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 170 of file CArrayStreamer.cc.

172  :
173  m_objectType( objectType ),
174  m_mappingElement( mapping ),
175  m_schema( contSchema ),
176  m_recordId(),
177  m_localElement( ),
178  m_offset(0 ),
179  m_query(),
180  m_arrayHandler(),
181  m_dataReader(){
182 }
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 184 of file CArrayStreamer.cc.

184  {
185 }

Member Function Documentation

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

Implements ora::IRelationalReader.

Definition at line 187 of file CArrayStreamer.cc.

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

188  {
189 
191 
192  m_recordId.clear();
193  // allocate for the index...
194  m_recordId.push_back(0);
195 
196  // Check the array type
197  Reflex::Type arrayType = m_objectType.ToType();
198  Reflex::Type arrayResolvedType = ClassUtils::resolvedType(arrayType);
199  // Check the component type
200  if ( ! arrayType || !arrayResolvedType ) {
201  throwException( "Missing dictionary information for the element type of the array \"" +
202  m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"",
203  "CArrayReader::build" );
204  }
205 
206  RelationalStreamerFactory streamerFactory( m_schema );
207 
208  // first open the insert on the extra table...
209  m_query.reset(new MultiRecordSelectOperation( m_mappingElement.tableName(), m_schema.storageSchema() ));
210  m_query->addWhereId( m_mappingElement.pkColumn() );
211  std::vector<std::string> recIdCols = m_mappingElement.recordIdColumns();
212  for( size_t i=0; i<recIdCols.size(); i++ ){
213  m_query->addId( recIdCols[ i ] );
214  m_query->addOrderId( recIdCols[ i ] );
215  }
216 
217  m_offset = &offset;
218 
220 
221  std::string arrayTypeName = arrayType.Name();
222 
223  // Retrieve the relevant mapping element
224  MappingElement::iterator iMe = m_mappingElement.find( arrayTypeName );
225  if ( iMe == m_mappingElement.end() ) {
226  throwException( "Item for \"" + arrayTypeName + "\" not found in the mapping element",
227  "CArrayReader::build" );
228  }
229 
230  m_dataReader.reset( streamerFactory.newReader( arrayResolvedType, iMe->second ) );
231  m_dataReader->build( m_localElement, *m_query );
232  return true;
233 }
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:380
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 255 of file CArrayStreamer.cc.

References i, and ora::throwException().

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

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

References ora::throwException().

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

235  {
236  if(!m_query.get()){
237  throwException("The streamer has not been built.",
238  "CArrayReader::select");
239  }
240  coral::AttributeList& whereData = m_query->whereData();
241  whereData[ m_mappingElement.pkColumn() ].data<int>() = oid;
242  m_query->execute();
243  m_dataReader->select( oid );
244 }
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 246 of file CArrayStreamer.cc.

References i.

246  {
247  m_recordId.clear();
248  for(size_t i=0;i<identity.size();i++) {
249  m_recordId.push_back( identity[i] );
250  }
251  // allocate the element for the index...
252  m_recordId.push_back( 0 );
253 }
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.