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

Represents different logic elements which holds array of logic values. More...

#include <LogicElement.hpp>

+ Inheritance diagram for torc::generic::LogicElement:
+ Collaboration diagram for torc::generic::LogicElement:

Data Structures

class  Factory
 

Public Types

enum  Type {
  eTypeSingle = 0, eTypeList, eTypeOneOf, eTypeWaveForm,
  eTypeIgnored, eTypeTransition, eTypeBecomes
}
 
enum  RelationType { eRelationTypeParent = 0, eRelationTypeChild }
 
typedef VisitorType< LogicElementVisitor
 
typedef std::string Name
 
typedef boost::shared_ptr< TypePointer
 
typedef boost::weak_ptr< TypeWeakPointer
 

Public Member Functions

virtual void accept (BaseVisitor &visitor) throw (Error)
 Receive a visitor to this class. The visit method of the visitor is called and a reference to this object is passed as a parameter. It has to be noted however, that a dynamic_cast is performed inside this method. If the cast fails, an appropriate exception is thrown by this method. This situation can arise when the passed Visitor object does not inherit from the appropriate visitor specialization. See Visitor documentation for more details. More...
 
const Type getType () const
 
void setType (const Type &inSource)
 
void getChildren (std::vector< LogicElementSharedPtr > &outLogicElements) const
 
void setChildren (const std::vector< LogicElementSharedPtr > &inSource)
 
bool addChildLogicElement (const LogicElementSharedPtr &inChildLogicElement)
 
template<typename _Action >
void applyOnAllChildren (const _Action &action) throw (Error)
 
const RelationType getRelationType () const
 
void setRelationType (const RelationType &inSource)
 
size_t getSize () const
 
 ~LogicElement () throw ()
 
const LogicValueAttributesSharedPtr getAttributes () const
 
void setAttributes (const LogicValueAttributesSharedPtr &inSource)
 
virtual const std::string getName () const
 
void setName (const std::string &inSource) throw (Error)
 
virtual Name getOriginalName () const
 
virtual void setOriginalName (const Name &inSource)
 
void addComment (const std::string &comment)
 
const std::vector< std::string > & getComments () const
 
void setComments (const std::vector< std::string > &inSource)
 
const boost::shared_ptr
< SimulationInfo
getParent () const
 
virtual void setParent (const boost::shared_ptr< SimulationInfo > &inSource)
 
PropertySharedPtr getProperty (const std::string &inName)
 
bool setProperty (const std::string &inName, const PropertySharedPtr &inProperty)
 
void getProperties (std::map< std::string, PropertySharedPtr > &outProperties) const
 
void setProperties (const std::map< std::string, PropertySharedPtr > &inSource)
 
template<typename _Action >
void applyOnAllProperties (const _Action &action) throw (Error)
 
void getUserData (std::list< std::string > &outUserData) const
 
void setUserData (const std::list< std::string > &inSource)
 
void addUserData (const std::string &inSource)
 
void setWeakThis (const WeakPointer &inWeakThis)
 
Pointer getSharedThis () const
 

Protected Member Functions

 LogicElement ()
 

Private Attributes

Type mType
 
RelationType mRelationType
 
std::vector
< LogicElementSharedPtr
mChildren
 

Friends

class FactoryType< LogicElement >
 

Detailed Description

Represents different logic elements which holds array of logic values.

The LogicElement class is used to represent different logic elements constructs in EDIF like logicWaveForm, logicOneOf, logicList, transition, becomes, ignore and logic value name.

Definition at line 41 of file LogicElement.hpp.

Member Typedef Documentation

typedef std::string torc::generic::Renamable::Name
inherited

Definition at line 40 of file generic/Renamable.hpp.

typedef boost::shared_ptr<Type> torc::generic::SelfReferencing< LogicValue >::Pointer
inherited

Definition at line 36 of file SelfReferencing.hpp.

Convenience class to visit a logic element.

Definition at line 67 of file LogicElement.hpp.

typedef boost::weak_ptr<Type> torc::generic::SelfReferencing< LogicValue >::WeakPointer
inherited

