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 140 of file OraPtrStreamer.cc.

142  :
143  m_objectType( objectType ),
144  m_mappingElement( mapping ),
145  m_schema( contSchema ),
146  m_localElement(),
147  m_dataElement( 0 ),
148  m_writer(){
149 }
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 151 of file OraPtrStreamer.cc.

151  {
152 }

Member Function Documentation

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

Implements ora::IRelationalWriter.

Definition at line 154 of file OraPtrStreamer.cc.

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

156  {
157  m_dataElement = &dataElement;
159 
160  // Check the type
161  Reflex::Type ptrType = m_objectType.TemplateArgumentAt(0);
162  Reflex::Type ptrResolvedType = ClassUtils::resolvedType(ptrType);
163  // Check the component type
164  if ( ! ptrType || !ptrResolvedType ) {
165  throwException( "Missing dictionary information for the type of the pointer \"" +
166  m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"",
167  "OraPtrWriter::build" );
168  }
169 
170  std::string ptrTypeName = ptrType.Name();
171 // Retrieve the relevant mapping element
172  MappingElement::iterator iMe = m_mappingElement.find( ptrTypeName );
173  if ( iMe == m_mappingElement.end() ) {
174  throwException( "Item for \"" + ptrTypeName + "\" not found in the mapping element",
175  "OraPtrWriter::build" );
176  }
177  RelationalStreamerFactory streamerFactory( m_schema );
178  m_writer.reset( streamerFactory.newWriter( ptrResolvedType, iMe->second ));
179  return m_writer->build( m_localElement, relationalData, operationBuffer );
180 }
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:380
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 182 of file OraPtrStreamer.cc.

182  {
183  m_writer->setRecordId( identity );
184 }
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 187 of file OraPtrStreamer.cc.

References ora::throwException().

188  {
189 
190  if(!m_dataElement){
191  throwException("The streamer has not been built.",
192  "OraPtrWriter::write");
193  }
194 
195  Reflex::Object ptrObject( m_objectType, m_dataElement->address( data ) );
196  // first load if required
197  ptrObject.Invoke("load",0);
198  // then get the data...
199  void* ptrAddress = 0;
200  ptrObject.Invoke("address",ptrAddress);
201  m_writer->write( oid, ptrAddress );
202 }
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:48
Reflex::Type m_objectType
std::auto_ptr< IRelationalWriter > m_writer
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.