torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve > Class Template Reference

An array of objects. More...

#include <Vector.hpp>

+ Inheritance diagram for torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >:
+ Collaboration diagram for torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >:

Public Types

typedef Composite< _Type > BaseType
 
typedef BaseType::Type Type
 
typedef BaseType::List List
 
typedef BaseType::Pointer Pointer
 
typedef BaseType::SizeType SizeType
 
typedef _ChildType ChildType
 
typedef boost::shared_ptr
< ChildType
ChildPointer
 
typedef _ChildFactoryType ChildFactory
 
typedef boost::shared_ptr
< _ChildFactoryType > 
ChildFactorySharedPtr
 
typedef boost::weak_ptr< TypeWeakPointer
 

Public Member Functions

virtual ~Vector () throw ()
 
virtual CompositionType getCompositionType () const
 
virtual SizeType getSize () const
 
virtual const Pointer get (const std::vector< SizeType > &inIndices) const throw (Error)
 
virtual void getChildren (List &outChildren) const throw (Error)
 
template<typename _Action >
void applyOnAllChildren (const _Action &action) throw (Error)
 
virtual void forceAutoBlast (void) throw (Error)
 
virtual void getCreatedChildren (List &outChildren) const throw (Error)
 
void constructChildren (const boost::shared_ptr< ChildFactory > &inFactory, const std::vector< SizeType > &inLimits) throw (Error)
 
void getLimits (std::vector< SizeType > &outLimits) const
 
bool getIsPreserved () const
 
virtual void setParentCollection (const Pointer &inParentCollection)
 
virtual Pointer getParentCollection () const
 
void setWeakThis (const WeakPointer &inWeakThis)
 
Pointer getSharedThis () const
 

Protected Member Functions

 Vector ()
 
void setChildren (const List &inSource) throw (Error)
 
virtual void onAutoBlast () const throw (Error)
 
virtual void onChildCreate (const boost::shared_ptr< ChildType > &inCreatedChild) const throw (Error)
 
void setLimits (const std::vector< SizeType > &inSource)
 
const boost::shared_ptr
< ChildFactory
getFactory () const
 
void setFactory (const boost::shared_ptr< ChildFactory > &inSource)
 

Private Types

typedef SymTab< SizeType, PointerSparseElements
 

Private Member Functions

void autoBlast () const throw (Error)
 
void incrementIndices (std::vector< SizeType > &indices, const std::vector< SizeType > &limits) const
 
SizeType indicesToAbsoluteIndex (const std::vector< SizeType > &inIndices) const
 
SizeType storageSize () const
 
 Vector (const Vector< _Type, _ChildType, _ChildFactoryType, cPreserve > &source)
 
Vector< _Type, _ChildType,
_ChildFactoryType, cPreserve > & 
operator= (const Vector< _Type, _ChildType, _ChildFactoryType, cPreserve > &source)
 

Private Attributes

std::vector< SizeTypemLimits
 
List mChildren
 
SparseElements mSparseElements
 
boost::shared_ptr< ChildFactorymFactory
 
bool mIsPreserved
 
SizeType mPreservationThreshold
 

Detailed Description

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
class torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >

An array of objects.

This provides methods for accessing and adding elements to the array. It also implements the VectorPreservation algorithm if cPreserve is set to true. The vector class creates elements derived from VectorBit class by using the provided factory.

Definition at line 50 of file Vector.hpp.

Member Typedef Documentation

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef Composite<_Type> torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::BaseType

Definition at line 55 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef _ChildFactoryType torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::ChildFactory

Definition at line 62 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef boost::shared_ptr<_ChildFactoryType> torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::ChildFactorySharedPtr

Definition at line 63 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef boost::shared_ptr<ChildType> torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::ChildPointer

Definition at line 61 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef _ChildType torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::ChildType

Definition at line 60 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef BaseType::List torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::List

Definition at line 57 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef BaseType::Pointer torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::Pointer

Definition at line 58 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef BaseType::SizeType torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::SizeType

Definition at line 59 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef SymTab<SizeType, Pointer> torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::SparseElements
private

Definition at line 66 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
typedef BaseType::Type torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::Type

