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

#include <RelationalOperation.h>

Inheritance diagram for ora::SelectOperation:
ora::IRelationalData

Public Member Functions

void addBlobData (const std::string &columnName)
 
void addData (const std::string &columnName, const std::type_info &columnType)
 
void addId (const std::string &columnName)
 
void addOrderId (const std::string &columnName)
 
void addWhereId (const std::string &columnName)
 
coral::AttributeListSpecification & attributeListSpecification ()
 
void clear ()
 
coral::AttributeList & data ()
 
void execute ()
 
bool nextCursorRow ()
 
 SelectOperation (const std::string &tableName, coral::ISchema &schema)
 
std::string & whereClause ()
 
coral::AttributeList & whereData ()
 
 ~SelectOperation ()
 
- Public Member Functions inherited from ora::IRelationalData
virtual ~IRelationalData ()
 

Private Attributes

coral::ICursor * m_cursor
 
std::vector< std::string > m_orderByCols
 
std::auto_ptr< coral::IQuery > m_query
 
coral::ISchema & m_schema
 
coral::AttributeListSpecification * m_spec
 
std::string m_tableName
 
std::string m_whereClause
 
coral::AttributeList m_whereData
 

Detailed Description

Definition at line 159 of file RelationalOperation.h.

Constructor & Destructor Documentation

ora::SelectOperation::SelectOperation ( const std::string &  tableName,
coral::ISchema &  schema 
)
explicit

Definition at line 224 of file RelationalOperation.cc.

225  :
226  m_spec( new coral::AttributeListSpecification ),
227  m_whereData(),
228  m_whereClause(""),
229  m_orderByCols(),
230  m_query(),
231  m_cursor( 0 ),
232  m_tableName( tableName ),
233  m_schema( schema ){
234 }
std::auto_ptr< coral::IQuery > m_query
coral::AttributeListSpecification * m_spec
coral::ISchema & m_schema
coral::ICursor * m_cursor
coral::AttributeList m_whereData
std::vector< std::string > m_orderByCols
ora::SelectOperation::~SelectOperation ( )

Definition at line 236 of file RelationalOperation.cc.

236  {
237  m_spec->release();
238 }
coral::AttributeListSpecification * m_spec

Member Function Documentation

void ora::SelectOperation::addBlobData ( const std::string &  columnName)
virtual

Implements ora::IRelationalData.

Definition at line 271 of file RelationalOperation.cc.

271  {
272  if(m_spec->index( columnName )==-1){
273  m_spec->extend<coral::Blob>( columnName );
274  }
275 }
coral::AttributeListSpecification * m_spec
void ora::SelectOperation::addData ( const std::string &  columnName,
const std::type_info &  columnType 
)
virtual

Implements ora::IRelationalData.

Definition at line 264 of file RelationalOperation.cc.

265  {
266  if(m_spec->index( columnName )==-1){
267  m_spec->extend( columnName, columnType );
268  }
269 }
coral::AttributeListSpecification * m_spec
void ora::SelectOperation::addId ( const std::string &  columnName)
virtual

Implements ora::IRelationalData.

Definition at line 258 of file RelationalOperation.cc.

Referenced by ora::IteratorBuffer::IteratorBuffer().

258  {
259  if(m_spec->index( columnName )==-1){
260  m_spec->extend< int >( columnName );
261  }
262 }
coral::AttributeListSpecification * m_spec
void ora::SelectOperation::addOrderId ( const std::string &  columnName)

Definition at line 240 of file RelationalOperation.cc.

Referenced by ora::IteratorBuffer::IteratorBuffer().

240  {
241  m_orderByCols.push_back( columnName );
242 }
std::vector< std::string > m_orderByCols
void ora::SelectOperation::addWhereId ( const std::string &  columnName)
virtual

Implements ora::IRelationalData.

Definition at line 277 of file RelationalOperation.cc.

References ora::existAttribute().

Referenced by ora::OraPtrReadBuffer::build(), and ora::ReadBuffer::ReadBuffer().

277  {
278  if(!existAttribute( columnName, m_whereData )){
279  m_whereData.extend<int>( columnName );
280  if(!m_whereClause.empty()) m_whereClause += " AND ";
281  m_whereClause += ( columnName +"= :"+columnName );
282  }
283 }
coral::AttributeList m_whereData
bool existAttribute(const std::string &attributeName, const coral::AttributeList &data)
coral::AttributeListSpecification & ora::SelectOperation::attributeListSpecification ( )

