CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InlineCArrayStreamer.cc
Go to the documentation of this file.
2 #include "InlineCArrayStreamer.h"
3 #include "DataElement.h"
4 #include "MappingElement.h"
5 #include "RelationalOperation.h"
6 #include "MappingRules.h"
7 #include "ClassUtils.h"
8 // externals
9 #include "CoralBase/Attribute.h"
10 
11 
13  MappingElement& mapping,
14  ContainerSchema& contSchema):
15  m_objectType( objectType ),
16  m_arrayType(),
17  m_streamerFactory( contSchema ),
18  m_mapping( mapping ){
19 }
20 
22 }
23 
24 
26  IRelationalData& relationalData,
27  RelationalBuffer* operationBuffer){
28  m_arrayType = ClassUtils::resolvedType( m_objectType.toType() );
29  if ( ! m_arrayType ) {
30  throwException( "Missing dictionary information for the element of array \"" +
31  m_objectType.cppName() + "\"",
32  "InlineCArrayStreamerBase::buildDataElement" );
33  }
34  // Loop over the elements of the array.
35  for ( size_t i=0;i<m_objectType.maximumIndex(0U);++i){
36 
37  // Form the element name
38  std::string arrayElementLabel = MappingRules::variableNameForArrayIndex( m_mapping.variableName(),i);
39 
40  // Retrieve the relevant mapping element
41  MappingElement::iterator iMe = m_mapping.find( arrayElementLabel );
42  if ( iMe == m_mapping.end() ) {
43  throwException( "Mapping for Array Element \"" + arrayElementLabel + "\" not found in the mapping element",
44  "InlineCArrayStreamerBase::buildDataElement" );
45  }
46  MappingElement& arrayElementMapping = iMe->second;
47  DataElement& arrayElement = dataElement.addChild( i*m_arrayType.size(), 0 );
48 
49  processArrayElement( arrayElement, relationalData, arrayElementMapping, operationBuffer );
50  }
51  return true;
52 }
53 
55  MappingElement& mapping,
56  ContainerSchema& contSchema ):
57  InlineCArrayStreamerBase( objectType, mapping, contSchema ),
58  m_writers(){
59 }
60 
62  for( std::vector< IRelationalWriter* >::iterator iW = m_writers.begin();
63  iW != m_writers.end(); ++iW ){
64  delete *iW;
65  }
66  m_writers.clear();
67 }
68 
70  IRelationalData& relationalData,
71  MappingElement& arrayElementMapping,
72  RelationalBuffer* operationBuffer ){
73  IRelationalWriter* arrayElementWriter = m_streamerFactory.newWriter( m_arrayType, arrayElementMapping );
74  m_writers.push_back( arrayElementWriter );
75  arrayElementWriter->build( arrayElementOffset, relationalData, *operationBuffer );
76 }
77 
79  IRelationalData& relationalData,
80  RelationalBuffer& operationBuffer){
81  return buildDataElement( dataElement, relationalData, &operationBuffer );
82 }
83 
84 void ora::InlineCArrayWriter::setRecordId( const std::vector<int>& identity ){
85  for( std::vector< IRelationalWriter* >::iterator iW = m_writers.begin();
86  iW != m_writers.end(); ++iW ){
87  (*iW)->setRecordId( identity );
88  }
89 }
90 
91 void ora::InlineCArrayWriter::write( int oid, const void* data ){
92  for( std::vector< IRelationalWriter* >::iterator iW = m_writers.begin();
93  iW != m_writers.end(); ++iW ){
94  (*iW)->write( oid, data );
95  }
96 }
97 
99  MappingElement& mapping,
100  ContainerSchema& contSchema ):
101  InlineCArrayStreamerBase( objectType, mapping, contSchema ),
102  m_updaters(){
103 }
104 
106  for( std::vector< IRelationalUpdater* >::iterator iU = m_updaters.begin();
107  iU != m_updaters.end(); ++iU ){
108  delete *iU;
109  }
110  m_updaters.clear();
111 }
112 
114  IRelationalData& relationalData,
115  MappingElement& arrayElementMapping,
116  RelationalBuffer* operationBuffer ){
117  IRelationalUpdater* arrayElementUpdater = m_streamerFactory.newUpdater( m_arrayType, arrayElementMapping );
118  m_updaters.push_back( arrayElementUpdater );
119  arrayElementUpdater->build( arrayElementOffset, relationalData, *operationBuffer );
120 }
121 
123  IRelationalData& relationalData,
124  RelationalBuffer& operationBuffer){
125  return buildDataElement( dataElement, relationalData, &operationBuffer );
126 }
127 
128 void ora::InlineCArrayUpdater::setRecordId( const std::vector<int>& identity ){
129  for( std::vector< IRelationalUpdater* >::iterator iU = m_updaters.begin();
130  iU != m_updaters.end(); ++iU){
131  (*iU)->setRecordId( identity );
132  }
133 }
134 
136  const void* data ){
137  for( std::vector< IRelationalUpdater* >::iterator iU = m_updaters.begin();
138  iU != m_updaters.end(); ++iU ){
139  (*iU)->update( oid, data );
140  }
141 }
142 
144  MappingElement& mapping,
145  ContainerSchema& contSchema ):
146  InlineCArrayStreamerBase( objectType, mapping, contSchema ),
147  m_readers(){
148 }
149 
151  for( std::vector< IRelationalReader* >::iterator iStr = m_readers.begin();
152  iStr != m_readers.end(); ++iStr ){
153  delete *iStr;
154  }
155  m_readers.clear();
156 }
157 
159  IRelationalData& relationalData,
160  MappingElement& arrayElementMapping,
162  IRelationalReader* arrayElementReader = m_streamerFactory.newReader( m_arrayType, arrayElementMapping );
163  m_readers.push_back( arrayElementReader );
164  arrayElementReader->build( arrayElementOffset, relationalData );
165 }
166 
168  IRelationalData& relationalData){
169  return buildDataElement( dataElement, relationalData, 0 );
170 }
171 
173  for( std::vector< IRelationalReader* >::iterator iDepReader = m_readers.begin();
174  iDepReader != m_readers.end(); ++iDepReader ){
175  (*iDepReader)->select( oid );
176  }
177 }
178 
179 void ora::InlineCArrayReader::setRecordId( const std::vector<int>& identity ){
180  for( std::vector< IRelationalReader* >::iterator iDepReader = m_readers.begin();
181  iDepReader != m_readers.end(); ++iDepReader ){
182  (*iDepReader)->setRecordId( identity );
183  }
184 }
185 
187  for( std::vector< IRelationalReader* >::iterator iDepReader = m_readers.begin();
188  iDepReader != m_readers.end(); ++iDepReader ){
189  (*iDepReader)->read( data );
190  }
191 }
192 
194  for( std::vector< IRelationalReader* >::iterator iDepReader = m_readers.begin();
195  iDepReader != m_readers.end(); ++iDepReader ){
196  (*iDepReader)->clear();
197  }
198 }
199 
201  MappingElement& mapping,
203  m_objectType( objectType ),
204  m_mapping( mapping ),
205  m_schema( schema ){
206 }
207 
209 }
210 
212  return new InlineCArrayWriter( m_objectType, m_mapping, m_schema );
213 }
214 
216  return new InlineCArrayUpdater( m_objectType, m_mapping, m_schema );
217 }
218 
220  return new InlineCArrayReader( m_objectType, m_mapping, m_schema );
221 }
int i
Definition: DBlmapReader.cc:9
void setRecordId(const std::vector< int > &identity)
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:486
static std::string variableNameForArrayIndex(const std::string &arrayVariable, unsigned int index)
IRelationalReader * newReader()
virtual bool build(DataElement &offset, IRelationalData &relationalData, RelationalBuffer &operationBuffer)=0
InlineCArrayReader(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
bool build(DataElement &dataElement, IRelationalData &relationalData)
void read(void *data)
Reads a data element.
InlineCArrayStreamer(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
virtual bool build(DataElement &offset, IRelationalData &relationalData)=0
InlineCArrayWriter(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
InlineCArrayUpdater(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
IRelationalUpdater * newUpdater()
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
void write(int oid, const void *data)
Writes a data element.
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
DataElement & addChild(size_t declaringScopeOffset, size_toffset)
Definition: DataElement.cc:27
bool buildDataElement(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer *operationBuffer)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
virtual bool build(DataElement &offset, IRelationalData &relationalData, RelationalBuffer &operationBuffer)=0
void update(int oid, const void *data)
Updates a data element.
void processArrayElement(DataElement &arrayElementOffset, IRelationalData &relationalData, MappingElement &arrayElementMapping, RelationalBuffer *operationBuffer)
void setRecordId(const std::vector< int > &identity)
void setRecordId(const std::vector< int > &identity)
void processArrayElement(DataElement &arrayElementOffset, IRelationalData &relationalData, MappingElement &arrayElementMapping, RelationalBuffer *operationBuffer)
InlineCArrayStreamerBase(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
void processArrayElement(DataElement &arrayElementOffset, IRelationalData &relationalData, MappingElement &arrayElementMapping, RelationalBuffer *operationBuffer)
IRelationalWriter * newWriter()