Definition at line 56 of file Vector.hpp.

template<typename _Type>
typedef boost::weak_ptr<Type> torc::generic::Composite< _Type >::WeakPointer
inherited

Definition at line 56 of file Composite.hpp.

Constructor & Destructor Documentation

template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::Vector ( )
protected

Definition at line 292 of file Vector.hpp.

292  : BaseType(), mLimits(),
293  mChildren(), mFactory(), mIsPreserved(cPreserve), mPreservationThreshold(1024) {}
std::vector< SizeType > mLimits
Definition: Vector.hpp:274
boost::shared_ptr< ChildFactory > mFactory
Definition: Vector.hpp:277
SizeType mPreservationThreshold
Definition: Vector.hpp:279
Composite< _Type > BaseType
Definition: Vector.hpp:55
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::~Vector ( )
throw (
)
virtual

Definition at line 289 of file Vector.hpp.

289 {}
template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::Vector ( const Vector< _Type, _ChildType, _ChildFactoryType, cPreserve > &  source)
private

Member Function Documentation

template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
template<typename _Action >
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::applyOnAllChildren ( const _Action &  action)
throw (Error
)

Definition at line 448 of file Vector.hpp.

448  {
449  try {
450  std::for_each(mChildren.begin(), mChildren.end(), action);
451  } catch(Error& e) {
452  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
453  throw;
454  }
455 
456 }

+ Here is the call graph for this function:

template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::autoBlast ( ) const
throw (Error
)
inlineprivate

Definition at line 534 of file Vector.hpp.

534  {
535  SizeType size = storageSize();
536  mChildren.resize(mChildren.size() + size); //create empty
537  Pointer thisPtr = BaseType::getSharedThis();
538  std::vector < SizeType > indices(mLimits.size());
539  fill(indices.begin(), indices.end(), 0);
540  if(!thisPtr) {
541  Error e(eMessageIdErrorPointerToItemDoesNotExist, __FUNCTION__, __FILE__, __LINE__);
542  e.saveContextData("Pointer to this object does not exist", thisPtr);
543  throw e;
544  }
545  boost::shared_ptr < ChildFactory > factory = getFactory();
546  if(!factory) {
547  Error e(eMessageIdErrorNullChildfactory, __FUNCTION__, __FILE__, __LINE__);
548  e.saveContextData("Null Child Factory", factory);
549  throw e;
550  }
551  for(SizeType index = 0; index < size; index++) {
552  Pointer child;
553  bool createNew = (cPreserve && mSparseElements.getSize() > 0
554  && mSparseElements.get(index, child)) ? false : true;
555  if(createNew) {
556  ChildPointer newChild;
557  try {
558  factory->create(newChild);
559  newChild->setParentCollection(thisPtr);
560  newChild->setIndices(indices);
561  newChild->setAbsoluteIndex(index);
562  child = newChild;
563  onChildCreate(newChild);
564  } catch(Error& e) {
565  mChildren.clear(); //For consistency
566  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
567  throw;
568  }
569  }
570  incrementIndices(indices, mLimits);
571  mChildren[index] = child;
572  }
574  try {
575  onAutoBlast();
576  } catch(Error& e) {
577  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
578  throw;
579  }
580 }
SizeType storageSize() const
Definition: Vector.hpp:640
SparseElements mSparseElements
Definition: Vector.hpp:276
std::vector< SizeType > mLimits
Definition: Vector.hpp:274
boost::shared_ptr< ChildType > ChildPointer
Definition: Vector.hpp:61
virtual void onChildCreate(const boost::shared_ptr< ChildType > &inCreatedChild) const
Definition: Vector.hpp:599
virtual void onAutoBlast() const
Definition: Vector.hpp:470
void incrementIndices(std::vector< SizeType > &indices, const std::vector< SizeType > &limits) const
Definition: Vector.hpp:605
const boost::shared_ptr< ChildFactory > getFactory() const
Definition: Vector.hpp:680
BaseType::SizeType SizeType
Definition: Vector.hpp:59
bool get(const KeyType &inKey, ValueType &outValue) const
Definition: SymTab.hpp:121
size_t getSize() const
Definition: SymTab.hpp:182
BaseType::Pointer Pointer
Definition: Vector.hpp:58

