CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cond::persistency::GTEditor Class Reference

#include <GTEditor.h>

Public Member Functions

std::string description () const
 
bool flush ()
 
bool flush (const boost::posix_time::ptime &operationTime)
 
 GTEditor ()
 
 GTEditor (const std::shared_ptr< SessionImpl > &session)
 
 GTEditor (const std::shared_ptr< SessionImpl > &session, const std::string &gtName)
 
 GTEditor (const GTEditor &rhs)
 
void insert (const std::string &recordName, const std::string &tagName, bool checkType=false)
 
void insert (const std::string &recordName, const std::string &recordLabel, const std::string &tagName, bool checkType=false)
 
void load (const std::string &gtName)
 
std::string name () const
 
GTEditoroperator= (const GTEditor &rhs)
 
std::string release () const
 
void setDescription (const std::string &description)
 
void setRelease (const std::string &release)
 
void setSnapshotTime (const boost::posix_time::ptime &snapshotTime)
 
void setValidity (cond::Time_t validity)
 
boost::posix_time::ptime snapshotTime () const
 
cond::Time_t validity () const
 

Private Member Functions

void checkTransaction (const std::string &ctx)
 

Private Attributes

std::shared_ptr< GTEditorDatam_data
 
std::shared_ptr< SessionImplm_session
 

Detailed Description

Definition at line 28 of file GTEditor.h.

Constructor & Destructor Documentation

GTEditor::GTEditor ( )

Definition at line 31 of file GTEditor.cc.

31  :
32  m_data(),
33  m_session(){
34  }
std::shared_ptr< SessionImpl > m_session
Definition: GTEditor.h:79
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
GTEditor::GTEditor ( const std::shared_ptr< SessionImpl > &  session)
explicit

Definition at line 36 of file GTEditor.cc.

36  :
37  m_data( new GTEditorData ),
38  m_session( session ){
39  }
std::shared_ptr< SessionImpl > m_session
Definition: GTEditor.h:79
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
GTEditor::GTEditor ( const std::shared_ptr< SessionImpl > &  session,
const std::string &  gtName 
)

Definition at line 41 of file GTEditor.cc.

References m_data.

42  :
43  m_data( new GTEditorData ),
44  m_session( session ){
45  m_data->name = gtName;
46  m_data->change = true;
47  }
std::shared_ptr< SessionImpl > m_session
Definition: GTEditor.h:79
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
GTEditor::GTEditor ( const GTEditor rhs)

Definition at line 49 of file GTEditor.cc.

49  :
50  m_data( rhs.m_data ),
51  m_session( rhs.m_session ){
52  }
std::shared_ptr< SessionImpl > m_session
Definition: GTEditor.h:79
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78

Member Function Documentation

void GTEditor::checkTransaction ( const std::string &  ctx)
private

Definition at line 169 of file GTEditor.cc.

References m_session, and cond::persistency::throwException().

Referenced by flush(), and load().

169  {
170  if( !m_session.get() ) throwException("The session is not active.",ctx );
171  if( !m_session->isTransactionActive( false ) ) throwException("The transaction is not active.",ctx );
172  }
std::shared_ptr< SessionImpl > m_session
Definition: GTEditor.h:79
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::string GTEditor::description ( ) const

Definition at line 87 of file GTEditor.cc.

References m_data.

Referenced by setDescription().

87  {
88  return m_data.get()? m_data->description : "";
89  }
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
bool GTEditor::flush ( )

Definition at line 164 of file GTEditor.cc.

164  {
165  return flush( boost::posix_time::microsec_clock::universal_time() );
166  }
bool GTEditor::flush ( const boost::posix_time::ptime &  operationTime)

Definition at line 136 of file GTEditor.cc.

References checkTransaction(), m_data, m_session, and cond::persistency::throwException().

136  {
137  bool ret = false;
138  checkTransaction( "GTEditor::flush" );
139  if( m_data->change ){
140  if( m_data->description.empty() ) throwException( "A non-empty Description string is mandatory.","GTEditor::flush" );
141  if( m_data->release.empty() ) throwException( "A non-empty Release string is mandatory.","GTEditor::flush" );
142  if( !m_data->exists ){
143  m_session->gtSchema().gtTable().insert( m_data->name, m_data->validity, m_data->description,
144  m_data->release, m_data->snapshotTime, operationTime );
145  ret = true;
146  m_data->exists = true;
147  } else {
148  m_session->gtSchema().gtTable().update( m_data->name, m_data->validity, m_data->description,
149  m_data->release,m_data->snapshotTime, operationTime );
150  ret = true;
151  }
152  m_data->change = false;
153  }
154  if( !m_data->tagListBuffer.empty() ) {
155 
156  // insert the new iovs
157  m_session->gtSchema().gtMapTable().insert( m_data->name, m_data->tagListBuffer );
158  m_data->tagListBuffer.clear();
159  ret = true;
160  }
161  return ret;
162  }
std::shared_ptr< SessionImpl > m_session
Definition: GTEditor.h:79
void checkTransaction(const std::string &ctx)
Definition: GTEditor.cc:169
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
void GTEditor::insert ( const std::string &  recordName,
const std::string &  tagName,
bool  checkType = false 
)

Definition at line 120 of file GTEditor.cc.