Definition at line 37 of file SelfReferencing.hpp.

Member Enumeration Documentation

Relation type of the logic elements, is it parent or child.

Enumerator
eRelationTypeParent 
eRelationTypeChild 

Definition at line 60 of file LogicElement.hpp.

Constructor & Destructor Documentation

torc::generic::LogicElement::~LogicElement ( )
throw (
)

Definition at line 171 of file LogicElement.cpp.

171 {}
torc::generic::LogicElement::LogicElement ( )
protected

Definition at line 169 of file LogicElement.cpp.

Member Function Documentation

void torc::generic::LogicElement::accept ( BaseVisitor visitor)
throw (Error
)
virtual

Receive a visitor to this class. The visit method of the visitor is called and a reference to this object is passed as a parameter. It has to be noted however, that a dynamic_cast is performed inside this method. If the cast fails, an appropriate exception is thrown by this method. This situation can arise when the passed Visitor object does not inherit from the appropriate visitor specialization. See Visitor documentation for more details.

Parameters
[in,out]visitorA reference to the visitor object
Exceptions
ErrorVisitor type inappropriate for visiting this object or any other error thrown by the Visitor::throw() method.

Reimplemented from torc::generic::LogicValue.

Definition at line 98 of file LogicElement.cpp.

98  {
99  try {
100  runVisitor(*this, visitor);
101  } catch(Error& e) {
102  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
103  throw;
104  }
105 }
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
Definition: VisitorType.hpp:78

+ Here is the call graph for this function:

bool torc::generic::LogicElement::addChildLogicElement ( const LogicElementSharedPtr inChildLogicElement)

Add a logic element to parent logic element

Parameters
[in]inChildLogicElementChild logic element to be added to parent

Definition at line 86 of file LogicElement.cpp.

86  {
87  if(!inChildLogicElement) {
88  Error e(eMessageIdErrorPointerToItemDoesNotExist, __FUNCTION__, __FILE__, __LINE__);
89  e.saveContextData("Pointer to the logic element object does not exist",
90  inChildLogicElement);
91  throw e;
92  } else {
93  mChildren.push_back(inChildLogicElement);
94  return true;
95  }
96 }
std::vector< LogicElementSharedPtr > mChildren

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::generic::Commentable::addComment ( const std::string &  comment)
inherited

Add a comment to the object

Parameters
[in]commentThe comment to add to an existing list of comments

Definition at line 36 of file Commentable.cpp.

36  {
37  mComments.push_back(comment);
38 }
std::vector< std::string > mComments
Definition: Commentable.hpp:77
void torc::generic::UserDataContainer::addUserData ( const std::string &  inSource)
inherited

Add an user data to the list of user data

Parameters
[in]inSourceAn user data as string

Definition at line 34 of file UserDataContainer.cpp.

34  {
35  mUserData.push_back(inSource);
36 }
std::list< std::string > mUserData
template<typename _Action >
void torc::generic::LogicElement::applyOnAllChildren ( const _Action &  action)
throw (Error
)
inline

Apply action on all children

Parameters
[in]actionAction to be applied

Definition at line 204 of file LogicElement.hpp.

205  {
206  try {
207  std::vector<LogicElementSharedPtr>::iterator it = mChildren.begin();
208  for(; it != mChildren.end(); ++it) {
209  action(*it);
210  }
211  } catch(Error& e) {
212  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
213  throw;
214  }
215 }
std::vector< LogicElementSharedPtr > mChildren

+ Here is the call graph for this function:

template<typename _Action >
void torc::generic::PropertyContainer::applyOnAllProperties ( const _Action &  action)
throw (Error
)
inlineinherited

Apply action on all properties.

Parameters
[in]actionAction to be applied

Definition at line 113 of file PropertyContainer.hpp.

114  {
115  try {
116  mProperties.applyOnAll(action);
117  } catch(Error& e) {
118  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
119  throw;
120  }
121 }
void applyOnAll(const _Action &action)
Definition: SymTab.hpp:192
SymTab< std::string, PropertySharedPtr > mProperties

