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

#include <CArrayStreamer.h>

Inheritance diagram for ora::CArrayReader:
ora::IRelationalReader

Public Member Functions

bool build (DataElement &offset, IRelationalData &relationalData)
 
 CArrayReader (const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
 Constructor. More...
 
void clear ()
 
void read (void *address)
 Reads a data element. More...
 
void select (int oid)
 
void setRecordId (const std::vector< int > &identity)
 
virtual ~CArrayReader ()
 
- Public Member Functions inherited from ora::IRelationalReader
virtual ~IRelationalReader ()
 

Private Attributes

std::auto_ptr< IArrayHandlerm_arrayHandler
 
std::auto_ptr< IRelationalReaderm_dataReader
 
DataElement m_localElement
 
MappingElementm_mappingElement
 
Reflex::Type m_objectType
 
DataElementm_offset
 
std::auto_ptr
< MultiRecordSelectOperation
m_query
 
std::vector< int > m_recordId
 
ContainerSchemam_schema
 

Detailed Description

Definition at line 72 of file CArrayStreamer.h.

Constructor & Destructor Documentation

ora::CArrayReader::CArrayReader ( const Reflex::Type &  objectType,
MappingElement mapping,
ContainerSchema contSchema 
)

Constructor.

Definition at line 169 of file CArrayStreamer.cc.

171  :
172  m_objectType( objectType ),
173  m_mappingElement( mapping ),
174  m_schema( contSchema ),
175  m_recordId(),
176  m_localElement( ),
177  m_offset(0 ),
178  m_query(),
179  m_arrayHandler(),
180  m_dataReader(){
181 }
DataElement * m_offset
ContainerSchema & m_schema
MappingElement & m_mappingElement
Reflex::Type m_objectType
std::auto_ptr< IArrayHandler > m_arrayHandler
std::vector< int > m_recordId
std::auto_ptr< IRelationalReader > m_dataReader
DataElement m_localElement
std::auto_ptr< MultiRecordSelectOperation > m_query
ora::CArrayReader::~CArrayReader ( )
virtual

Definition at line 183 of file CArrayStreamer.cc.

183  {
184 }

Member Function Documentation

bool ora::CArrayReader::build ( DataElement offset,
IRelationalData relationalData 
)
virtual

Implements ora::IRelationalReader.

Definition at line 186 of file CArrayStreamer.cc.

References i, ora::ArrayHandlerFactory::newArrayHandler(), ora::RelationalStreamerFactory::newReader(), evf::evtn::offset(), ora::ClassUtils::resolvedType(), AlCaHLTBitMon_QueryRunRegistry::string, and ora::throwException().

187  {
188 
190 
191  m_recordId.clear();
192  // allocate for the index...
193  m_recordId.push_back(0);
194 
195  // Check the array type
196  Reflex::Type arrayType = m_objectType.ToType();
197  Reflex::Type arrayResolvedType = ClassUtils::resolvedType(arrayType);
198  // Check the component type
199  if ( ! arrayType || !arrayResolvedType ) {
200  throwException( "Missing dictionary information for the element type of the array \"" +
201  m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"",
202  "CArrayReader::build" );
203  }
204 
205  RelationalStreamerFactory streamerFactory( m_schema );
206 
207  // first open the insert on the extra table...
208  m_query.reset(new MultiRecordSelectOperation( m_mappingElement.tableName(), m_schema.storageSchema() ));
209  m_query->addWhereId( m_mappingElement.pkColumn() );
210  std::vector<std::string> recIdCols = m_mappingElement.recordIdColumns();
211  for( size_t i=0; i<recIdCols.size(); i++ ){
212  m_query->addId( recIdCols[ i ] );
213  m_query->addOrderId( recIdCols[ i ] );
214  }
215 
216  m_offset = &offset;
217 
219 
220  std::string arrayTypeName = arrayType.Name();
221 
222  // Retrieve the relevant mapping element
223  MappingElement::iterator iMe = m_mappingElement.find( arrayTypeName );
224  if ( iMe == m_mappingElement.end() ) {
225  throwException( "Item for \"" + arrayTypeName + "\" not found in the mapping element",
226  "CArrayReader::build" );
227  }
228 
229  m_dataReader.reset( streamerFactory.newReader( arrayResolvedType, iMe->second ) );
230  m_dataReader->build( m_localElement, *m_query );
231  return true;
232 }
int i
Definition: DBlmapReader.cc:9
DataElement * m_offset
ContainerSchema & m_schema
MappingElement & m_mappingElement
Reflex::Type m_objectType
std::vector< std::string > recordIdColumns() const
static IArrayHandler * newArrayHandler(const Reflex::Type &arrayType)
std::auto_ptr< IArrayHandler > m_arrayHandler
iterator find(const std::string &key)
Retrieves a sub-element.
unsigned int offset(bool)
std::string pkColumn() const
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
coral::ISchema & storageSchema()
std::vector< int > m_recordId
iterator end()
Returns an iterator in the end of the sequence.
std::auto_ptr< IRelationalReader > m_dataReader
const std::string & tableName() const
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
DataElement m_localElement
std::auto_ptr< MultiRecordSelectOperation > m_query
void ora::CArrayReader::clear ( void  )
virtual
void ora::CArrayReader::read ( void *  address)
virtual

Reads a data element.

Implements ora::IRelationalReader.

Definition at line 254 of file CArrayStreamer.cc.

References i, AlCaHLTBitMon_QueryRunRegistry::string, and ora::throwException().

Referenced by Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), and Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

