CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RelationalBuffer.cc
Go to the documentation of this file.
1 #include "RelationalBuffer.h"
2 #include "RelationalOperation.h"
4 
6  m_schema( schema ),
7  m_operations(),
8  m_volatileBuffers(),
9  m_blobBuffer(){
10 }
11 
13  clear();
14 }
15 
17  InsertOperation* newOperation = new InsertOperation( tableName, m_schema );
18  m_operations.push_back( std::make_pair(newOperation,false) );
19  return *newOperation;
20 }
21 
23  BulkInsertOperation* newOperation = new BulkInsertOperation( tableName, m_schema );
24  m_operations.push_back( std::make_pair(newOperation,false) );
25  return *newOperation;
26 }
27 
29  MultiRecordInsertOperation* newOperation = new MultiRecordInsertOperation( tableName, m_schema );
30  m_operations.push_back( std::make_pair(newOperation,false) );
31  return *newOperation;
32 }
33 
35  bool addToResult ){
36  UpdateOperation* newOperation = new UpdateOperation( tableName, m_schema );
37  m_operations.push_back( std::make_pair(newOperation,addToResult) );
38  return *newOperation;
39 }
40 
42  bool addToResult ){
43  DeleteOperation* newOperation = new DeleteOperation( tableName, m_schema );
44  m_operations.push_back( std::make_pair(newOperation,addToResult) );
45  return *newOperation;
46 }
47 
48 
50  RelationalBuffer* newBuffer = new RelationalBuffer( m_schema );
51  m_volatileBuffers.push_back( newBuffer );
52  return *newBuffer;
53 }
54 
55 void ora::RelationalBuffer::storeBlob( boost::shared_ptr<coral::Blob> blob ){
56  m_blobBuffer.push_back( blob );
57 }
58 
60  for( std::vector< std::pair<IRelationalOperation*,bool> >::const_iterator iOp = m_operations.begin();
61  iOp != m_operations.end(); ++iOp ){
62  delete iOp->first;
63  }
64  m_operations.clear();
65  for( std::vector<RelationalBuffer*>::const_iterator iV = m_volatileBuffers.begin() ;
66  iV != m_volatileBuffers.end(); ++iV ){
67  delete *iV;
68  }
69  m_volatileBuffers.clear();
70  m_blobBuffer.clear();
71 }
72 
74  bool ret = true;
75  bool go = true;
76  std::vector< std::pair<IRelationalOperation*,bool> >::const_iterator iOp = m_operations.begin();
77  if( iOp != m_operations.end() ){
78  bool ok = (iOp->first)->execute();
79  go = ok || !(iOp->first)->isRequired();
80  ret = ret && (ok || !iOp->second);
81  iOp++;
82  }
83  for( ; iOp != m_operations.end(); ++iOp ){
84  if( go ){
85  bool ok = (iOp->first)->execute();
86  go = ok || !(iOp->first)->isRequired();
87  ret = ret && (ok || !iOp->second);
88  } else {
89  (iOp->first)->reset();
90  }
91  }
92  for( std::vector<RelationalBuffer*>::iterator iV = m_volatileBuffers.begin() ;
93  iV != m_volatileBuffers.end(); ++iV ){
94  (*iV)->flush();
95  delete *iV;
96  }
97  m_volatileBuffers.clear();
98  m_blobBuffer.clear();
99  return ret;
100 }
101 
102 
tuple ret
prodAgent to be discontinued
tuple schema
Definition: dataDML.py:2334
RelationalBuffer & addVolatileBuffer()
RelationalBuffer(coral::ISchema &schema)
InsertOperation & newInsert(const std::string &tableName)
BulkInsertOperation & newBulkInsert(const std::string &tableName)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
MultiRecordInsertOperation & newMultiRecordInsert(const std::string &tableName)
UpdateOperation & newUpdate(const std::string &tableName, bool addToResult=false)
void storeBlob(boost::shared_ptr< coral::Blob > blob)
void reset(double vett[256])
Definition: TPedValues.cc:11
DeleteOperation & newDelete(const std::string &tableName, bool addToResult=false)