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

Represents a "bundle" in the EDIF sense. More...

#include <Bundle.hpp>

+ Inheritance diagram for torc::generic::Bundle< _Type >:
+ Collaboration diagram for torc::generic::Bundle< _Type >:

Public Types

typedef Composite< _Type > BaseType
 
typedef BaseType::Type Type
 
typedef BaseType::Pointer Pointer
 
typedef BaseType::List List
 
typedef BaseType::SizeType SizeType
 
typedef Type ChildType
 
typedef boost::weak_ptr< TypeWeakPointer
 

Public Member Functions

virtual ~Bundle () throw ()
 
virtual CompositionType getCompositionType () const
 
virtual SizeType getSize () const
 
virtual void addChild (const boost::shared_ptr< Type > &child) throw (Error)
 
virtual void getChildren (List &outChildren) const throw (Error)
 
template<typename _Action >
void applyOnAllChildren (const _Action &action) throw (Error)
 
virtual const Pointer get (const std::vector< SizeType > &indices) const throw (Error)
 
virtual void setParentCollection (const Pointer &inParentCollection)
 
virtual Pointer getParentCollection () const
 
void setWeakThis (const WeakPointer &inWeakThis)
 
Pointer getSharedThis () const
 

Protected Member Functions

 Bundle ()
 

Private Attributes

List mChildren
 

Detailed Description

template<typename _Type>
class torc::generic::Bundle< _Type >

Represents a "bundle" in the EDIF sense.

A bundle in EDIF is an ordered collection of items. For example a bundle of ports is a collection of other scalar and vector ports. The Bundle class represents an implementation of functionality for such a collection.

Definition at line 43 of file Bundle.hpp.

Member Typedef Documentation

template<typename _Type>
typedef Composite<_Type> torc::generic::Bundle< _Type >::BaseType

Definition at line 48 of file Bundle.hpp.

template<typename _Type>
typedef Type torc::generic::Bundle< _Type >::ChildType

Definition at line 53 of file Bundle.hpp.

template<typename _Type>
typedef BaseType::List torc::generic::Bundle< _Type >::List

Definition at line 51 of file Bundle.hpp.

template<typename _Type>
typedef BaseType::Pointer torc::generic::Bundle< _Type >::Pointer

Definition at line 50 of file Bundle.hpp.

template<typename _Type>
typedef BaseType::SizeType torc::generic::Bundle< _Type >::SizeType

Definition at line 52 of file Bundle.hpp.

template<typename _Type>
typedef BaseType::Type torc::generic::Bundle< _Type >::Type

Definition at line 49 of file Bundle.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 >
torc::generic::Bundle< _Type >::Bundle ( )
protected

Definition at line 112 of file Bundle.hpp.

112 : Composite<_Type>() {}
template<typename _Type >
torc::generic::Bundle< _Type >::~Bundle ( )
throw (
)
virtual

Definition at line 114 of file Bundle.hpp.

114 {}

Member Function Documentation

template<typename _Type >
void torc::generic::Bundle< _Type >::addChild ( const boost::shared_ptr< Type > &  child)
throw (Error
)
virtual

Add a child to the bundle. Note that, the new element is added to the end of the array.

Parameters
[in]childA pointer to a child
Exceptions
ErrorThe composition is not a container or the child type is not proper

Definition at line 145 of file Bundle.hpp.

146  {
147  mChildren.push_back(child);
148  child->setParentCollection(SelfReferencing<_Type>::getSharedThis());
149 }
template<typename _Type >
template<typename _Action >
void torc::generic::Bundle< _Type >::applyOnAllChildren ( const _Action &  action)
throw (Error
)

Definition at line 162 of file Bundle.hpp.

163  {
164  try {
165  std::for_each(mChildren.begin(), mChildren.end(), action);
166  } catch(Error& e) {
167  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
168  throw;
169  }
170 
171 }

+ Here is the call graph for this function:

template<typename _Type>
const Bundle< _Type >::Pointer torc::generic::Bundle< _Type >::get ( const std::vector< SizeType > &  indices) const
throw (Error
)
virtual

Get a specific member of this composition.

Returns
An empty pointer is returned
Exceptions
ErrorIndex dimensions mismatch

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

Definition at line 180 of file Bundle.hpp.

181  {
182  return Pointer();
183 }
BaseType::Pointer Pointer
Definition: Bundle.hpp:50
template<typename _Type>
void torc::generic::Bundle< _Type >::getChildren ( List outChildren) const
throw (Error
)
virtual

Get children of this composition.

Parameters
[out]outChildrenA list of all children for this composition

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

Definition at line 156 of file Bundle.hpp.

157  {
158  outChildren.insert(outChildren.end(), mChildren.begin(), mChildren.end());
159  return;
160 }

+ Here is the caller graph for this function:

template<typename _Type >
CompositionType torc::generic::Bundle< _Type >::getCompositionType ( ) const
virtual

Get composition type for this object

Returns
The CompositionType inSource VECTOR is returned

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

Definition at line 121 of file Bundle.hpp.

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 >
Bundle< _Type >::SizeType torc::generic::Bundle< _Type >::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 129 of file Bundle.hpp.

129  {
130  size_t size = 0;
131  for(typename Bundle<_Type>::List::const_iterator it = mChildren.begin(); it != mChildren.end();
132  ++it) {
133  size += (*it)->getSize();
134  }
135  return size;
136 }
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

Field Documentation

template<typename _Type>
List torc::generic::Bundle< _Type >::mChildren
private

Definition at line 109 of file Bundle.hpp.


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