CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::OraPtrWriter Class Reference

#include <OraPtrStreamer.h>

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

List of all members.

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.
virtual ~OraPtrWriter ()

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.

                                                              :
  m_objectType( objectType ),
  m_mappingElement( mapping ),
  m_schema( contSchema ),
  m_localElement(),
  m_dataElement( 0 ),
  m_writer(){
}
ora::OraPtrWriter::~OraPtrWriter ( ) [virtual]

Definition at line 151 of file OraPtrStreamer.cc.

                              {
}

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().

                                                                {
  m_dataElement = &dataElement;
  m_localElement.clear();
  
  // Check the  type
  Reflex::Type ptrType = m_objectType.TemplateArgumentAt(0);
  Reflex::Type ptrResolvedType = ClassUtils::resolvedType(ptrType);
  // Check the component type
  if ( ! ptrType || !ptrResolvedType ) {
    throwException( "Missing dictionary information for the type of the pointer \"" +
                    m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"",
                    "OraPtrWriter::build" );
  }

  std::string ptrTypeName = ptrType.Name();
// Retrieve the relevant mapping element
  MappingElement::iterator iMe = m_mappingElement.find( ptrTypeName );
  if ( iMe == m_mappingElement.end() ) {
    throwException( "Item for \"" + ptrTypeName + "\" not found in the mapping element",
                    "OraPtrWriter::build" );
  }
  RelationalStreamerFactory streamerFactory( m_schema );
  m_writer.reset( streamerFactory.newWriter( ptrResolvedType, iMe->second ));
  return m_writer->build( m_localElement, relationalData, operationBuffer );
}
void ora::OraPtrWriter::setRecordId ( const std::vector< int > &  identity) [virtual]

Implements ora::IRelationalWriter.

Definition at line 182 of file OraPtrStreamer.cc.

                                                                 {
  m_writer->setRecordId( identity );
}
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().

                                                 {

  if(!m_dataElement){
    throwException("The streamer has not been built.",
                   "OraPtrWriter::write");    
  }
  
  Reflex::Object ptrObject( m_objectType, m_dataElement->address( data ) );
  // first load if required
  ptrObject.Invoke("load",0);
  // then get the data...
  void* ptrAddress = 0;
  ptrObject.Invoke("address",ptrAddress);
  m_writer->write( oid, ptrAddress );
}

Member Data Documentation

Definition at line 41 of file OraPtrStreamer.h.

Definition at line 40 of file OraPtrStreamer.h.

Definition at line 38 of file OraPtrStreamer.h.

Reflex::Type ora::OraPtrWriter::m_objectType [private]

Definition at line 37 of file OraPtrStreamer.h.

Definition at line 39 of file OraPtrStreamer.h.

Definition at line 42 of file OraPtrStreamer.h.