+ Here is the call graph for this function:

template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::constructChildren ( const boost::shared_ptr< ChildFactory > &  inFactory,
const std::vector< SizeType > &  inLimits 
)
throw (Error
)
inline

Create list of children using the provided factory and limits

Parameters
[in]inFactoryChildFactory to use for construcing children
[in]inLimitsArray dimensions
Exceptions
ErrorChildren could not be created
Note
setName() must have already been called before calling this method. For preserved arrays this does not actually do anything other than storing the factory and limits inside itself for later use.

Create list of children using the provided factory and limits

Parameters
[in]inFactoryChildFactory to use for construcing children
[in]inLimitsArray dimensions
Exceptions
ErrorChildren could not be created
Note
For preserved arrays this does not actually do anything other than storing the factory and limits inside itself for later use.

Definition at line 502 of file Vector.hpp.

504  {
505  if(inLimits.empty()) {
506  Error e(eMessageIdErrorEmptyArray, __FUNCTION__, __FILE__, __LINE__);
507  e.saveContextData("Empty Array,", inLimits.empty());
508  throw e;
509  } else {
510  typename std::vector<SizeType>::const_iterator index = inLimits.begin();
511  typename std::vector<SizeType>::const_iterator lend = inLimits.end();
512  for(; index != lend; index++) {
513  if(*index == 0) {
514  Error e(eMessageIdErrorEmptyArray, __FUNCTION__, __FILE__, __LINE__);
515  e.saveContextData("Empty Array,", *index);
516  throw e;
517  }
518  }
519  }
520 
521  setFactory(inFactory);
522  setLimits(inLimits);
523  if(!cPreserve) {
524  try {
525  autoBlast();
526  } catch(Error& e) {
527  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
528  throw;
529  }
530  }
531 }
void setFactory(const boost::shared_ptr< ChildFactory > &inSource)
Definition: Vector.hpp:690
void autoBlast() const
Definition: Vector.hpp:534
void setLimits(const std::vector< SizeType > &inSource)
Definition: Vector.hpp:668

+ Here is the call graph for this function:

template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::forceAutoBlast ( void  )
throw (Error
)
inlinevirtual

Force creation of VectorBit children, even if this is a preserved Vector.

Definition at line 479 of file Vector.hpp.

480  {
481  if(!mFactory) return;
482  if(mLimits.empty()) return;
483  try {
484  autoBlast();
485  } catch(Error& e) {
486  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
487  throw;
488  }
489 }
std::vector< SizeType > mLimits
Definition: Vector.hpp:274
boost::shared_ptr< ChildFactory > mFactory
Definition: Vector.hpp:277
void autoBlast() const
Definition: Vector.hpp:534

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
const Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::Pointer torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::get ( const std::vector< SizeType > &  inIndices) const
throw (Error
)
virtual

Get a specific member of this composition.

Note
This is relevant for Vector composition only. Other compositions return a NULL pointer
Parameters
[in]inIndicesA list of indices to be accessed. The number of indices must be equal to the number of dimensions.
Returns
A pointer to the child situated at the specified indices. For non-relevant types a NULL pointer is returned
Exceptions
ErrorIndex dimensions mismatch
  • Id : eMessageIdErrorArrayIndexSizeMismatch
  • Context Data
    • Array Index Size - size_t
    • Array Dimension Size - size_t
ErrorArray index out of bounds
  • Id : eMessageIdErrorArrayIndexOutOfBounds
  • Context Data
    • Array Index - size_t
    • Array Dimension - size_t
ErrorEmpty Array
  • Id : eMessageIdErrorEmptyArray
  • Context Data
    • Array Dimension - size_t

Get a specific member of this composition.

Note
This is relevant for Vector composition only. Other compositions return a NULL pointer
Parameters
[in]inIndicesA list of indices to be accessed. The number of indices must be equal to the number of dimensions.
Returns
A pointer to the child situated at the specified indices. For non-relevant types a NULL pointer is returned
Exceptions
ErrorIndex dimensions mismatch

Implements torc::generic::Composite< _Type >.

Definition at line 363 of file Vector.hpp.

