torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::physical::Primitive Class Reference

primitive. More...

#include <Primitive.hpp>

+ Inheritance diagram for torc::physical::Primitive:
+ Collaboration diagram for torc::physical::Primitive:

Public Types

typedef
ElementSharedPtrVector::const_iterator 
ElementSharedPtrConstIterator
 Constant iterator for Element shared pointers. More...
 
typedef
ElementSharedPtrVector::iterator 
ElementSharedPtrIterator
 Non-constant iterator for Element shared pointers. More...
 
typedef
PrimitivePinSharedPtrVector::const_iterator 
PrimitivePinSharedPtrConstIterator
 
typedef
PrimitivePinSharedPtrVector::iterator 
PrimitivePinSharedPtrIterator
 

Public Member Functions

ElementSharedPtrIterator findElement (const string &inName)
 Find a primitive element by name. More...
 
bool addElement (ElementSharedPtr &inElementPtr)
 Add a element to the primitive. More...
 
bool removeElement (ElementSharedPtr &inElementPtr)
 Remove a element from the primitive. More...
 
bool operator== (const Primitive &rhs) const
 Equality operator. More...
 
size_t getElementCount (void) const
 
ElementSharedPtrConstIterator elementsBegin (void) const
 Returns the begin constant iterator for elements. More...
 
ElementSharedPtrConstIterator elementsEnd (void) const
 Returns the end constant iterator for elements. More...
 
ElementSharedPtrIterator elementsBegin (void)
 Returns the begin non-constant iterator for elements. More...
 
ElementSharedPtrIterator elementsEnd (void)
 Returns the end non-constant iterator for elements. More...
 
size_t getPrimitivePinCount (void) const
 
PrimitivePinSharedPtrConstIterator PrimitivePinsBegin (void) const
 
PrimitivePinSharedPtrIterator PrimitivePinsBegin (void)
 
PrimitivePinSharedPtrConstIterator PrimitivePinsEnd (void) const
 
PrimitivePinSharedPtrIterator PrimitivePinsEnd (void)
 
bool addPrimitivePin (PrimitivePinSharedPtr &inPrimitivePinPtr)
 
bool removePrimitivePin (PrimitivePinSharedPtr &inPrimitivePinPtr)
 
PrimitivePinSharedPtrIterator findPrimitivePin (const string &inName)
 
bool operator== (const Component &rhs) const
 
bool operator== (const Named &rhs) const
 Equality operator. More...
 
const stringgetName (void) const
 Returns the object name. More...
 
const WeakPtrTypegetParentWeakPtr (void) const
 Returns a weak pointer to the parent. More...
 
void setParentWeakPtr (WeakPtrType inParentPtr)
 Sets the weak pointer to the parent. More...
 
void resetParentWeakPtr (void)
 Method to reset and orphan this object. More...
 
const SharedPtrTypegetParentSharedPtr (void) const
 Returns a shared pointer to the parent (WARNING: Does not work right). More...
 

Protected Types

typedef std::string string
 Imported type name. More...
 
typedef boost::weak_ptr< class
Component
WeakPtrType
 Weak pointer of our own type. More...
 
typedef boost::weak_ptr< class
Component
WeakPtrType
 Weak pointer of our own type. More...
 
typedef boost::shared_ptr
< class Component
SharedPtrType
 Shared pointer of our own type. More...
 
typedef boost::shared_ptr
< class Component
SharedPtrType
 Shared pointer of our own type. More...
 

Protected Member Functions

 Primitive (const string &inName)
 
void setSelfWeakPtr (WeakPtrType inSelfPtr)
 Sets the weak pointer to this object. More...
 
const WeakPtrTypegetSelfWeakPtr (void) const
 Returns a weak pointer to this object. More...
 

Protected Attributes

ElementSharedPtrVector mElements
 Vector of element shared pointers. More...
 
PrimitivePinSharedPtrVector mPrimitivePins
 
string mName
 The name of the object. More...
 
WeakPtrType mParentWeakPtr
 Weak pointer to the parent. More...
 
WeakPtrType mSelfWeakPtr
 Weak pointer this object. More...
 

Friends

class RcFactory
 The Factory class has direct access to our internals. More...
 

Detailed Description

primitive.

Definition at line 33 of file Primitive.hpp.

Member Typedef Documentation

typedef ElementSharedPtrVector::const_iterator torc::physical::Primitive::ElementSharedPtrConstIterator

Constant iterator for Element shared pointers.

Definition at line 53 of file Primitive.hpp.

typedef ElementSharedPtrVector::iterator torc::physical::Primitive::ElementSharedPtrIterator