Referenced by BeautifulSoup.PageElement::append().

120  {
122  }
void insert(const std::string &recordName, const std::string &tagName, bool checkType=false)
Definition: GTEditor.cc:120
void GTEditor::insert ( const std::string &  recordName,
const std::string &  recordLabel,
const std::string &  tagName,
bool  checkType = false 
)

Definition at line 124 of file GTEditor.cc.

References m_data, candidateCombinedSecondaryVertexSoftLeptonCvsLComputer_cfi::recordLabel, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by BeautifulSoup.PageElement::append().

124  {
125  if( m_data.get() ){
126  // here the type check could be added
127 
128  std::string rlabel = recordLabel;
129  if( rlabel.empty() ){
130  rlabel = "-";
131  }
132  m_data->tagListBuffer.push_back( std::tie( recordName, rlabel, tagName ) );
133  }
134  }
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
void GTEditor::load ( const std::string &  gtName)

Definition at line 60 of file GTEditor.cc.

References checkTransaction(), m_data, m_session, and cond::persistency::throwException().

Referenced by cond::persistency::Session::editGlobalTag(), MatrixToProcess.MatrixToProcess::getProcess(), MatrixToProcess.MatrixToProcess::listAll(), and ConfigBuilder.ConfigBuilder::prepare_FILTER().

60  {
61  checkTransaction( "GTEditor::load" );
62 
63  // loads the current header data in memory
64  if( !m_session->gtSchema().gtTable().select( gtName, m_data->validity, m_data->description, m_data->release, m_data->snapshotTime ) ){
65  throwException( "Global Tag \""+gtName+"\" has not been found in the database.","GTEditor::load");
66  }
67  m_data->name = gtName;
68  m_data->exists = true;
69  m_data->change = false;
70  }
std::shared_ptr< SessionImpl > m_session
Definition: GTEditor.h:79
void checkTransaction(const std::string &ctx)
Definition: GTEditor.cc:169
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
std::string GTEditor::name ( ) const

Definition at line 72 of file GTEditor.cc.

References m_data.

Referenced by config.CFG::__str__(), validation.Sample::digest(), VIDSelectorBase.VIDSelectorBase::initialize(), and Vispa.Views.PropertyView.Property::valueChanged().

72  {
73  return m_data.get()? m_data->name : "" ;
74  }
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
GTEditor & GTEditor::operator= ( const GTEditor rhs)

Definition at line 54 of file GTEditor.cc.

References m_data, and m_session.

54  {
55  m_data = rhs.m_data;
56  m_session = rhs.m_session;
57  return *this;
58  }
std::shared_ptr< SessionImpl > m_session
Definition: GTEditor.h:79
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
std::string GTEditor::release ( ) const

Definition at line 98 of file GTEditor.cc.

References m_data.

Referenced by setRelease().

98  {
99  return m_data.get()? m_data->release : "";
100  }
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
void GTEditor::setDescription ( const std::string &  description)

Definition at line 91 of file GTEditor.cc.

References description(), and m_data.

91  {
92  if( m_data.get() ) {
93  m_data->description = description;
94  m_data->change = true;
95  }
96  }
std::string description() const
Definition: GTEditor.cc:87
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
void GTEditor::setRelease ( const std::string &  release)

Definition at line 102 of file GTEditor.cc.

References m_data, and release().

102  {
103  if( m_data.get() ) {
104  m_data->release = release;
105  m_data->change = true;
106  }
107  }
std::string release() const
Definition: GTEditor.cc:98
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
void GTEditor::setSnapshotTime ( const boost::posix_time::ptime &  snapshotTime)

Definition at line 113 of file GTEditor.cc.

References m_data, and snapshotTime().

113  {
114  if( m_data.get() ) {
115  m_data->snapshotTime = snapshotTime;
116  m_data->change = true;
117  }
118  }
boost::posix_time::ptime snapshotTime() const
Definition: GTEditor.cc:109
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
void GTEditor::setValidity ( cond::Time_t  validity)

Definition at line 80 of file GTEditor.cc.

References m_data, and validity().

80  {
81  if( m_data.get() ) {
82  m_data->validity = validity;
83  m_data->change = true;
84  }
85  }
cond::Time_t validity() const
Definition: GTEditor.cc:76
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
boost::posix_time::ptime GTEditor::snapshotTime ( ) const

Definition at line 109 of file GTEditor.cc.

References m_data.

Referenced by setSnapshotTime().

109  {
110  return m_data.get()? m_data->snapshotTime : boost::posix_time::ptime();
111  }
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78
cond::Time_t GTEditor::validity ( ) const

Definition at line 76 of file GTEditor.cc.

References m_data, and cond::time::MIN_VAL().

Referenced by setValidity().

76  {
77  return m_data.get()? m_data->validity : cond::time::MIN_VAL;
78  }
const Time_t MIN_VAL(0)
std::shared_ptr< GTEditorData > m_data
Definition: GTEditor.h:78

Member Data Documentation

std::shared_ptr<GTEditorData> cond::persistency::GTEditor::m_data
private
std::shared_ptr<SessionImpl> cond::persistency::GTEditor::m_session
private

Definition at line 79 of file GTEditor.h.

Referenced by checkTransaction(), flush(), load(), and operator=().