364  {
365  if(inIndices.size() != mLimits.size()) {
366  Error e(eMessageIdErrorArrayIndexSizeMismatch, __FUNCTION__, __FILE__, __LINE__);
367  e.saveContextData("Array Index", inIndices.size());
368  e.saveContextData("Array Dimension", mLimits.size());
369  throw e;
370  } else {
371  typename std::vector<SizeType>::const_iterator lend = mLimits.end();
372  typename std::vector<SizeType>::const_iterator limit = mLimits.begin();
373  typename std::vector<SizeType>::const_iterator index = inIndices.begin();
374  for(; limit != lend; ++limit, ++index) {
375  if(*index >= *limit) {
376  Error e(eMessageIdErrorArrayIndexOutOfBounds, __FUNCTION__, __FILE__, __LINE__);
377  e.saveContextData("Array Index", *index);
378  e.saveContextData("Array Dimension", *limit);
379  throw e;
380  }
381  }
382  }
383 
384  SizeType index = indicesToAbsoluteIndex(inIndices);
385 
386  Pointer thisPtr = BaseType::getSharedThis();
387  boost::shared_ptr < ChildFactory > factory = getFactory();
388  if(!factory) {
389  Error e(eMessageIdErrorNullChildfactory, __FUNCTION__, __FILE__, __LINE__);
390  e.saveContextData("Null Child Factory", factory);
391  throw e;
392  }
393 
394  Pointer child;
395  if(cPreserve && mChildren.empty()) {
396  if(false == mSparseElements.get(index, child)) {
397  ChildPointer newChild;
398  try {
399  factory->create(newChild);
400  newChild->setParentCollection(thisPtr);
401  newChild->setIndices(inIndices);
402  newChild->setAbsoluteIndex(index);
403  mSparseElements.set(index, newChild);
404  child = newChild;
405  onChildCreate(newChild);
406  } catch(Error& e) {
407  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
408  throw;
409  }
410  }
411  //TBD::THRESHOLD BASED CHECKING?
412  } else {
413  child = mChildren[index];
414  }
415 
416  return child;
417 }
SparseElements mSparseElements
Definition: Vector.hpp:276
std::vector< SizeType > mLimits
Definition: Vector.hpp:274
boost::shared_ptr< ChildType > ChildPointer
Definition: Vector.hpp:61
virtual void onChildCreate(const boost::shared_ptr< ChildType > &inCreatedChild) const
Definition: Vector.hpp:599
SizeType indicesToAbsoluteIndex(const std::vector< SizeType > &inIndices) const
Definition: Vector.hpp:624
const boost::shared_ptr< ChildFactory > getFactory() const
Definition: Vector.hpp:680
bool set(const KeyType &inKey, const ValueType &inValue)
Definition: SymTab.hpp:132
BaseType::SizeType SizeType
Definition: Vector.hpp:59
bool get(const KeyType &inKey, ValueType &outValue) const
Definition: SymTab.hpp:121
BaseType::Pointer Pointer
Definition: Vector.hpp:58

+ Here is the call graph for this function:

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::getChildren ( List outChildren) const
throw (Error
)
virtual

Get children of this composition.

Parameters
[out]outChildrenA list of all children for this composition
Exceptions
ErrorIf factory is not set and preserve is true and the vector has not been blasted, an exception is generated.

Implements torc::generic::Composite< _Type >.

Definition at line 428 of file Vector.hpp.

430  {
431  if(cPreserve //Is the vector preserved? Otherwise it already has all the elements
432  && !mLimits.empty() //Do we have sufficient info to blast
433  && mChildren.empty()) //Haven't we already blasted
434  {
435  try {
436  autoBlast();
437  } catch(Error& e) {
438  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
439  throw;
440  }
441  }
442  outChildren.insert(outChildren.end(), mChildren.begin(), mChildren.end());
443  return;
444 }
std::vector< SizeType > mLimits
Definition: Vector.hpp:274
void autoBlast() const
Definition: Vector.hpp:534

+ Here is the call graph for this function:

template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
CompositionType torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::getCompositionType ( ) const
virtual

Get composition type for this object

Returns
The CompositionType inSource eCompositionTypeVector is returned