Non-constant iterator for Element shared pointers.

Definition at line 55 of file Primitive.hpp.

typedef PrimitivePinSharedPtrVector::const_iterator torc::physical::Component::PrimitivePinSharedPtrConstIterator
inherited

Definition at line 39 of file Component.hpp.

typedef PrimitivePinSharedPtrVector::iterator torc::physical::Component::PrimitivePinSharedPtrIterator
inherited

Definition at line 40 of file Component.hpp.

typedef boost::shared_ptr<class Component > torc::physical::Progeny< class Component >::SharedPtrType
protectedinherited

Shared pointer of our own type.

Definition at line 35 of file Progeny.hpp.

typedef boost::shared_ptr<class Component > torc::physical::Progenitor< class Component >::SharedPtrType
protectedinherited

Shared pointer of our own type.

Definition at line 52 of file Progenitor.hpp.

typedef std::string torc::physical::Primitive::string
protected

Imported type name.

Definition at line 42 of file Primitive.hpp.

typedef boost::weak_ptr<class Component > torc::physical::Progeny< class Component >::WeakPtrType
protectedinherited

Weak pointer of our own type.

Definition at line 33 of file Progeny.hpp.

typedef boost::weak_ptr<class Component > torc::physical::Progenitor< class Component >::WeakPtrType
protectedinherited

Weak pointer of our own type.

Definition at line 50 of file Progenitor.hpp.

Constructor & Destructor Documentation

torc::physical::Primitive::Primitive ( const string inName)
inlineprotected

Definition at line 48 of file Primitive.hpp.

48 : Component(inName){}
Component(const string &inName)
Protected constructor.
Definition: Component.hpp:37

Member Function Documentation

bool torc::physical::Primitive::addElement ( ElementSharedPtr inElementPtr)
inline

Add a element to the primitive.

Parameters
inElementPtrThe element to add.
Returns
true if the element was added, or false if a element with the same name already exists in the primitive.
Todo:
Acquire mutex.
Todo:
Release mutex.

Definition at line 69 of file Primitive.hpp.

69  {
70 /// \todo Acquire mutex.
71 ElementSharedPtrVector::iterator e = mElements.end();
72 ElementSharedPtrVector::iterator result = findElement(inElementPtr->getName());
73 if(result == e) mElements.push_back(inElementPtr);
74 return result == e; // return true if we added the element
75 /// \todo Release mutex.
76 }
ElementSharedPtrIterator findElement(const string &inName)
Find a primitive element by name.
Definition: Primitive.hpp:61
ElementSharedPtrVector mElements
Vector of element shared pointers.
Definition: Primitive.hpp:45

+ Here is the call graph for this function:

bool torc::physical::Component::addPrimitivePin ( PrimitivePinSharedPtr inPrimitivePinPtr)
inlineinherited
Todo:
Acquire mutex.
Todo:
Release mutex.

Definition at line 48 of file Component.hpp.

48  {
49  /// \todo Acquire mutex.
51  PrimitivePinSharedPtrIterator result = std::find(PrimitivePinsEnd(), e, inPrimitivePinPtr);
52  if(result != e) return false;
53  mPrimitivePins.push_back(inPrimitivePinPtr);
54  return true;
55  /// \todo Release mutex.
56  }
PrimitivePinSharedPtrVector::iterator PrimitivePinSharedPtrIterator
Definition: Component.hpp:40
PrimitivePinSharedPtrVector mPrimitivePins
Definition: Component.hpp:34
PrimitivePinSharedPtrConstIterator PrimitivePinsEnd(void) const
Definition: Component.hpp:44

+ Here is the call graph for this function:

ElementSharedPtrConstIterator torc::physical::Primitive::elementsBegin ( void  ) const
inline

Returns the begin constant iterator for elements.

Definition at line 161 of file Primitive.hpp.

161 { return mElements.begin(); }
ElementSharedPtrVector mElements
Vector of element shared pointers.
Definition: Primitive.hpp:45

+ Here is the caller graph for this function:

ElementSharedPtrIterator torc::physical::Primitive::elementsBegin ( void  )
inline

Returns the begin non-constant iterator for elements.

Definition at line 165 of file Primitive.hpp.

165 { return mElements.begin(); }
ElementSharedPtrVector mElements
Vector of element shared pointers.
Definition: Primitive.hpp:45
ElementSharedPtrConstIterator torc::physical::Primitive::elementsEnd ( void  ) const
inline

Returns the end constant iterator for elements.

Definition at line 163 of file Primitive.hpp.

