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::PrimitiveStreamerBase Class Reference

#include <PrimitiveStreamer.h>

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

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

std::string m_columnName
 
DataElementm_dataElement
 
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.

References ora::MappingElement::columnNames(), and m_columnName.

12  :
13  m_objectType( objectType ),
14  m_columnName(""),
15  m_dataElement( 0 ),
16  m_relationalData( 0 ){
17 
18  if( mapping.columnNames().size() ){
19  m_columnName = mapping.columnNames()[0];
20  }
21 }
IRelationalData * m_relationalData
ora::PrimitiveStreamerBase::~PrimitiveStreamerBase ( )
virtual

Definition at line 23 of file PrimitiveStreamer.cc.

23  {
24 }

Member Function Documentation

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

Definition at line 59 of file PrimitiveStreamer.cc.

References ora::throwException().

59  {
60  if( ! m_dataElement ){
61  throwException( "The streamer has not been built.",
62  "PrimitiveStreamerBase::bindDataForRead");
63  }
64  void* dataElementAddress = m_dataElement->address( data );
65  coral::Attribute& relDataElement = m_relationalData->data()[ m_columnName ];
66  relDataElement.copyValueToAddress( dataElementAddress );
67 }
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:48
IRelationalData * m_relationalData
virtual coral::AttributeList & data()=0
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
void ora::PrimitiveStreamerBase::bindDataForUpdate ( const void *  data)

Definition at line 43 of file PrimitiveStreamer.cc.

References ora::throwException().

43  {
44  if( ! m_dataElement ){
45  throwException( "The streamer has not been built.",
46  "PrimitiveStreamerBase::bindDataForUpdate");
47  }
48  void* dataElementAddress = m_dataElement->address( data );
49  coral::Attribute& relDataElement = m_relationalData->data()[ m_columnName ];
50  relDataElement.setValueFromAddress( dataElementAddress );
51  if(!relDataElement.isValidData()){
52  throwException("Data provided for column \""+
53  relDataElement.specification().name()+
54  "\" is not valid for RDBMS storage.",
55  "PrimitiveStreamerBase::bindDataForUpdate");
56  }
57 }
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:48
IRelationalData * m_relationalData
virtual coral::AttributeList & data()=0
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
bool ora::PrimitiveStreamerBase::buildDataElement ( DataElement dataElement,
IRelationalData relationalData 
)

Definition at line 26 of file PrimitiveStreamer.cc.

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

27  {
28 
29  if( m_columnName.empty() ){
30  throwException( "Column name not found ",
31  "PrimitiveStreamerBase::buildDataElement");
32  }
33 
34  m_dataElement = &dataElement;
35  const std::type_info* attrType = &m_objectType.TypeInfo();
36  if(m_objectType.IsEnum()) attrType = &typeid(int);
37  if(ClassUtils::isTypeString( m_objectType )) attrType = &typeid(std::string);
38  relationalData.addData( m_columnName, *attrType );
39  m_relationalData = &relationalData;
40  return true;
41 }
bool isTypeString(const Reflex::Type &typ)
Definition: ClassUtils.cc:128
IRelationalData * m_relationalData
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10

Member Data Documentation

std::string ora::PrimitiveStreamerBase::m_columnName
private

Definition at line 30 of file PrimitiveStreamer.h.

Referenced by PrimitiveStreamerBase().

DataElement* ora::PrimitiveStreamerBase::m_dataElement
private

Definition at line 31 of file PrimitiveStreamer.h.

Reflex::Type ora::PrimitiveStreamerBase::m_objectType
private

Definition at line 29 of file PrimitiveStreamer.h.

IRelationalData* ora::PrimitiveStreamerBase::m_relationalData
private

Definition at line 32 of file PrimitiveStreamer.h.