CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ora::UniqueRefWriter Class Reference

#include <UniqueRefStreamer.h>

Inheritance diagram for ora::UniqueRefWriter:
ora::IRelationalWriter

Public Member Functions

bool build (DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
 
void setRecordId (const std::vector< int > &identity)
 
 UniqueRefWriter (const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
 
void write (int oid, const void *data)
 Writes a data element. More...
 
virtual ~UniqueRefWriter ()
 
- Public Member Functions inherited from ora::IRelationalWriter
virtual ~IRelationalWriter ()
 Destructor. More...
 

Private Attributes

int m_columnIndexes [2]
 
DataElementm_dataElement
 
MappingElementm_mappingElement
 
edm::TypeWithDict m_objectType
 
RelationalBufferm_operationBuffer
 
IRelationalDatam_relationalData
 
ContainerSchemam_schema
 

Detailed Description

Definition at line 23 of file UniqueRefStreamer.h.

Constructor & Destructor Documentation

ora::UniqueRefWriter::UniqueRefWriter ( const edm::TypeWithDict objectType,
MappingElement mapping,
ContainerSchema contSchema 
)

Definition at line 171 of file UniqueRefStreamer.cc.

References m_columnIndexes.

173  :
174  m_objectType( objectType ),
175  m_mappingElement( mapping ),
176  m_schema( contSchema ),
177  m_dataElement( 0 ),
178  m_relationalData( 0 ),
179  m_operationBuffer( 0 ){
180  m_columnIndexes[0]=-1;
181  m_columnIndexes[1]=-1;
182 }
RelationalBuffer * m_operationBuffer
DataElement * m_dataElement
edm::TypeWithDict m_objectType
IRelationalData * m_relationalData
ContainerSchema & m_schema
MappingElement & m_mappingElement
ora::UniqueRefWriter::~UniqueRefWriter ( )
virtual

Definition at line 189 of file UniqueRefStreamer.cc.

189  {
190 }

Member Function Documentation

bool ora::UniqueRefWriter::build ( DataElement dataElement,
IRelationalData relationalData,
RelationalBuffer operationBuffer 
)
virtual

Implements ora::IRelationalWriter.

Definition at line 192 of file UniqueRefStreamer.cc.

References ora::IRelationalData::addData(), AlCaHLTBitMon_QueryRunRegistry::string, and ora::throwException().

Referenced by psClasses.BuildThread::run().

194  {
195  m_dataElement = &dataElement;
196 
197  const std::vector<std::string>& columns = m_mappingElement.columnNames();
198  if( columns.size() < 2 ){
199  throwException("Expected column names have not been found in the mapping.",
200  "UniqueRefWriter::build");
201  }
202  // booking for ref metadata
203  m_columnIndexes[0] = relationalData.addData( columns[0],typeid(std::string) );
204  // booking for ref id
205  m_columnIndexes[1] = relationalData.addData( columns[1],typeid(int) );
206  m_relationalData = &relationalData;
207  m_operationBuffer = &buffer;
208  return true;
209 }
RelationalBuffer * m_operationBuffer
DataElement * m_dataElement
IRelationalData * m_relationalData
const std::vector< std::string > & columnNames() const
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
MappingElement & m_mappingElement
void ora::UniqueRefWriter::setRecordId ( const std::vector< int > &  identity)
virtual

Implements ora::IRelationalWriter.

Definition at line 211 of file UniqueRefStreamer.cc.

211  {
212 }
void ora::UniqueRefWriter::write ( int  oid,
const void *  data 
)
virtual

Writes a data element.

Implements ora::IRelationalWriter.

Definition at line 215 of file UniqueRefStreamer.cc.

References ora::DependentClassWriter::build(), className(), edm::TypeWithDict::cppName(), edm::TypeWithDict::functionMemberByName(), edm::FunctionWithDict::invoke(), ora::ClassUtils::lookupDictionary(), ora::MappingRules::sequenceNameForDependentClass(), AlCaHLTBitMon_QueryRunRegistry::string, ora::throwException(), edm::ObjectWithDict::typeOf(), ora::uniqueRefNullLabel(), and ora::DependentClassWriter::write().

Referenced by pkg.AbstractPkg::generate(), and querying.connection::write_and_commit().

216  {
217 
218  if(!m_dataElement){
219  throwException("The streamer has not been built.",
220  "UniqueRefWriter::write");
221  }
222 
223  void* refAddress = m_dataElement->address( data );
224 
225  edm::ObjectWithDict refObj( m_objectType, const_cast<void*>(refAddress));
226 
227  bool isNull;
228  edm::ObjectWithDict resObj = edm::ObjectWithDict(edm::TypeWithDict(typeid(bool)), &isNull);
229  refObj.typeOf().functionMemberByName("operator!").invoke(refObj, &resObj);
230 
231  int refId = 0;
233 
234  if(!isNull){
235  // resolving the ref type
236  const std::type_info *refTypeInfo = 0;
237  edm::TypeWithDict typeInfoDict( typeid(std::type_info*) );
238  edm::ObjectWithDict refTIObj( typeInfoDict, &refTypeInfo );
239  m_objectType.functionMemberByName("typeInfo").invoke( refObj, &refTIObj);
240  edm::TypeWithDict refType = ClassUtils::lookupDictionary( *refTypeInfo );
241  className = refType.cppName();
242 
243  // building the dependent buffer
244  MappingElement& depMapping = m_schema.mappingForDependentClass( refType, true );
245 
246  // getting a new valid ref id
248 
249  DependentClassWriter writer;
250  writer.build( refType, depMapping, m_schema, m_operationBuffer->addVolatileBuffer() );
251  void* refData = 0;
252  edm::ObjectWithDict refDataObj(edm::TypeWithDict(typeid(void*)), &refData);
253  m_objectType.functionMemberByName("operator*").invoke( refObj, &refDataObj );
254 
255  writer.write( oid, refId, refData );
256 
257  }
258  // writing in the parent table
259  coral::AttributeList& parentData = m_relationalData->data();
260  parentData[m_columnIndexes[0]].data<std::string>()=className;
261  parentData[m_columnIndexes[1]].data<int>()=refId;
262 }
Sequences & containerSequences()
RelationalBuffer * m_operationBuffer
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:49
DataElement * m_dataElement
RelationalBuffer & addVolatileBuffer()
edm::TypeWithDict m_objectType
std::string cppName() const
void invoke(ObjectWithDict const &obj, ObjectWithDict *ret=nullptr, std::vector< void * > const &values=std::vector< void * >()) const
Call a member function.
IRelationalData * m_relationalData
FunctionWithDict functionMemberByName(std::string const &) const
ContainerSchema & m_schema
edm::TypeWithDict lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:170
virtual coral::AttributeList & data()=0
int getNextId(const std::string &sequenceName, bool sinchronize=false)
Definition: Sequences.cc:22
const std::string & containerName()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static std::string sequenceNameForDependentClass(const std::string &containerName, const std::string &className)
Definition: MappingRules.cc:21
std::string className(const T &t)
Definition: ClassName.h:30
MappingElement & mappingForDependentClass(const edm::TypeWithDict &dependentClass, bool writeEnabled=false)
std::string uniqueRefNullLabel()

Member Data Documentation

int ora::UniqueRefWriter::m_columnIndexes[2]
private

Definition at line 42 of file UniqueRefStreamer.h.

Referenced by UniqueRefWriter().

DataElement* ora::UniqueRefWriter::m_dataElement
private

Definition at line 44 of file UniqueRefStreamer.h.

MappingElement& ora::UniqueRefWriter::m_mappingElement
private

Definition at line 41 of file UniqueRefStreamer.h.

edm::TypeWithDict ora::UniqueRefWriter::m_objectType
private

Definition at line 40 of file UniqueRefStreamer.h.

RelationalBuffer* ora::UniqueRefWriter::m_operationBuffer
private

Definition at line 46 of file UniqueRefStreamer.h.

IRelationalData* ora::UniqueRefWriter::m_relationalData
private

Definition at line 45 of file UniqueRefStreamer.h.

ContainerSchema& ora::UniqueRefWriter::m_schema
private

Definition at line 43 of file UniqueRefStreamer.h.