163 { return mElements.end(); }
ElementSharedPtrVector mElements
Vector of element shared pointers.
Definition: Primitive.hpp:45

+ Here is the caller graph for this function:

ElementSharedPtrIterator torc::physical::Primitive::elementsEnd ( void  )
inline

Returns the end non-constant iterator for elements.

Definition at line 167 of file Primitive.hpp.

167 { return mElements.end(); }
ElementSharedPtrVector mElements
Vector of element shared pointers.
Definition: Primitive.hpp:45
ElementSharedPtrIterator torc::physical::Primitive::findElement ( const string inName)
inline

Find a primitive element by name.

Parameters
inNameThe element name to look for.
Returns
an iterator for the specified element, or elementsEnd() if the name was not found.

Definition at line 61 of file Primitive.hpp.

61  {
62 NameComparator predicate(inName);
63 return std::find_if(elementsBegin(), elementsEnd(), predicate);
64 }
ElementSharedPtrConstIterator elementsBegin(void) const
Returns the begin constant iterator for elements.
Definition: Primitive.hpp:161
ElementSharedPtrConstIterator elementsEnd(void) const
Returns the end constant iterator for elements.
Definition: Primitive.hpp:163

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PrimitivePinSharedPtrIterator torc::physical::Component::findPrimitivePin ( const string inName)
inlineinherited

Definition at line 66 of file Component.hpp.

66  {
67  NameComparator predicate(inName);
68  return std::find_if(PrimitivePinsBegin(), PrimitivePinsEnd(), predicate);
69  }
PrimitivePinSharedPtrConstIterator PrimitivePinsEnd(void) const
Definition: Component.hpp:44
PrimitivePinSharedPtrConstIterator PrimitivePinsBegin(void) const
Definition: Component.hpp:43

+ Here is the call graph for this function:

size_t torc::physical::Primitive::getElementCount ( void  ) const
inline

Definition at line 158 of file Primitive.hpp.

158 { return mElements.size(); }
ElementSharedPtrVector mElements
Vector of element shared pointers.
Definition: Primitive.hpp:45
const string& torc::physical::Named::getName ( void  ) const
inlineinherited

Returns the object name.

Definition at line 51 of file Named.hpp.

51 { return mName; }
string mName
The name of the object.
Definition: Named.hpp:43

+ Here is the caller graph for this function:

const SharedPtrType& torc::physical::Progeny< class Component >::getParentSharedPtr ( void  ) const
inlineinherited

Returns a shared pointer to the parent (WARNING: Does not work right).

Always seems to generate a "Returning reference to temporary" warning, and I cannot figure out why.

It is the caller's responsibility to reset the shared pointer when done.

Todo:
Figure out why Progeny<T>::getParentSharedPtr() yields a "Returning reference to temporary" warning.

Definition at line 59 of file Progeny.hpp.

59 { return mParentWeakPtr.lock(); }
WeakPtrType mParentWeakPtr
Weak pointer to the parent.
Definition: Progeny.hpp:38
const WeakPtrType& torc::physical::Progeny< class Component >::getParentWeakPtr ( void  ) const
inlineinherited

Returns a weak pointer to the parent.

Definition at line 47 of file Progeny.hpp.

47 { return mParentWeakPtr; }
WeakPtrType mParentWeakPtr
Weak pointer to the parent.
Definition: Progeny.hpp:38
size_t torc::physical::Component::getPrimitivePinCount ( void  ) const
inlineinherited

Definition at line 42 of file Component.hpp.

42 { return mPrimitivePins.size(); }
PrimitivePinSharedPtrVector mPrimitivePins
Definition: Component.hpp:34
const WeakPtrType& torc::physical::Progenitor< class Component >::getSelfWeakPtr ( void  ) const
inlineinherited

Returns a weak pointer to this object.

Definition at line 68 of file Progenitor.hpp.

68 { return mSelfWeakPtr; }
WeakPtrType mSelfWeakPtr
Weak pointer this object.
Definition: Progenitor.hpp:57
bool torc::physical::Named::operator== ( const Named rhs) const
inlineinherited

Equality operator.

Definition at line 54 of file Named.hpp.

54 { return mName == rhs.mName; }
string mName
The name of the object.
Definition: Named.hpp:43
bool torc::physical::Component::operator== ( const Component rhs) const
inlineinherited

Definition at line 71 of file Component.hpp.

71 { return mName == rhs.mName; }
string mName
The name of the object.
Definition: Named.hpp:43
bool torc::physical::Primitive::operator== ( const Primitive rhs) const
inline

Equality operator.

This function deems elements equal if their names are identical.

