CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::PrimitiveStreamerBase Class Reference

#include <PrimitiveStreamer.h>

Inheritance diagram for ora::PrimitiveStreamerBase:
ora::PrimitiveReader ora::PrimitiveUpdater ora::PrimitiveWriter

List of all members.

Public Member Functions

void bindDataForRead (void *data)
void bindDataForUpdate (const void *data)
bool buildDataElement (DataElement &dataElement, IRelationalData &relationalData)
 PrimitiveStreamerBase (const Reflex::Type &objectType, MappingElement &mapping)
virtual ~PrimitiveStreamerBase ()

Private Attributes

int m_columnIndex
DataElementm_dataElement
MappingElementm_mapping
Reflex::Type m_objectType
IRelationalDatam_relationalData

Detailed Description

Definition at line 13 of file PrimitiveStreamer.h.


Constructor & Destructor Documentation

ora::PrimitiveStreamerBase::PrimitiveStreamerBase ( const Reflex::Type &  objectType,
MappingElement mapping 
)

Definition at line 11 of file PrimitiveStreamer.cc.

                                                                            :
  m_objectType( objectType ),
  m_mapping(mapping),
  m_columnIndex(-1),
  m_dataElement( 0 ),
  m_relationalData( 0 ){  
}
ora::PrimitiveStreamerBase::~PrimitiveStreamerBase ( ) [virtual]

Definition at line 20 of file PrimitiveStreamer.cc.

                                                {
}

Member Function Documentation

void ora::PrimitiveStreamerBase::bindDataForRead ( void *  data)

Definition at line 56 of file PrimitiveStreamer.cc.

References ora::throwException().

                                                          {
  if( ! m_dataElement ){
    throwException( "The streamer has not been built.",
                    "PrimitiveStreamerBase::bindDataForRead");
  }
  void* dataElementAddress = m_dataElement->address( data );
  coral::Attribute& relDataElement = m_relationalData->data()[ m_columnIndex ];
  relDataElement.copyValueToAddress( dataElementAddress );
}
void ora::PrimitiveStreamerBase::bindDataForUpdate ( const void *  data)

Definition at line 40 of file PrimitiveStreamer.cc.

References ora::throwException().

                                                                  {
  if( ! m_dataElement ){
    throwException( "The streamer has not been built.",
                    "PrimitiveStreamerBase::bindDataForUpdate");
  }
  void* dataElementAddress = m_dataElement->address( data );
  coral::Attribute& relDataElement = m_relationalData->data()[ m_columnIndex ];
  relDataElement.setValueFromAddress( dataElementAddress );
  if(!relDataElement.isValidData()){
    throwException("Data provided for column \""+
                   relDataElement.specification().name()+
                   "\" is not valid for RDBMS storage.",
                   "PrimitiveStreamerBase::bindDataForUpdate");
  }  
}
bool ora::PrimitiveStreamerBase::buildDataElement ( DataElement dataElement,
IRelationalData relationalData 
)

Definition at line 23 of file PrimitiveStreamer.cc.

References ora::IRelationalData::addData(), ora::ClassUtils::isTypeString(), and ora::throwException().

                                                                                  {
  if( m_mapping.columnNames().size()==0 ){
    throwException( "The mapping element does not contain columns.",
                    "PrimitiveStreamerBase::buildDataElement");
  }

  const std::type_info* attrType = &m_objectType.TypeInfo();
  if(m_objectType.IsEnum()) attrType = &typeid(int);
  if(ClassUtils::isTypeString( m_objectType )) attrType = &typeid(std::string);
  std::string columnName = m_mapping.columnNames()[0];
  m_columnIndex = relationalData.addData( columnName, *attrType );
  m_dataElement = &dataElement;
  m_relationalData = &relationalData;
  return true;
}

Member Data Documentation

Definition at line 31 of file PrimitiveStreamer.h.

Definition at line 32 of file PrimitiveStreamer.h.

Definition at line 30 of file PrimitiveStreamer.h.

Definition at line 29 of file PrimitiveStreamer.h.

Definition at line 33 of file PrimitiveStreamer.h.