+ Here is the call graph for this function:

const LogicValueAttributesSharedPtr torc::generic::LogicValue::getAttributes ( ) const
inlineinherited

Get the attributes of the LogicValue. Attributes include voltageMap, currentMap, booleanMap, compound, weak, strong, dominates etc.

Returns
Pointer to LogicValueAttributes object.

Definition at line 125 of file LogicValue.hpp.

125  {
126  return mAttributes;
127 }
LogicValueAttributesSharedPtr mAttributes
Definition: LogicValue.hpp:115
void torc::generic::LogicElement::getChildren ( std::vector< LogicElementSharedPtr > &  outLogicElements) const
inline

Get the nested logic elements.

Parameters
[out]outLogicElementsVector of logic element to be appended to

Definition at line 196 of file LogicElement.hpp.

196  {
197  outLogicElements.insert(outLogicElements.end(), mChildren.begin(), mChildren.end());
198 }
std::vector< LogicElementSharedPtr > mChildren

+ Here is the caller graph for this function:

const std::vector< std::string > & torc::generic::Commentable::getComments ( ) const
inlineinherited

Get the list of all comments

Returns
A list of all comments on this object

Definition at line 85 of file Commentable.hpp.

85  {
86  return mComments;
87 }
std::vector< std::string > mComments
Definition: Commentable.hpp:77
const std::string torc::generic::Nameable::getName ( void  ) const
inlinevirtualinherited

Get the object name

Returns
Name of the object

Definition at line 89 of file Nameable.hpp.

89  {
90  return mName;
91 }

+ Here is the caller graph for this function:

Renamable::Name torc::generic::Renamable::getOriginalName ( ) const
inlinevirtualinherited

Get the new name provided for the object.

Returns
Name of the object

Definition at line 78 of file generic/Renamable.hpp.

78  {
79  return mOriginalName;
80 }

+ Here is the caller graph for this function:

const boost::shared_ptr<SimulationInfo > torc::generic::ParentedObject< SimulationInfo >::getParent ( ) const
inlineinherited

Get a pointer to the parent object

Returns
Pointer to parent
void torc::generic::PropertyContainer::getProperties ( std::map< std::string, PropertySharedPtr > &  outProperties) const
inlineinherited

Get the map of all properties

Parameters
[out]outPropertiesThe map of properties

Get the map of all properties

Returns
The map of properties

Definition at line 107 of file PropertyContainer.hpp.

108  {
109  mProperties.getValueMap(outProperties);
110  return;
111 }
void getValueMap(UserMap &outMap) const
Definition: SymTab.hpp:171
SymTab< std::string, PropertySharedPtr > mProperties

+ Here is the call graph for this function:

PropertySharedPtr torc::generic::PropertyContainer::getProperty ( const std::string &  inName)
inherited

Get a property

Parameters
[in]inNameName of the property to be retreived
Returns
Pointer to the property object if present, empty pointer otherwise.

Get a property

Parameters
[in]nameName of the property to be retreived
Returns
Pointer to the property object if present, empty pointer otherwise.

Definition at line 37 of file PropertyContainer.cpp.

37  {
38  PropertySharedPtr property;
39  if(!inName.empty()) {
40  mProperties.get(inName, property);
41  }
42  return property;
43 }
bool get(const KeyType &inKey, ValueType &outValue) const
Definition: SymTab.hpp:121
SymTab< std::string, PropertySharedPtr > mProperties
boost::shared_ptr< Property > PropertySharedPtr

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const LogicElement::RelationType torc::generic::LogicElement::getRelationType ( ) const
inline

Get the relation type.

Returns
RelationType

Definition at line 222 of file LogicElement.hpp.

222  {
223  return mRelationType;
224 }

+ Here is the caller graph for this function:

Pointer torc::generic::SelfReferencing< LogicValue >::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
size_t torc::generic::LogicElement::getSize ( void  ) const

Get the total number of bits of the composition

Returns
Number of bits