254  {
255  if(!m_offset){
256  throwException("The streamer has not been built.",
257  "CArrayReader::read");
258  }
259  void* address = m_offset->address( destinationData );
260 
261  Reflex::Type iteratorDereferenceReturnType = m_arrayHandler->iteratorReturnType();
262 
263  bool isElementFundamental = iteratorDereferenceReturnType.IsFundamental();
264 
265  std::string positionColumn = m_mappingElement.posColumn();
266 
267  size_t arraySize = m_objectType.ArrayLength();
268 
269  m_arrayHandler->clear( address );
270 
271  size_t cursorSize = m_query->selectionSize(m_recordId, m_recordId.size()-1);
272  unsigned int i=0;
273  while ( i< cursorSize ){
274 
275  m_recordId[m_recordId.size()-1] = (int)i;
276  m_query->selectRow( m_recordId );
277  coral::AttributeList& row = m_query->data();
278 
279  int arrayIndex = row[positionColumn].data< int >();
280 
281  // Create a new element for the array
282  void* objectData = 0;
283 
284  if(arrayIndex >= (int)arraySize){
285  throwException("Found more element then array size.",
286  "CArrayReader::read");
287 
288  }
289 
290  // the memory has been allocated already!
291  objectData = static_cast<char*>(address)+arrayIndex*iteratorDereferenceReturnType.SizeOf();
292 
293  if(!isElementFundamental){
294  // in this case the initialization is required: use default constructor...
295  iteratorDereferenceReturnType.Construct(Reflex::Type(0,0),std::vector< void* >(),objectData);
296  }
297 
298  m_dataReader->setRecordId( m_recordId );
299  m_dataReader->read( objectData );
300 
301  ++i;
302  }
303 
304  m_arrayHandler->finalize( address );
305 
306 }
int i
Definition: DBlmapReader.cc:9
DataElement * m_offset
char * address
Definition: mlp_lapack.h:14
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:48
MappingElement & m_mappingElement
Reflex::Type m_objectType
std::string posColumn() const
std::auto_ptr< IArrayHandler > m_arrayHandler
std::vector< int > m_recordId
std::auto_ptr< IRelationalReader > m_dataReader
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
std::auto_ptr< MultiRecordSelectOperation > m_query
void ora::CArrayReader::select ( int  oid)
virtual

Implements ora::IRelationalReader.

Definition at line 234 of file CArrayStreamer.cc.

References ora::throwException().

Referenced by Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Views.LineDecayView.LineDecayContainer::mousePressEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), and Vispa.Views.AbstractView.AbstractView::restoreSelection().

234  {
235  if(!m_query.get()){
236  throwException("The streamer has not been built.",
237  "CArrayReader::select");
238  }
239  coral::AttributeList& whereData = m_query->whereData();
240  whereData[ m_mappingElement.pkColumn() ].data<int>() = oid;
241  m_query->execute();
242  m_dataReader->select( oid );
243 }
MappingElement & m_mappingElement
std::string pkColumn() const
std::auto_ptr< IRelationalReader > m_dataReader
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
std::auto_ptr< MultiRecordSelectOperation > m_query
void ora::CArrayReader::setRecordId ( const std::vector< int > &  identity)
virtual

Implements ora::IRelationalReader.

Definition at line 245 of file CArrayStreamer.cc.

References i.

245  {
246  m_recordId.clear();
247  for(size_t i=0;i<identity.size();i++) {
248  m_recordId.push_back( identity[i] );
249  }
250  // allocate the element for the index...
251  m_recordId.push_back( 0 );
252 }
int i
Definition: DBlmapReader.cc:9
std::vector< int > m_recordId

Member Data Documentation

std::auto_ptr<IArrayHandler> ora::CArrayReader::m_arrayHandler
private

Definition at line 102 of file CArrayStreamer.h.

std::auto_ptr<IRelationalReader> ora::CArrayReader::m_dataReader
private

Definition at line 103 of file CArrayStreamer.h.

DataElement ora::CArrayReader::m_localElement
private

Definition at line 97 of file CArrayStreamer.h.

MappingElement& ora::CArrayReader::m_mappingElement
private

Definition at line 94 of file CArrayStreamer.h.

Reflex::Type ora::CArrayReader::m_objectType
private

Definition at line 93 of file CArrayStreamer.h.

DataElement* ora::CArrayReader::m_offset
private

Definition at line 100 of file CArrayStreamer.h.

std::auto_ptr<MultiRecordSelectOperation> ora::CArrayReader::m_query
private

Definition at line 101 of file CArrayStreamer.h.

std::vector<int> ora::CArrayReader::m_recordId
private

Definition at line 96 of file CArrayStreamer.h.

ContainerSchema& ora::CArrayReader::m_schema
private

Definition at line 95 of file CArrayStreamer.h.