Parameters
rhsThe element to compare against.
Returns
true if both element names are identical, or false otherwise.

Definition at line 153 of file Primitive.hpp.

153 { return mName == rhs.mName; }
string mName
The name of the object.
Definition: Named.hpp:43
PrimitivePinSharedPtrConstIterator torc::physical::Component::PrimitivePinsBegin ( void  ) const
inlineinherited

Definition at line 43 of file Component.hpp.

43 { return mPrimitivePins.begin(); }
PrimitivePinSharedPtrVector mPrimitivePins
Definition: Component.hpp:34

+ Here is the caller graph for this function:

PrimitivePinSharedPtrIterator torc::physical::Component::PrimitivePinsBegin ( void  )
inlineinherited

Definition at line 45 of file Component.hpp.

45 { return mPrimitivePins.begin(); }
PrimitivePinSharedPtrVector mPrimitivePins
Definition: Component.hpp:34
PrimitivePinSharedPtrConstIterator torc::physical::Component::PrimitivePinsEnd ( void  ) const
inlineinherited

Definition at line 44 of file Component.hpp.

44 { return mPrimitivePins.end(); }
PrimitivePinSharedPtrVector mPrimitivePins
Definition: Component.hpp:34

+ Here is the caller graph for this function:

PrimitivePinSharedPtrIterator torc::physical::Component::PrimitivePinsEnd ( void  )
inlineinherited

Definition at line 46 of file Component.hpp.

46 { return mPrimitivePins.end(); }
PrimitivePinSharedPtrVector mPrimitivePins
Definition: Component.hpp:34
bool torc::physical::Primitive::removeElement ( ElementSharedPtr inElementPtr)
inline

Remove a element from the primitive.

Parameters
inElementPtrThe element to remove.
Returns
true if the element was removed, or false if the element did not exist.
Todo:
Acquire mutex.

Definition at line 80 of file Primitive.hpp.

80  {
81 /// \todo Acquire mutex.
82 ElementSharedPtrVector::iterator e = mElements.end();
83 ElementSharedPtrVector::iterator result = std::find(mElements.begin(), e, inElementPtr);
84 if(result == e) return false;
85 
86 //adjust connections
87 
88  ConnectionPinVector sinkPins;
89  ConnectionPinVector sourcePins;
90  ConnectionSharedPtrVector sourceConnections;
91  ConnectionSharedPtrVector sinkConnections;
92  ElementSharedPtrVector sourceElements;
93  ElementSharedPtrVector sinkElements;
94 
97 
98  ConnectionPin pin;
99 
100  ConnectionSharedPtr cnPtr;
101  ElementSharedPtr elemPtr;
102  for( cnIt = inElementPtr->connectionsBegin(); cnIt != inElementPtr->connectionsEnd(); ++cnIt){
103  if( (*cnIt)->getSource()->getElementName() == inElementPtr->getName() ){
104  pin = *(*cnIt)->getSink();
105  sinkPins.push_back(pin);
106  elemPtr = *findElement(pin.getElementName());
107  sinkElements.push_back(elemPtr);
108  for(cnIt2 = elemPtr->connectionsBegin(); cnIt2 != elemPtr->connectionsEnd(); ++cnIt2){
109  if( (*cnIt2)->getSink()->getPinName() == pin.getPinName()){
110  sinkConnections.push_back(*cnIt2);
111  elemPtr->removeConnection(cnIt2);
112  break;
113  }
114  }
115  }
116  else{
117  pin = *(*cnIt)->getSource();
118  sourcePins.push_back(pin);
119  elemPtr = *findElement(pin.getElementName());
120  sourceElements.push_back(elemPtr);
121  for(cnIt2 = elemPtr->connectionsBegin(); cnIt2 != elemPtr->connectionsEnd(); ++cnIt2){
122  if( (*cnIt2)->getSource()->getPinName() == pin.getPinName()){
123  sourceConnections.push_back(*cnIt2);
124  elemPtr->removeConnection(cnIt2);
125  break;
126  }
127  }
128  }
129  }
130  for(size_t i=0; i<sourcePins.size(); ++i){
131  for(size_t j=0; j<sinkPins.size(); ++j){
132  ConnectionSharedPtr connectionPtr(new Connection(sourcePins[i].getPinName()));
133  ConnectionSharedPtr connectionPtr1(new Connection(sourcePins[i].getPinName()));
134  connectionPtr->addConnectionPin(sourcePins[i]);
135  connectionPtr->addConnectionPin(sinkPins[j]);
136  sinkElements[j]->addConnection(connectionPtr);
137 
138  connectionPtr1->addConnectionPin(sourcePins[i]);
139  connectionPtr1->addConnectionPin(sinkPins[j]);
140  sourceElements[i]->addConnection(connectionPtr1);
141 
142  }
143  }
144  mElements.erase(result);
145 return true;
146 }
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer encapsulation of a element.
Definition: Element.hpp:119
std::vector< ConnectionSharedPtr > ConnectionSharedPtrVector
Vector of componenet shared pointers.
Definition: Connection.hpp:88
boost::shared_ptr< Connection > ConnectionSharedPtr
Shared pointer encapsulation of a componenet.
Definition: Connection.hpp:82
ElementSharedPtrIterator findElement(const string &inName)
Find a primitive element by name.
Definition: Primitive.hpp:61
ElementSharedPtrVector mElements
Vector of element shared pointers.
Definition: Primitive.hpp:45
std::vector< ElementSharedPtr > ElementSharedPtrVector
Vector of element shared pointers.
Definition: Element.hpp:125
ConnectionSharedPtrVector::iterator ConnectionSharedPtrIterator
Definition: Element.hpp:55
ConnectionPinVector::iterator ConnectionPinSharedPtrIterator
Definition: Connection.hpp:41
std::vector< ConnectionPin > ConnectionPinVector
Vector of connection pins.

