10 #include "CoralBase/Attribute.h"
11 #include "Reflex/Object.h"
12 #include "Reflex/Member.h"
22 m_query( mapping.tableName(), contSchema.storageSchema() ),
35 size_t cols = columns.size();
36 for(
size_t i=0;
i<cols;
i++ ){
44 if ( ! ptrType || !ptrResolvedType ) {
45 throwException(
"Missing dictionary information for the type of the pointer \"" +
47 "OraPtrReadBuffer::build" );
50 std::string ptrTypeName = ptrType.Name();
54 throwException(
"Item for \"" + ptrTypeName +
"\" not found in the mapping element",
55 "OraPtrReadBuffer::build" );
62 void*
read(
const std::vector<int>& fullId ){
65 if(!fullId.size())
throwException(
"Object id set is empty.",
"OraPtrReadBuffer::read");
68 coral::AttributeList::iterator iCol = whereBuff.begin();
70 for( coral::AttributeList::iterator iCol = whereBuff.begin(); iCol != whereBuff.end(); ++iCol ){
71 if( i<fullId.size() ){
72 iCol->data<
int>() = fullId[i];
77 std::vector<int> recordId( fullId.size()-1 );
78 for(
size_t i=0; i<fullId.size()-1; i++ ){
79 recordId[
i] = fullId[i+1];
85 void* destination = 0;
121 "RelationalPtrLoader::load");
144 m_objectType( objectType ),
145 m_mappingElement( mapping ),
146 m_schema( contSchema ),
158 m_dataElement = &dataElement;
159 m_localElement.
clear();
162 Reflex::Type ptrType = m_objectType.TemplateArgumentAt(0);
165 if ( ! ptrType || !ptrResolvedType ) {
166 throwException(
"Missing dictionary information for the type of the pointer \"" +
167 m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) +
"\"",
168 "OraPtrWriter::build" );
171 std::string ptrTypeName = ptrType.Name();
174 if ( iMe == m_mappingElement.end() ) {
175 throwException(
"Item for \"" + ptrTypeName +
"\" not found in the mapping element",
176 "OraPtrWriter::build" );
179 m_writer.reset( streamerFactory.
newWriter( ptrResolvedType, iMe->second ));
180 return m_writer->build( m_localElement, relationalData, operationBuffer );
184 m_writer->setRecordId( identity );
193 "OraPtrWriter::write");
196 Reflex::Object ptrObject( m_objectType, m_dataElement->address( data ) );
198 ptrObject.Invoke(
"load",0);
200 void* ptrAddress = 0;
201 ptrObject.Invoke(
"address",ptrAddress);
202 m_writer->write( oid, ptrAddress );
208 m_objectType( objectType ),
209 m_mappingElement( mapping ),
210 m_schema( contSchema ),
222 m_dataElement = &dataElement;
223 m_localElement.
clear();
226 Reflex::Type ptrType = m_objectType.TemplateArgumentAt(0);
229 if ( ! ptrType || !ptrResolvedType ) {
230 throwException(
"Missing dictionary information for the type of the pointer \"" +
231 m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) +
"\"",
232 "OraPtrUpdater::build" );
235 std::string ptrTypeName = ptrType.Name();
238 if ( iMe == m_mappingElement.end() ) {
239 throwException(
"Item for \"" + ptrTypeName +
"\" not found in the mapping element",
240 "OraPtrUpdater::build" );
243 m_updater.reset( streamerFactory.
newUpdater( ptrResolvedType, iMe->second ) );
244 return m_updater->build( m_localElement, relationalData, operationBuffer );
248 m_updater->setRecordId( identity );
256 "OraPtrUpdater::update");
258 Reflex::Object ptrObject( m_objectType, m_dataElement->address( data ) );
260 ptrObject.Invoke(
"load",0);
261 void* ptrAddress = 0;
262 ptrObject.Invoke(
"address",ptrAddress);
263 m_updater->update( oid, ptrAddress );
269 m_objectType( objectType ),
278 for(std::vector<boost::shared_ptr<IPtrLoader> >::const_iterator iL = m_loaders.begin();
279 iL != m_loaders.end(); ++iL ){
286 m_dataElement = &dataElement;
288 m_tmpIds.push_back(0);
289 return m_readBuffer->build( dataElement );
293 if(!m_dataElement)
throwException(
"The streamer has not been built.",
"OraPtrReader::select");
298 m_tmpIds.resize( 1+identity.size() );
299 for(
size_t i=0;
i<identity.size();
i++){
300 m_tmpIds[1+
i] = identity[
i];
308 "OraPtrReader::read");
311 Reflex::Member loaderMember = m_objectType.MemberByName(
"m_loader");
313 void* loaderAddress = loaderElement.
address( data );
314 boost::shared_ptr<IPtrLoader>* loaderPtr =
static_cast<boost::shared_ptr<IPtrLoader>*
>( loaderAddress );
316 boost::shared_ptr<IPtrLoader> newLoader(
new RelationalPtrLoader( *m_readBuffer, m_tmpIds ) );
317 m_loaders.push_back( newLoader );
319 *loaderPtr = newLoader;
329 m_objectType( objectType ),
330 m_mapping( mapping ),
331 m_schema( contSchema ){
338 return new OraPtrWriter( m_objectType, m_mapping, m_schema );
342 return new OraPtrUpdater( m_objectType, m_mapping, m_schema );
346 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)
OraPtrWriter(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
OraPtrReadBuffer(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
IRelationalReader * newReader(const Reflex::Type &dataType, MappingElement &dataMapping)
void * constructObject(const Reflex::Type &typ)
void * address(const void *topLevelAddress) const
DataElement * m_dataElement
void * read(const std::vector< int > &fullId)
OraPtrReader(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
virtual ~RelationalPtrLoader()
IRelationalUpdater * newUpdater()
void write(int oid, const void *data)
Writes a data element.
DataElement & addChild(size_t declaringScopeOffset, Reflex::OffsetFunction offsetFunction)
OraPtrStreamer(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
std::auto_ptr< IRelationalReader > m_reader
int addWhereId(const std::string &columnName)
bool build(DataElement &dataElement)
OraPtrReadBuffer & m_buffer
DataElement m_localElement
bool build(DataElement &offset, IRelationalData &relationalData)
void setRecordId(const std::vector< int > &identity)
void read(void *destination)
Reads a data element.
IRelationalWriter * newWriter()
RelationalPtrLoader(OraPtrReadBuffer &buffer, const std::vector< int > &fullId)
iterator find(const std::string &key)
Retrieves a sub-element.
Reflex::Type m_objectType
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
const std::vector< std::string > & columnNames() const
std::vector< int > m_fullId
IRelationalReader * newReader()
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
Reflex::Type resolvedType(const Reflex::Type &typ)
void setRecordId(const std::vector< int > &identity)
OraPtrUpdater(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
IRelationalWriter * newWriter(const Reflex::Type &dataType, MappingElement &dataMapping)
coral::AttributeList & whereData()
IRelationalUpdater * newUpdater(const Reflex::Type &dataType, MappingElement &dataMapping)
std::auto_ptr< OraPtrReadBuffer > m_readBuffer
iterator end()
Returns an iterator in the end of the sequence.
char data[epos_bytes_allocation]
MappingElement & m_mapping
void throwException(const std::string &message, const std::string &methodName)
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
ContainerSchema & m_schema