CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::ReadBuffer Class Reference

List of all members.

Public Member Functions

void * read (int oid)
 ReadBuffer (ContainerSchema &contSchema)
const Reflex::Type & type ()
 ~ReadBuffer ()

Private Attributes

std::auto_ptr< IRelationalReaderm_reader
DataElement m_topLevelElement
SelectOperation m_topLevelQuery
const Reflex::Type & m_type

Detailed Description

Definition at line 155 of file DatabaseContainer.cc.


Constructor & Destructor Documentation

ora::ReadBuffer::ReadBuffer ( ContainerSchema contSchema) [inline, explicit]

Definition at line 157 of file DatabaseContainer.cc.

References ora::SelectOperation::addWhereId(), ora::MappingElement::columnNames(), ora::MappingElement::end(), ora::MappingElement::find(), m_reader, m_topLevelElement, m_topLevelQuery, m_type, ora::ContainerSchema::mapping(), ora::RelationalStreamerFactory::newReader(), ora::throwException(), and ora::MappingTree::topElement().

                                                        :
        m_topLevelElement(),
        m_type( contSchema.type() ),
        m_reader(),
        m_topLevelQuery( contSchema.mapping().topElement().tableName(), contSchema.storageSchema() ){

        MappingElement& topLevelMapping = contSchema.mapping().topElement();
        m_topLevelQuery.addWhereId(  topLevelMapping.columnNames()[ 0 ] );
        MappingElement::iterator iMap = topLevelMapping.find( m_type.Name(Reflex::SCOPED) );
        // the first inner mapping is the good one ...
        if( iMap == topLevelMapping.end()){
          throwException("Could not find a mapping element for class \""+
                         m_type.Name(Reflex::SCOPED)+"\"",
                         "ReadBuffer::ReadBuffer");
        }
        MappingElement& mapping = iMap->second;
        RelationalStreamerFactory streamerFactory( contSchema );
        m_reader.reset( streamerFactory.newReader( m_type, mapping )) ;
        m_reader->build( m_topLevelElement , m_topLevelQuery );
      }
ora::ReadBuffer::~ReadBuffer ( ) [inline]

Definition at line 178 of file DatabaseContainer.cc.

                   {
      }

Member Function Documentation

void* ora::ReadBuffer::read ( int  oid) [inline]

Definition at line 181 of file DatabaseContainer.cc.

References ora::SelectOperation::clear(), ora::ClassUtils::constructObject(), ora::SelectOperation::execute(), m_reader, m_topLevelQuery, m_type, ora::SelectOperation::nextCursorRow(), and ora::SelectOperation::whereData().

                           {
        coral::AttributeList& dataBuff = m_topLevelQuery.whereData();
        dataBuff.begin()->data<int>() = oid;
        m_topLevelQuery.execute();
        m_reader->select( oid );
        void* destination = 0;
        if( m_topLevelQuery.nextCursorRow() ){
          destination = ClassUtils::constructObject( m_type );
          m_reader->read( destination );
        }
        m_reader->clear();
        m_topLevelQuery.clear();
        return destination;
      }
const Reflex::Type& ora::ReadBuffer::type ( ) [inline]

Definition at line 196 of file DatabaseContainer.cc.

References m_type.

                              {
        return m_type;
      }

Member Data Documentation

std::auto_ptr<IRelationalReader> ora::ReadBuffer::m_reader [private]

Definition at line 203 of file DatabaseContainer.cc.

Referenced by read(), and ReadBuffer().

Definition at line 201 of file DatabaseContainer.cc.

Referenced by ReadBuffer().

Definition at line 204 of file DatabaseContainer.cc.

Referenced by read(), and ReadBuffer().

const Reflex::Type& ora::ReadBuffer::m_type [private]

Definition at line 202 of file DatabaseContainer.cc.

Referenced by read(), ReadBuffer(), and type().