+ Here is the call graph for this function:

bool torc::physical::Component::removePrimitivePin ( PrimitivePinSharedPtr inPrimitivePinPtr)
inlineinherited
Todo:
Acquire mutex.
Todo:
Release mutex.

Definition at line 57 of file Component.hpp.

57  {
58  /// \todo Acquire mutex.
60  PrimitivePinSharedPtrIterator result = std::find(PrimitivePinsBegin(), e, inPrimitivePinPtr);
61  if(result == e) return false;
62  mPrimitivePins.erase(result);
63  /// \todo Release mutex.
64  return true;
65  }
PrimitivePinSharedPtrVector::iterator PrimitivePinSharedPtrIterator
Definition: Component.hpp:40
PrimitivePinSharedPtrVector mPrimitivePins
Definition: Component.hpp:34
PrimitivePinSharedPtrConstIterator PrimitivePinsEnd(void) const
Definition: Component.hpp:44
PrimitivePinSharedPtrConstIterator PrimitivePinsBegin(void) const
Definition: Component.hpp:43

+ Here is the call graph for this function:

void torc::physical::Progeny< class Component >::resetParentWeakPtr ( void  )
inlineinherited

Method to reset and orphan this object.

Definition at line 51 of file Progeny.hpp.

51 { mParentWeakPtr.reset(); }
WeakPtrType mParentWeakPtr
Weak pointer to the parent.
Definition: Progeny.hpp:38
void torc::physical::Progeny< class Component >::setParentWeakPtr ( WeakPtrType  inParentPtr)
inlineinherited

Sets the weak pointer to the parent.

Definition at line 49 of file Progeny.hpp.

49 { mParentWeakPtr = inParentPtr; }
WeakPtrType mParentWeakPtr
Weak pointer to the parent.
Definition: Progeny.hpp:38
void torc::physical::Progenitor< class Component >::setSelfWeakPtr ( WeakPtrType  inSelfPtr)
inlineprotectedinherited

Sets the weak pointer to this object.

Definition at line 59 of file Progenitor.hpp.

59 { mSelfWeakPtr = inSelfPtr; }
WeakPtrType mSelfWeakPtr
Weak pointer this object.
Definition: Progenitor.hpp:57

Friends And Related Function Documentation

friend class RcFactory
friend

The Factory class has direct access to our internals.

Definition at line 37 of file Primitive.hpp.

Field Documentation

ElementSharedPtrVector torc::physical::Primitive::mElements
protected

Vector of element shared pointers.

Definition at line 45 of file Primitive.hpp.

string torc::physical::Named::mName
protectedinherited

The name of the object.

Definition at line 43 of file Named.hpp.

WeakPtrType torc::physical::Progeny< class Component >::mParentWeakPtr
protectedinherited

Weak pointer to the parent.

Definition at line 38 of file Progeny.hpp.

PrimitivePinSharedPtrVector torc::physical::Component::mPrimitivePins
protectedinherited

Definition at line 34 of file Component.hpp.

WeakPtrType torc::physical::Progenitor< class Component >::mSelfWeakPtr
protectedinherited

Weak pointer this object.

This weak pointer is kept here to be passed along to our children, allowing them to point back to us without the strong dependency of a shared pointer.

Definition at line 57 of file Progenitor.hpp.


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