Definition at line 120 of file LogicElement.cpp.

120  {
121  size_t size = 0;
122  size_t pSize = 0;
123  size_t cSize = 0;
125 
126  std::vector<LogicElementSharedPtr> outLogicElements;
127  getChildren(outLogicElements);
128 
129  std::vector<LogicElementSharedPtr>::iterator logicElemIt = outLogicElements.begin();
131  return 1;
132  }
133 
135  if(!outLogicElements.empty()) {
136  size += (*logicElemIt)->getSize();
137  } else {
138  size = 0;
139  }
140  return size;
141  }
142 
144  if(!outLogicElements.empty()) {
145  size += (*logicElemIt)->getSize();
146  } else {
147  size = 0;
148  }
149  return size;
150  }
151 
152  if(LogicElement::eRelationTypeParent == rType) {
153  if(!outLogicElements.empty()) {
154  pSize += (*logicElemIt)->getSize();
155  } else {
156  pSize = 0;
157  }
158  } else {
159  if(!outLogicElements.empty()) {
160  for(; logicElemIt != outLogicElements.end(); logicElemIt++) {
161  cSize += (*logicElemIt)->getSize();
162  }
163  }
164  }
165  size = pSize + cSize;
166  return size;
167 }
const RelationType getRelationType() const
void getChildren(std::vector< LogicElementSharedPtr > &outLogicElements) const
const Type getType() const

+ Here is the call graph for this function:

const LogicElement::Type torc::generic::LogicElement::getType ( void  ) const
inline

Get the Logic element type

Returns
Logic element type

Definition at line 187 of file LogicElement.hpp.

187  {
188  return mType;
189 }

+ Here is the caller graph for this function:

void torc::generic::UserDataContainer::getUserData ( std::list< std::string > &  outUserData) const
inlineinherited

Get the list of all userData

Parameters
[out]outUserDataThe list of all userData

Definition at line 78 of file UserDataContainer.hpp.

78  {
79  outUserData.insert(outUserData.end(), mUserData.begin(), mUserData.end());
80  return;
81 }
std::list< std::string > mUserData
void torc::generic::LogicValue::setAttributes ( const LogicValueAttributesSharedPtr inSource)
inherited

Set the attributes of the LogicValue. Attributes include voltageMap, currentMap, booleanMap, compound, weak, strong, dominates etc.

Parameters
[in]inSourcePointer to LogicValueAttributes object.

Definition at line 59 of file LogicValue.cpp.

59  {
60  mAttributes = inSource;
61 }
LogicValueAttributesSharedPtr mAttributes
Definition: LogicValue.hpp:115
void torc::generic::LogicElement::setChildren ( const std::vector< LogicElementSharedPtr > &  inSource)

Set the nested logic elements.

Parameters
[in]inSourceVector containing logic elements.
Exceptions
ErrorCould not add child logic elements because pointer to the logic elements does not exist

Definition at line 68 of file LogicElement.cpp.

68  {
69  std::vector<LogicElementSharedPtr>::const_iterator entry = inSource.begin();
70  std::vector<LogicElementSharedPtr>::const_iterator end = inSource.end();
71  for(; entry != end; ++entry) {
72  try {
73  addChildLogicElement(*entry);
74  } catch(Error& e) {
75  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
76  throw;
77  }
78  }
79 }
bool addChildLogicElement(const LogicElementSharedPtr &inChildLogicElement)

+ Here is the call graph for this function:

void torc::generic::Commentable::setComments ( const std::vector< std::string > &  inSource)
inherited

Get the list of all comments

Parameters
[in]inSourceA list of all comments to be set on this object

Definition at line 45 of file Commentable.cpp.

45  {
46  mComments.insert(mComments.end(), inSource.begin(), inSource.end());
47 }
std::vector< std::string > mComments
Definition: Commentable.hpp:77
void torc::generic::Nameable::setName ( const std::string &  inSource)
throw (Error
)
inherited

Set a name for this object

