11 #include "CoralBase/Attribute.h"
31 for( std::vector<std::string>::const_iterator iC = columns.begin();
32 iC != columns.end(); ++iC){
38 if( iMe == mapping.
end()){
41 "DependentClassWriter::write");
54 "DependentClassWriter::write");
58 coral::AttributeList::iterator iData = dataBuff.begin();
59 iData->data<
int>()= oId;
61 iData->data<
int>()= refId;
63 std::vector<int> recordId(1,refId);
90 if( iMap == depMapping.
end()){
93 "DependentClassReadBuffer::ReadBuffer");
107 "DependentClassReader::read");
109 coral::AttributeList& whereData =
m_depQuery->whereData();
110 coral::AttributeList::iterator iWData = whereData.begin();
111 iWData->data<
int>() = refId;
151 "RelationalRefLoader::load");
174 m_objectType( objectType ),
175 m_mappingElement( mapping ),
176 m_schema( contSchema ),
178 m_relationalData( 0 ),
179 m_operationBuffer( 0 ){
185 static const std::string nullLabel(
"ora::UniqueRef::Null");
195 m_dataElement = &dataElement;
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");
205 m_columnIndexes[1] = relationalData.
addData( columns[1],
typeid(
int) );
206 m_relationalData = &relationalData;
207 m_operationBuffer = &buffer;
220 "UniqueRefWriter::write");
223 void* refAddress = m_dataElement->address( data );
236 const std::type_info *refTypeInfo = 0;
239 m_objectType.functionMemberByName(
"typeInfo").invoke( refObj, &refTIObj);
244 MappingElement& depMapping = m_schema.mappingForDependentClass( refType,
true );
250 writer.
build( refType, depMapping, m_schema, m_operationBuffer->addVolatileBuffer() );
253 m_objectType.functionMemberByName(
"operator*").invoke( refObj, &refDataObj );
255 writer.
write( oid, refId, refData );
259 coral::AttributeList& parentData = m_relationalData->data();
260 parentData[m_columnIndexes[0]].data<
std::string>()=className;
261 parentData[m_columnIndexes[1]].data<
int>()=refId;
267 m_writer( objectType, mapping, contSchema ){
276 return m_writer.build( dataElement, relationalData, operationBuffer );
280 m_writer.setRecordId( identity );
286 m_writer.write( oid, data );
292 m_objectType( objectType ),
293 m_mappingElement( mapping ),
294 m_schema( contSchema ),
296 m_relationalData( 0 ),
303 for(std::vector<boost::shared_ptr<RelationalRefLoader> >::const_iterator iL = m_loaders.begin();
304 iL != m_loaders.end(); ++iL ){
311 m_dataElement = &dataElement;
312 const std::vector<std::string>&
columns = m_mappingElement.columnNames();
313 if( columns.size() < 2 ){
314 throwException(
"Expected column names have not been found in the mapping.",
315 "UniqueRefReader::build");
320 m_columnIndexes[1] = relationalData.
addData( columns[1],
typeid(
int) );
321 m_relationalData = &relationalData;
335 "UniqueRefReader::read");
337 coral::AttributeList& row = m_relationalData->data();
339 int refId = row[m_columnIndexes[1]].data<
int>();
344 MappingElement& depMapping = m_schema.mappingForDependentClass( refType );
349 void* loaderAddress = loaderElement.
address( data );
350 boost::shared_ptr<IPtrLoader>* loaderPtr =
static_cast<boost::shared_ptr<IPtrLoader>*
>( loaderAddress );
353 newLoader->build( refType, depMapping, m_schema );
354 m_loaders.push_back( newLoader );
356 boost::shared_ptr<IPtrLoader>
tmp( newLoader );
366 m_objectType( objectType ),
367 m_mapping( mapping ),
368 m_schema( contSchema ){
UniqueRefReader(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
void build(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema, RelationalBuffer &operationBuffer)
IRelationalReader * newReader()
void build(const edm::TypeWithDict &objectType, MappingElement &depMapping, ContainerSchema &contSchema)
void * load() const override
void * address(const void *topLevelAddress) const
void write(int oid, const void *data)
Writes a data element.
virtual ~UniqueRefReader()
bool build(DataElement &offset, IRelationalData &relationalData)
virtual int addData(const std::string &columnName, const std::type_info &columnType)=0
std::auto_ptr< IRelationalWriter > m_writer
IRelationalUpdater * newUpdater()
void setRecordId(const std::vector< int > &identity)
void write(int oId, int refId, const void *data)
UniqueRefWriter(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
virtual ~UniqueRefUpdater()
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
InsertOperation & newInsert(const std::string &tableName)
TypeWithDict typeOf() const
DataElement m_dataElement
void read(void *destination)
Reads a data element.
virtual ~UniqueRefWriter()
InsertOperation * m_depInsert
DataElement m_dataElement
std::string cppName() const
void setRecordId(const std::vector< int > &identity)
UniqueRefStreamer(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
void update(int oid, const void *data)
Updates a data element.
virtual ~RelationalRefLoader()
IRelationalWriter * newWriter(const edm::TypeWithDict &dataType, MappingElement &dataMapping)
void invoke(ObjectWithDict const &obj, ObjectWithDict *ret=nullptr, std::vector< void * > const &values=std::vector< void * >()) const
Call a member function.
void invalidate() override
DependentClassReader m_reader
iterator find(const std::string &key)
Retrieves a sub-element.
FunctionWithDict functionMemberByName(std::string const &) const
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
const std::vector< std::string > & columnNames() const
DataElement & addChild(size_t declaringScopeOffset, size_toffset)
edm::TypeWithDict lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
bool isValid() const override
IRelationalReader * newReader(const edm::TypeWithDict &dataType, MappingElement &dataMapping)
coral::ISchema & storageSchema()
void setRecordId(const std::vector< int > &identity)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
iterator end()
Returns an iterator in the end of the sequence.
std::vector< std::vector< double > > tmp
UniqueRefUpdater(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
void * constructObject(const edm::TypeWithDict &typ)
std::auto_ptr< IRelationalReader > m_reader
std::auto_ptr< SelectOperation > m_depQuery
const std::string & tableName() const
void build(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
RelationalRefLoader(int refId)
static std::string sequenceNameForDependentClass(const std::string &containerName, const std::string &className)
volatile std::atomic< bool > shutdown_flag false
std::string className(const T &t)
IRelationalWriter * newWriter()
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
std::string uniqueRefNullLabel()