11 #include "CoralBase/Attribute.h"
12 #include "Reflex/Object.h"
13 #include "Reflex/Member.h"
30 const std::vector<std::string> columns = mapping.
columnNames();
31 for( std::vector<std::string>::const_iterator iC = columns.begin();
32 iC != columns.end(); ++iC){
38 if( iMe == mapping.
end()){
40 objectType.Name(Reflex::SCOPED)+
"\"",
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()){
92 m_type.Name(Reflex::SCOPED)+
"\"",
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 );
225 Reflex::Object refObj( m_objectType, const_cast<void*>(refAddress));
228 refObj.Invoke(
"operator!",isNull);
235 std::type_info* refTypeInfo = 0;
236 refObj.Invoke(
"typeInfo",refTypeInfo);
238 className = refType.Name(Reflex::SCOPED);
241 MappingElement& depMapping = m_schema.mappingForDependentClass( refType,
true );
247 writer.
build( refType, depMapping, m_schema, m_operationBuffer->addVolatileBuffer() );
249 refObj.Invoke(
"operator*",refData);
250 writer.
write( oid, refId, refData );
254 coral::AttributeList& parentData = m_relationalData->data();
255 parentData[m_columnIndexes[0]].data<
std::string>()=className;
256 parentData[m_columnIndexes[1]].data<
int>()=refId;
262 m_writer( objectType, mapping, contSchema ){
271 return m_writer.build( dataElement, relationalData, operationBuffer );
275 m_writer.setRecordId( identity );
281 m_writer.write( oid, data );
287 m_objectType( objectType ),
288 m_mappingElement( mapping ),
289 m_schema( contSchema ),
291 m_relationalData( 0 ),
298 for(std::vector<boost::shared_ptr<RelationalRefLoader> >::const_iterator iL = m_loaders.begin();
299 iL != m_loaders.end(); ++iL ){
306 m_dataElement = &dataElement;
307 const std::vector<std::string>& columns = m_mappingElement.columnNames();
308 if( columns.size() < 2 ){
309 throwException(
"Expected column names have not been found in the mapping.",
310 "UniqueRefReader::build");
315 m_columnIndexes[1] = relationalData.
addData( columns[1],
typeid(
int) );
316 m_relationalData = &relationalData;
330 "UniqueRefReader::read");
332 coral::AttributeList& row = m_relationalData->data();
334 int refId = row[m_columnIndexes[1]].data<
int>();
339 MappingElement& depMapping = m_schema.mappingForDependentClass( refType );
342 Reflex::Member loaderMember = m_objectType.MemberByName(
"m_loader");
344 void* loaderAddress = loaderElement.
address( data );
345 boost::shared_ptr<IPtrLoader>* loaderPtr =
static_cast<boost::shared_ptr<IPtrLoader>*
>( loaderAddress );
348 newLoader->build( refType, depMapping, m_schema );
349 m_loaders.push_back( newLoader );
351 boost::shared_ptr<IPtrLoader>
tmp( newLoader );
361 m_objectType( objectType ),
362 m_mapping( mapping ),
363 m_schema( contSchema ){
IRelationalReader * newReader()
void * load() const override
UniqueRefUpdater(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
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()
DataElement & addChild(size_t declaringScopeOffset, Reflex::OffsetFunction offsetFunction)
void setRecordId(const std::vector< int > &identity)
void write(int oId, int refId, const void *data)
virtual ~UniqueRefUpdater()
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
InsertOperation & newInsert(const std::string &tableName)
DataElement m_dataElement
void read(void *destination)
Reads a data element.
virtual ~UniqueRefWriter()
UniqueRefStreamer(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
InsertOperation * m_depInsert
DataElement m_dataElement
void setRecordId(const std::vector< int > &identity)
UniqueRefWriter(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
void update(int oid, const void *data)
Updates a data element.
virtual ~RelationalRefLoader()
void invalidate() override
DependentClassReader m_reader
iterator find(const std::string &key)
Retrieves a sub-element.
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
const std::vector< std::string > & columnNames() const
bool isValid() const override
IRelationalWriter * newWriter(const Reflex::Type &dataType, MappingElement &dataMapping)
void build(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema, RelationalBuffer &operationBuffer)
UniqueRefReader(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
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
char data[epos_bytes_allocation]
std::auto_ptr< IRelationalReader > m_reader
void build(const Reflex::Type &objectType, MappingElement &depMapping, ContainerSchema &contSchema)
std::auto_ptr< SelectOperation > m_depQuery
const std::string & tableName() const
RelationalRefLoader(int refId)
static std::string sequenceNameForDependentClass(const std::string &containerName, const std::string &className)
volatile std::atomic< bool > shutdown_flag false
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
void build(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
std::string className(const T &t)
IRelationalWriter * newWriter()
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
std::string uniqueRefNullLabel()