CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ora::OraPtrWriter Class Reference

#include <OraPtrStreamer.h>

Inheritance diagram for ora::OraPtrWriter:
ora::IRelationalWriter

Public Member Functions

bool build (DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
 
 OraPtrWriter (const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
 
void setRecordId (const std::vector< int > &identity)
 
void write (int oid, const void *data)
 Writes a data element. More...
 
virtual ~OraPtrWriter ()
 
- Public Member Functions inherited from ora::IRelationalWriter
virtual ~IRelationalWriter ()
 Destructor. More...
 

Private Attributes

DataElementm_dataElement
 
DataElement m_localElement
 
MappingElementm_mappingElement
 
Reflex::Type m_objectType
 
ContainerSchemam_schema
 
std::auto_ptr< IRelationalWriterm_writer
 

Detailed Description

Definition at line 20 of file OraPtrStreamer.h.

Constructor & Destructor Documentation

ora::OraPtrWriter::OraPtrWriter ( const Reflex::Type &  objectType,
MappingElement mapping,
ContainerSchema contSchema 
)

Definition at line 141 of file OraPtrStreamer.cc.

143  :
144  m_objectType( objectType ),
145  m_mappingElement( mapping ),
146  m_schema( contSchema ),
147  m_localElement(),
148  m_dataElement( 0 ),
149  m_writer(){
150 }
Reflex::Type m_objectType
ContainerSchema & m_schema
DataElement m_localElement
std::auto_ptr< IRelationalWriter > m_writer
MappingElement & m_mappingElement
DataElement * m_dataElement
ora::OraPtrWriter::~OraPtrWriter ( )
virtual

Definition at line 152 of file OraPtrStreamer.cc.

152  {
153 }

Member Function Documentation

bool ora::OraPtrWriter::build ( DataElement dataElement,
IRelationalData relationalData,
RelationalBuffer operationBuffer 
)
virtual

Implements ora::IRelationalWriter.

Definition at line 155 of file OraPtrStreamer.cc.

References ora::DataElement::clear(), ora::RelationalStreamerFactory::newWriter(), ora::ClassUtils::resolvedType(), and ora::throwException().

157  {
158  m_dataElement = &dataElement;
160 
161  // Check the type
162  Reflex::Type ptrType = m_objectType.TemplateArgumentAt(0);
163  Reflex::Type ptrResolvedType = ClassUtils::resolvedType(ptrType);
164  // Check the component type
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" );
169  }
170 
171  std::string ptrTypeName = ptrType.Name();
172 // Retrieve the relevant mapping element
173  MappingElement::iterator iMe = m_mappingElement.find( ptrTypeName );
174  if ( iMe == m_mappingElement.end() ) {
175  throwException( "Item for \"" + ptrTypeName + "\" not found in the mapping element",
176  "OraPtrWriter::build" );
177  }
178  RelationalStreamerFactory streamerFactory( m_schema );
179  m_writer.reset( streamerFactory.newWriter( ptrResolvedType, iMe->second ));
180  return m_writer->build( m_localElement, relationalData, operationBuffer );
181 }
Reflex::Type m_objectType
ContainerSchema & m_schema
iterator find(const std::string &key)
Retrieves a sub-element.
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
DataElement m_localElement
std::auto_ptr< IRelationalWriter > m_writer
iterator end()
Returns an iterator in the end of the sequence.
MappingElement & m_mappingElement
DataElement * m_dataElement
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
void ora::OraPtrWriter::setRecordId ( const std::vector< int > &  identity)
virtual

Implements ora::IRelationalWriter.

Definition at line 183 of file OraPtrStreamer.cc.

183  {
184  m_writer->setRecordId( identity );
185 }
std::auto_ptr< IRelationalWriter > m_writer
void ora::OraPtrWriter::write ( int  oid,
const void *  data 
)
virtual

Writes a data element.

Implements ora::IRelationalWriter.

Definition at line 188 of file OraPtrStreamer.cc.

References ora::throwException().

189  {
190 
191  if(!m_dataElement){
192  throwException("The streamer has not been built.",
193  "OraPtrWriter::write");
194  }
195 
196  Reflex::Object ptrObject( m_objectType, m_dataElement->address( data ) );
197  // first load if required
198  ptrObject.Invoke("load",0);
199  // then get the data...
200  void* ptrAddress = 0;
201  ptrObject.Invoke("address",ptrAddress);
202  m_writer->write( oid, ptrAddress );
203 }
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:48
Reflex::Type m_objectType
std::auto_ptr< IRelationalWriter > m_writer
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
DataElement * m_dataElement
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10

Member Data Documentation

DataElement* ora::OraPtrWriter::m_dataElement
private

Definition at line 41 of file OraPtrStreamer.h.

DataElement ora::OraPtrWriter::m_localElement
private

Definition at line 40 of file OraPtrStreamer.h.

MappingElement& ora::OraPtrWriter::m_mappingElement
private

Definition at line 38 of file OraPtrStreamer.h.

Reflex::Type ora::OraPtrWriter::m_objectType
private

Definition at line 37 of file OraPtrStreamer.h.

ContainerSchema& ora::OraPtrWriter::m_schema
private

Definition at line 39 of file OraPtrStreamer.h.

std::auto_ptr<IRelationalWriter> ora::OraPtrWriter::m_writer
private

Definition at line 42 of file OraPtrStreamer.h.