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

#include <DatabaseContainer.h>

Public Member Functions

void * getItem ()
 
void * getItemAsType (const Reflex::Type &type)
 
int itemId ()
 
 IteratorBuffer (ContainerSchema &schema, ReadBuffer &buffer)
 
bool next ()
 
void reset ()
 
const Reflex::Type & type ()
 
 ~IteratorBuffer ()
 

Private Attributes

int m_itemId
 
SelectOperation m_query
 
ReadBufferm_readBuffer
 

Detailed Description

Definition at line 26 of file DatabaseContainer.h.

Constructor & Destructor Documentation

ora::IteratorBuffer::IteratorBuffer ( ContainerSchema schema,
ReadBuffer buffer 
)

Definition at line 253 of file DatabaseContainer.cc.

References ora::SelectOperation::addId(), ora::SelectOperation::addOrderId(), ora::MappingElement::columnNames(), m_query, ora::ContainerSchema::mapping(), and ora::MappingTree::topElement().

254  :
255  m_query( schema.mapping().topElement().tableName(), schema.storageSchema() ),
256  m_itemId( -1 ),
257  m_readBuffer( buffer ){
258  const std::string& idCol = schema.mapping().topElement().columnNames()[0];
259  m_query.addId( idCol );
260  m_query.addOrderId( idCol );
261 }
void addId(const std::string &columnName)
SelectOperation m_query
void addOrderId(const std::string &columnName)
ReadBuffer & m_readBuffer
ora::IteratorBuffer::~IteratorBuffer ( )

Definition at line 263 of file DatabaseContainer.cc.

263  {
264 }

Member Function Documentation

void * ora::IteratorBuffer::getItem ( )

Definition at line 284 of file DatabaseContainer.cc.

References runTheMatrix::ret.

Referenced by ora::DatabaseUtilitySession::importContainer().

284  {
285  void* ret = 0;
286  if( m_itemId != -1 ){
287  ret = m_readBuffer.read( m_itemId );
288  }
289  return ret;
290 }
void * read(int oid)
ReadBuffer & m_readBuffer
void * ora::IteratorBuffer::getItemAsType ( const Reflex::Type &  type)

Definition at line 292 of file DatabaseContainer.cc.

References ora::ClassUtils::isType(), and ora::throwException().

292  {
293  if( !ClassUtils::isType( type(), asType ) ){
294  throwException("Provided output object type \""+asType.Name(Reflex::SCOPED)+"\" does not match with the container type \""+
295  type().Name(Reflex::SCOPED)+"\"","IteratorBuffer::getItemAsType");
296  }
297  return getItem();
298 }
const Reflex::Type & type()
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
bool isType(const Reflex::Type &type, const Reflex::Type &baseType)
Definition: ClassUtils.cc:49
int ora::IteratorBuffer::itemId ( )

Definition at line 300 of file DatabaseContainer.cc.

300  {
301  return m_itemId;
302 }
bool ora::IteratorBuffer::next ( void  )

Definition at line 270 of file DatabaseContainer.cc.

Referenced by ora::DatabaseUtilitySession::importContainer().

270  {
271  bool prevValid = (m_itemId != -1);
272  bool currValid = false;
273  m_itemId = -1;
274  if( m_query.nextCursorRow() ){
275  coral::AttributeList& row = m_query.data();
276  m_itemId = row.begin()->data<int>();
277  currValid = true;
278  }
279 
280  if( !currValid && prevValid ) m_query.clear();
281  return currValid;
282 }
SelectOperation m_query
coral::AttributeList & data()
void ora::IteratorBuffer::reset ( void  )
const Reflex::Type & ora::IteratorBuffer::type ( )

Member Data Documentation

int ora::IteratorBuffer::m_itemId
private

Definition at line 46 of file DatabaseContainer.h.

SelectOperation ora::IteratorBuffer::m_query
private

Definition at line 45 of file DatabaseContainer.h.

Referenced by IteratorBuffer().

ReadBuffer& ora::IteratorBuffer::m_readBuffer
private

Definition at line 47 of file DatabaseContainer.h.