Implements torc::generic::Composite< _Type >.

Definition at line 301 of file Vector.hpp.

template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::getCreatedChildren ( List outChildren) const
throw (Error
)
virtual

Definition at line 583 of file Vector.hpp.

584  {
585  if(cPreserve && mChildren.empty()) {
586  mSparseElements.getValues(outChildren);
587  } else if(!mChildren.empty()) {
588  try {
589  getChildren(outChildren);
590  } catch(Error& e) {
591  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
592  throw;
593  }
594  }
595  return;
596 }
void getValues(std::vector< ValueType > &outValues) const
Definition: SymTab.hpp:158
SparseElements mSparseElements
Definition: Vector.hpp:276
virtual void getChildren(List &outChildren) const
Definition: Vector.hpp:428

+ Here is the call graph for this function:

template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
const boost::shared_ptr< _ChildFactoryType > torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::getFactory ( ) const
inlineprotected

Get current factory

Returns
Return ChildFactory object
Exceptions
ErrorNull Child Factory
  • Id : eMessageIdErrorNullChildfactory
  • Context Data

    • Child factory - ChildFactory

    Get current factory

Returns
Return ChildFactory object

Definition at line 680 of file Vector.hpp.

680  {
681  return mFactory;
682 }
boost::shared_ptr< ChildFactory > mFactory
Definition: Vector.hpp:277
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
bool torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::getIsPreserved ( ) const
inline

Definition at line 658 of file Vector.hpp.

658  {
659  return mIsPreserved;
660 }
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::getLimits ( std::vector< SizeType > &  outLimits) const
inline

Get dimensions of the array.

Parameters
[in]outLimitsDimensions of the vector

Get dimensions of the array.

Returns
Dimensions of the vector

Definition at line 652 of file Vector.hpp.

653  {
654  outLimits.insert(outLimits.end(), mLimits.begin(), mLimits.end());
655 }
std::vector< SizeType > mLimits
Definition: Vector.hpp:274
template<typename _Type >
Composite< _Type >::Pointer torc::generic::Composite< _Type >::getParentCollection ( ) const
inlinevirtualinherited

Get a pointer to the parent collection

Returns
A pointer to the parent collection if present, empty pointer otherwise

Definition at line 156 of file Composite.hpp.

156  {
157  return mParentCollection.lock();
158 }
WeakPointer mParentCollection
Definition: Composite.hpp:133
Pointer torc::generic::SelfReferencing< _Type >::getSharedThis ( ) const
inlineinherited

Get a shared pointer to this object. A valid pointer is returned if weakThis was set. Otherwise this returns a NULL pointer. For Vector types, the second scenario is an exception condition and should be treated as such.

Returns
A shared pointer to this object

Get a shared pointer to this object. A valid pointer is returned if weakThis was set. Otherwise this returns a NULL pointer. For Vector types, the second scenario is an exception condition and should be treated as such.

Parameters
[out]ptrSet to a shared pointer to this object
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::SizeType torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::getSize ( void  ) const
virtual

Get the total number of bits of the composition

Returns
Number of bits

Implements torc::generic::Composite< _Type >.

Definition at line 312 of file Vector.hpp.

312  {
313  return storageSize();
314 }
SizeType storageSize() const
Definition: Vector.hpp:640
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::incrementIndices ( std::vector< SizeType > &  indices,
const std::vector< SizeType > &  limits 
) const
private

Definition at line 605 of file Vector.hpp.

606  {
607  SizeType size = limits.size();
608  bool incr = false;
609  for(SizeType i = 0; i < size; i++) {
610  if(i == 0 || incr) {
611  ++indices[i];
612  if(indices[i] == limits[i]) {
613  indices[i] = 0;
614  incr = true;
615  } else {
616  incr = false;
617  }
618  }
619  }
620 }
BaseType::SizeType SizeType
Definition: Vector.hpp:59
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::SizeType torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::indicesToAbsoluteIndex ( const std::vector< SizeType > &  inIndices) const
inlineprivate

Definition at line 624 of file Vector.hpp.

