10 #include "CoralBase/Attribute.h"
36 size_t cols = columns.size();
37 for(
size_t i=0;
i<cols;
i++ ){
45 if ( ! ptrType || !ptrResolvedType ) {
46 throwException(
"Missing dictionary information for the type of the pointer \"" +
48 "OraPtrReadBuffer::build" );
55 throwException(
"Item for \"" + ptrTypeName +
"\" not found in the mapping element",
56 "OraPtrReadBuffer::build" );
63 void*
read(
const std::vector<int>& fullId ){
66 if(!fullId.size())
throwException(
"Object id set is empty.",
"OraPtrReadBuffer::read");
69 coral::AttributeList::iterator iCol = whereBuff.begin();
71 for( coral::AttributeList::iterator iCol = whereBuff.begin(); iCol != whereBuff.end(); ++iCol ){
72 if( i<fullId.size() ){
73 iCol->data<
int>() = fullId[i];
78 std::vector<int> recordId( fullId.size()-1 );
79 for(
size_t i=0; i<fullId.size()-1; i++ ){
80 recordId[
i] = fullId[i+1];
86 void* destination = 0;
122 "RelationalPtrLoader::load");
145 m_objectType( objectType ),
146 m_mappingElement( mapping ),
147 m_schema( contSchema ),
159 m_dataElement = &dataElement;
160 m_localElement.
clear();
166 if ( ! ptrType || !ptrResolvedType ) {
167 throwException(
"Missing dictionary information for the type of the pointer \"" +
168 m_objectType.cppName() +
"\"",
169 "OraPtrWriter::build" );
175 if ( iMe == m_mappingElement.end() ) {
176 throwException(
"Item for \"" + ptrTypeName +
"\" not found in the mapping element",
177 "OraPtrWriter::build" );
180 m_writer.reset( streamerFactory.
newWriter( ptrResolvedType, iMe->second ));
181 return m_writer->build( m_localElement, relationalData, operationBuffer );
185 m_writer->setRecordId( identity );
194 "OraPtrWriter::write");
199 m_objectType.functionMemberByName(
"load").invoke(ptrObject,
nullptr);
201 void* ptrAddress =
nullptr;
203 m_objectType.functionMemberByName(
"address").invoke(ptrObject, &ptrAddrObj);
204 m_writer->write( oid, ptrAddress );
210 m_objectType( objectType ),
211 m_mappingElement( mapping ),
212 m_schema( contSchema ),
224 m_dataElement = &dataElement;
225 m_localElement.
clear();
231 if ( ! ptrType || !ptrResolvedType ) {
232 throwException(
"Missing dictionary information for the type of the pointer \"" +
233 m_objectType.cppName() +
"\"",
234 "OraPtrUpdater::build" );
240 if ( iMe == m_mappingElement.end() ) {
241 throwException(
"Item for \"" + ptrTypeName +
"\" not found in the mapping element",
242 "OraPtrUpdater::build" );
245 m_updater.reset( streamerFactory.
newUpdater( ptrResolvedType, iMe->second ) );
246 return m_updater->build( m_localElement, relationalData, operationBuffer );
250 m_updater->setRecordId( identity );
258 "OraPtrUpdater::update");
262 m_objectType.functionMemberByName(
"load").invoke(ptrObject,
nullptr);
263 void *ptrAddress =
nullptr;
265 m_objectType.functionMemberByName(
"address").invoke(ptrObject, &ptrAddrObj);
266 m_updater->update( oid, ptrAddress );
272 m_objectType( objectType ),
281 for(std::vector<boost::shared_ptr<IPtrLoader> >::const_iterator iL = m_loaders.begin();
282 iL != m_loaders.end(); ++iL ){
289 m_dataElement = &dataElement;
291 m_tmpIds.push_back(0);
292 return m_readBuffer->build( dataElement );
296 if(!m_dataElement)
throwException(
"The streamer has not been built.",
"OraPtrReader::select");
301 m_tmpIds.resize( 1+identity.size() );
302 for(
size_t i=0;
i<identity.size();
i++){
303 m_tmpIds[1+
i] = identity[
i];
311 "OraPtrReader::read");
316 void* loaderAddress = loaderElement.
address( data );
317 boost::shared_ptr<IPtrLoader>* loaderPtr =
static_cast<boost::shared_ptr<IPtrLoader>*
>( loaderAddress );
319 boost::shared_ptr<IPtrLoader> newLoader(
new RelationalPtrLoader( *m_readBuffer, m_tmpIds ) );
320 m_loaders.push_back( newLoader );
322 *loaderPtr = newLoader;
332 m_objectType( objectType ),
333 m_mapping( mapping ),
334 m_schema( contSchema ){
341 return new OraPtrWriter( m_objectType, m_mapping, m_schema );
345 return new OraPtrUpdater( m_objectType, m_mapping, m_schema );
349 return new OraPtrReader( m_objectType, m_mapping, m_schema );
void update(int oid, const void *data)
Updates a data element.
void setRecordId(const std::vector< int > &identity)
OraPtrReadBuffer(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
void * address(const void *topLevelAddress) const
DataElement * m_dataElement
void * read(const std::vector< int > &fullId)
virtual ~RelationalPtrLoader()
OraPtrUpdater(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
IRelationalUpdater * newUpdater()
void write(int oid, const void *data)
Writes a data element.
std::auto_ptr< IRelationalReader > m_reader
int addWhereId(const std::string &columnName)
bool build(DataElement &dataElement)
TypeWithDict templateArgumentAt(size_t index) const
OraPtrReadBuffer & m_buffer
DataElement m_localElement
bool build(DataElement &offset, IRelationalData &relationalData)
std::string cppName() const
void * load() const override
void setRecordId(const std::vector< int > &identity)
void read(void *destination)
Reads a data element.
IRelationalWriter * newWriter()
IRelationalWriter * newWriter(const edm::TypeWithDict &dataType, MappingElement &dataMapping)
RelationalPtrLoader(OraPtrReadBuffer &buffer, const std::vector< int > &fullId)
iterator find(const std::string &key)
Retrieves a sub-element.
OraPtrStreamer(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
const std::vector< std::string > & columnNames() const
void invalidate() override
DataElement & addChild(size_t declaringScopeOffset, size_toffset)
std::vector< int > m_fullId
IRelationalReader * newReader()
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
void setRecordId(const std::vector< int > &identity)
IRelationalReader * newReader(const edm::TypeWithDict &dataType, MappingElement &dataMapping)
coral::AttributeList & whereData()
std::auto_ptr< OraPtrReadBuffer > m_readBuffer
bool isValid() const override
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
IRelationalUpdater * newUpdater(const edm::TypeWithDict &dataType, MappingElement &dataMapping)
iterator end()
Returns an iterator in the end of the sequence.
void * constructObject(const edm::TypeWithDict &typ)
OraPtrWriter(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
edm::TypeWithDict m_objectType
OraPtrReader(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
MappingElement & m_mapping
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
ContainerSchema & m_schema