Parameters
[in]inSourceName of the object
Exceptions
ErrorCould not set name, because name is empty (Will be used by array members)
  • Id : eMessageIdErrorEmptyItemName
  • Context Data

Set a name for this object

Parameters
[in]inSourceName of the object
Exceptions
ErrorCould not set name, because name is empty (Will be used by array members)

Definition at line 41 of file Nameable.cpp.

41  {
42  if(inSource.empty()) {
43  Error e(eMessageIdErrorEmptyItemName, __FUNCTION__, __FILE__, __LINE__);
44  e.saveContextData("Nameable", inSource);
45  throw e;
46  }
47  mName = inSource;
48 }

+ Here is the call graph for this function:

void torc::generic::Renamable::setOriginalName ( const Name inSource)
virtualinherited

Set the new name provided for the object.

Parameters
[in]inSourceName of the object

Definition at line 35 of file generic/Renamable.cpp.

35  {
36  mOriginalName = inSource;
37 }
virtual void torc::generic::ParentedObject< SimulationInfo >::setParent ( const boost::shared_ptr< SimulationInfo > &  inSource)
virtualinherited

Set a pointer to the parent

Parameters
[in]inSourceSet a pointer to the parent
void torc::generic::PropertyContainer::setProperties ( const std::map< std::string, PropertySharedPtr > &  inSource)
inherited

Set the map of properties

Parameters
[in]inSourceThe map of properties

Definition at line 66 of file PropertyContainer.cpp.

66  {
67  std::map<std::string, PropertySharedPtr>::const_iterator it = inSource.begin();
68  for(; it != inSource.end(); it++) {
69  setProperty((*it).first, (*it).second);
70  }
71 }
bool setProperty(const std::string &inName, const PropertySharedPtr &inProperty)

+ Here is the call graph for this function:

bool torc::generic::PropertyContainer::setProperty ( const std::string &  inName,
const PropertySharedPtr inProperty 
)
inherited

Save the inSource of a property

Parameters
[in]inNameName of the property to be saved
[in]inPropertyPointer to the property object if present, empty pointer otherwise.
Returns
bool True if saved, false otherwise.

Save the inSource of a property

Parameters
[in]inNameName of the property to be saved
[in]inPopertyPointer to the property object if present, empty pointer otherwise.
Returns
bool True if saved, false otherwise.

Definition at line 53 of file PropertyContainer.cpp.

54  {
55  if(!inName.empty()) {
56  return mProperties.set(inName, inProperty);
57  }
58  return false;
59 }
bool set(const KeyType &inKey, const ValueType &inValue)
Definition: SymTab.hpp:132
SymTab< std::string, PropertySharedPtr > mProperties

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::generic::LogicElement::setRelationType ( const RelationType inSource)

Set the relation type.

Parameters
[in]inSourceRelationType

Definition at line 112 of file LogicElement.cpp.

112  {
113  mRelationType = inSource;
114 }
void torc::generic::LogicElement::setType ( const Type inSource)

Set the Logic element type

Parameters
[in]inSourceLogic element type

Definition at line 57 of file LogicElement.cpp.

57  {
58  mType = inSource;
59 }
void torc::generic::UserDataContainer::setUserData ( const std::list< std::string > &  inSource)
inherited

Set the list of userData

Parameters
[in]inSourceThe list of UserData

Definition at line 26 of file UserDataContainer.cpp.

26  {
27  mUserData.insert(mUserData.end(), inSource.begin(), inSource.end());
28 }
std::list< std::string > mUserData
void torc::generic::SelfReferencing< LogicValue >::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

Friends And Related Function Documentation

friend class FactoryType< LogicElement >
friend

Definition at line 43 of file LogicElement.hpp.

Field Documentation

std::vector<LogicElementSharedPtr> torc::generic::LogicElement::mChildren
private

Definition at line 178 of file LogicElement.hpp.

RelationType torc::generic::LogicElement::mRelationType
private

Definition at line 177 of file LogicElement.hpp.

Type torc::generic::LogicElement::mType
private

Definition at line 176 of file LogicElement.hpp.


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