Definition at line 317 of file RelationalOperation.cc.

317  {
318  return *m_spec;
319 }
coral::AttributeListSpecification * m_spec
void ora::SelectOperation::clear ( void  )
coral::AttributeList & ora::SelectOperation::data ( )
virtual

Implements ora::IRelationalData.

Definition at line 285 of file RelationalOperation.cc.

References ora::throwException().

285  {
286  if(!m_cursor) throwException( "Query on table "+m_tableName+" has not been executed.",
287  "ora::ReadOperation::data" );
288  return const_cast<coral::AttributeList&>(m_cursor->currentRow());
289 }
coral::ICursor * m_cursor
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
void ora::SelectOperation::execute ( )

Definition at line 299 of file RelationalOperation.cc.

References asciidump::table.

Referenced by ora::OraPtrReadBuffer::read(), and ora::ReadBuffer::read().

299  {
300  m_cursor = 0;
301  coral::ITable& table = m_schema.tableHandle( m_tableName );
302  m_query.reset( table.newQuery() );
303  for ( coral::AttributeListSpecification::const_iterator iSpec = m_spec->begin();
304  iSpec != m_spec->end(); ++iSpec ) {
305  m_query->addToOutputList( iSpec->name() );
306  m_query->defineOutputType( iSpec->name(),iSpec->typeName());
307  }
308  for(std::vector<std::string>::iterator iCol = m_orderByCols.begin();
309  iCol != m_orderByCols.end(); iCol++ ){
310  m_query->addToOrderList( *iCol );
311  }
312  m_query->setCondition( m_whereClause, m_whereData );
313  m_query->setRowCacheSize( 100 ); // We should better define this value !!!
314  m_cursor = &m_query->execute();
315 }
list table
Definition: asciidump.py:386
std::auto_ptr< coral::IQuery > m_query
coral::AttributeListSpecification * m_spec
coral::ISchema & m_schema
coral::ICursor * m_cursor
coral::AttributeList m_whereData
std::vector< std::string > m_orderByCols
bool ora::SelectOperation::nextCursorRow ( )

Definition at line 244 of file RelationalOperation.cc.

References runTheMatrix::ret.

Referenced by ora::OraPtrReadBuffer::read(), and ora::ReadBuffer::read().

244  {
245  bool ret = false;
246  if( m_query.get() ){
247  ret = m_cursor->next();
248  if(!ret) clear();
249  }
250  return ret;
251 }
std::auto_ptr< coral::IQuery > m_query
coral::ICursor * m_cursor
std::string & ora::SelectOperation::whereClause ( )
virtual

Implements ora::IRelationalData.

Definition at line 295 of file RelationalOperation.cc.

295  {
296  return m_whereClause;
297 }
coral::AttributeList & ora::SelectOperation::whereData ( )
virtual

Implements ora::IRelationalData.

Definition at line 291 of file RelationalOperation.cc.

Referenced by ora::OraPtrReadBuffer::read(), and ora::ReadBuffer::read().

291  {
292  return m_whereData;
293 }
coral::AttributeList m_whereData

Member Data Documentation

coral::ICursor* ora::SelectOperation::m_cursor
private

Definition at line 190 of file RelationalOperation.h.

std::vector<std::string> ora::SelectOperation::m_orderByCols
private

Definition at line 188 of file RelationalOperation.h.

std::auto_ptr<coral::IQuery> ora::SelectOperation::m_query
private

Definition at line 189 of file RelationalOperation.h.

coral::ISchema& ora::SelectOperation::m_schema
private

Definition at line 192 of file RelationalOperation.h.

coral::AttributeListSpecification* ora::SelectOperation::m_spec
private

Definition at line 185 of file RelationalOperation.h.

std::string ora::SelectOperation::m_tableName
private

Definition at line 191 of file RelationalOperation.h.

std::string ora::SelectOperation::m_whereClause
private

Definition at line 187 of file RelationalOperation.h.

coral::AttributeList ora::SelectOperation::m_whereData
private

Definition at line 186 of file RelationalOperation.h.