625  {
626  SizeType idx = 0;
627  SizeType size = mLimits.size();
628  for(SizeType k = 1; k <= size; k++) {
629  SizeType prod = 1;
630  for(SizeType l = k + 1; l <= size; l++) {
631  prod *= mLimits[l - 1];
632  }
633  idx += prod * inIndices[k - 1];
634  }
635  return idx;
636 }
std::vector< SizeType > mLimits
Definition: Vector.hpp:274
BaseType::SizeType SizeType
Definition: Vector.hpp:59
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::onAutoBlast ( ) const
throw (Error
)
protectedvirtual

Definition at line 470 of file Vector.hpp.

470  {
471  //Do nothing here
472  //meant to be overridden by clients
473 }
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::onChildCreate ( const boost::shared_ptr< ChildType > &  inCreatedChild) const
throw (Error
)
protectedvirtual

Definition at line 599 of file Vector.hpp.

600  {
601  //If required, inherited classes will override this
602 }
template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
Vector<_Type, _ChildType, _ChildFactoryType, cPreserve>& torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::operator= ( const Vector< _Type, _ChildType, _ChildFactoryType, cPreserve > &  source)
private
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::setChildren ( const List inSource)
throw (Error
)
protected

Set list of children for unpreserved vector.

Parameters
[in]inSourceList of children

Definition at line 464 of file Vector.hpp.

465  {
466  mChildren = inSource;
467 }
template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::setFactory ( const boost::shared_ptr< ChildFactory > &  inSource)
protected

Set current factory

Parameters
[in]inSourceChildFactory object

Definition at line 690 of file Vector.hpp.

691  {
692  mFactory = inSource;
693 }
boost::shared_ptr< ChildFactory > mFactory
Definition: Vector.hpp:277
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
void torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::setLimits ( const std::vector< SizeType > &  inSource)
protected

Set dimensions of the array.

Parameters
[in]inSourceDimensions of the vector

Definition at line 668 of file Vector.hpp.

669  {
670  mLimits = inSource;
671 }
std::vector< SizeType > mLimits
Definition: Vector.hpp:274
template<typename _Type>
void torc::generic::Composite< _Type >::setParentCollection ( const Pointer inParentCollection)
inlinevirtualinherited

Set a pointer to a parnt composition.

Parameters
[in]inParentCollectionpointer to the parent collection (Vector/Bundle)

Set a pointer to a parnt composition.

Parameters
[in]parentCollectionpointer to the parent collection (Vector/Bundle)

Definition at line 145 of file Composite.hpp.

146  {
147  mParentCollection = inParentCollection;
148 }
WeakPointer mParentCollection
Definition: Composite.hpp:133
void torc::generic::SelfReferencing< _Type >::setWeakThis ( const WeakPointer inWeakThis)
inlineinherited

Set a weak pointer to this object. This will be used later to get a shared pointer to this object from within other member methods if required. This should be called by the Factory creating the object.

Parameters
[in]weakThisA weak pointer to this object
template<typename _Type , typename _ChildType , typename _ChildFactoryType , bool cPreserve>
Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::SizeType torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::storageSize ( ) const
inlineprivate

Definition at line 640 of file Vector.hpp.

640  {
641  return std::accumulate(mLimits.begin(), mLimits.end(), 1,
642  std::multiplies<typename Vector<_Type, _ChildType, _ChildFactoryType,
643  cPreserve>::SizeType>());
644 }
std::vector< SizeType > mLimits
Definition: Vector.hpp:274
BaseType::SizeType SizeType
Definition: Vector.hpp:59

Field Documentation

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
List torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::mChildren
mutableprivate

Definition at line 275 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
boost::shared_ptr<ChildFactory> torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::mFactory
private

Definition at line 277 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
bool torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::mIsPreserved
private

Definition at line 278 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
std::vector<SizeType> torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::mLimits
private

Definition at line 274 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
SizeType torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::mPreservationThreshold
private

Definition at line 279 of file Vector.hpp.

template<typename _Type, typename _ChildType, typename _ChildFactoryType, bool cPreserve = false>
SparseElements torc::generic::Vector< _Type, _ChildType, _ChildFactoryType, cPreserve >::mSparseElements
mutableprivate

Definition at line 276 of file Vector.hpp.


The documentation for this class was generated from the following file: