test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PrimitiveStreamer.cc
Go to the documentation of this file.
2 #include "PrimitiveStreamer.h"
3 #include "DataElement.h"
4 #include "MappingElement.h"
5 #include "RelationalOperation.h"
6 #include "ClassUtils.h"
7 // externals
8 #include "CoralBase/Attribute.h"
9 
10 
12  MappingElement& mapping ):
13  m_objectType( objectType ),
14  m_mapping(mapping),
15  m_columnIndex(-1),
16  m_dataElement( 0 ),
17  m_relationalData( 0 ){
18 }
19 
21 }
22 
24  IRelationalData& relationalData){
25  if( m_mapping.columnNames().size()==0 ){
26  throwException( "The mapping element does not contain columns.",
27  "PrimitiveStreamerBase::buildDataElement");
28  }
29 
30  const std::type_info* attrType = m_objectType.isEnum() ? &typeid(int) : &m_objectType.typeInfo();
31  if(ClassUtils::isTypeString( m_objectType )) attrType = &typeid(std::string);
32  std::string columnName = m_mapping.columnNames()[0];
33  m_columnIndex = relationalData.addData( columnName, *attrType );
34  m_dataElement = &dataElement;
35  m_relationalData = &relationalData;
36  return true;
37 }
38 
40  if( ! m_dataElement ){
41  throwException( "The streamer has not been built.",
42  "PrimitiveStreamerBase::bindDataForUpdate");
43  }
44  void* dataElementAddress = m_dataElement->address( data );
45  coral::Attribute& relDataElement = m_relationalData->data()[ m_columnIndex ];
46  relDataElement.setValueFromAddress( dataElementAddress );
47  if(!relDataElement.isValidData()){
48  throwException("Data provided for column \""+
49  relDataElement.specification().name()+
50  "\" is not valid for RDBMS storage.",
51  "PrimitiveStreamerBase::bindDataForUpdate");
52  }
53 }
54 
56  if( ! m_dataElement ){
57  throwException( "The streamer has not been built.",
58  "PrimitiveStreamerBase::bindDataForRead");
59  }
60  void* dataElementAddress = m_dataElement->address( data );
61  coral::Attribute& relDataElement = m_relationalData->data()[ m_columnIndex ];
62  relDataElement.copyValueToAddress( dataElementAddress );
63 }
64 
65 
67  MappingElement& mapping ):
68  PrimitiveStreamerBase( objectType, mapping ){
69 }
70 
72 }
73 
75  IRelationalData& relationalData,
77  return buildDataElement( dataElement, relationalData );
78 }
79 
80 void ora::PrimitiveWriter::setRecordId( const std::vector<int>& ){
81 }
82 
83 void ora::PrimitiveWriter::write( int, const void* data ){
84  bindDataForUpdate( data );
85 }
86 
88  MappingElement& mapping ):
89  PrimitiveStreamerBase( objectType, mapping ){
90 }
91 
93 }
94 
96  IRelationalData& relationalData,
98  return buildDataElement( dataElement, relationalData );
99 }
100 
101 void ora::PrimitiveUpdater::setRecordId( const std::vector<int>& ){
102 }
103 
105  const void* data ){
106  bindDataForUpdate( data );
107 }
108 
110  MappingElement& mapping ):
111  PrimitiveStreamerBase( objectType, mapping ){
112 }
113 
115 }
116 
118  IRelationalData& relationalData){
119  return buildDataElement( dataElement, relationalData );
120 }
121 
123 }
124 
125 void ora::PrimitiveReader::setRecordId( const std::vector<int>& ){
126 }
127 
129  bindDataForRead( data );
130 }
131 
133 }
134 
135 
137  MappingElement& mapping ):
138  m_objectType( objectType ),
139  m_mapping( mapping ){
140 }
141 
143 }
144 
146  return new PrimitiveWriter( m_objectType, m_mapping );
147 }
148 
150  return new PrimitiveUpdater( m_objectType, m_mapping );
151 }
152 
154  return new PrimitiveReader( m_objectType, m_mapping );
155 }
IRelationalUpdater * newUpdater()
PrimitiveUpdater(const edm::TypeWithDict &objectType, MappingElement &mapping)
IRelationalWriter * newWriter()
virtual int addData(const std::string &columnName, const std::type_info &columnType)=0
bool isTypeString(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:215
bool buildDataElement(DataElement &dataElement, IRelationalData &relationalData)
PrimitiveWriter(const edm::TypeWithDict &objectType, MappingElement &mapping)
void setRecordId(const std::vector< int > &identity)
void write(int oid, const void *data)
Writes a data element.
void read(void *data)
Reads a data element.
PrimitiveStreamer(const edm::TypeWithDict &objectType, MappingElement &mapping)
void update(int oid, const void *data)
Updates a data element.
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void bindDataForRead(void *data)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void setRecordId(const std::vector< int > &identity)
void bindDataForUpdate(const void *data)
bool build(DataElement &dataElement, IRelationalData &relationalData)
PrimitiveStreamerBase(const edm::TypeWithDict &objectType, MappingElement &mapping)
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
IRelationalReader * newReader()
PrimitiveReader(const edm::TypeWithDict &objectType, MappingElement &mapping)
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
void setRecordId(const std::vector< int > &identity)