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

An EDIF cell library. More...

#include <Library.hpp>

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

Data Structures

class  Factory
 

Public Types

typedef VisitorType< LibraryVisitor
 
typedef std::string Name
 
typedef Library Type
 
typedef boost::shared_ptr< TypePointer
 
typedef boost::weak_ptr< TypeWeakPointer
 

Public Member Functions

virtual void accept (BaseVisitor &inoutVisitor) throw (Error)
 
const EdifLevel getLevel () const
 
void setLevel (const EdifLevel &inSource)
 
const std::map< Unit, ScaleFactorgetScaleFactors () const
 
bool findScaleFactor (Unit inUnit, ScaleFactor &outResult) const
 
bool setScaleFactor (Unit inUnit, const ScaleFactor &inScale)
 
void addCell (const CellSharedPtr &inCell) throw (Error)
 
virtual CellSharedPtr findCell (const std::string &inName) throw (Error)
 
void removeCell (const std::string &inName) throw (Error)
 
virtual void getCells (std::vector< CellSharedPtr > &outCells)
 
template<typename _Action >
void applyOnAllCells (const _Action &action) throw (Error)
 
const SimulationInfoSharedPtr getSimulationInfo () const
 
void setSimulationInfo (const SimulationInfoSharedPtr &inSource)
 
virtual ~Library () throw ()
 
void addComment (const std::string &comment)
 
const std::vector< std::string > & getComments () const
 
void setComments (const std::vector< std::string > &inSource)
 
bool getIsExtern () const
 
bool isExtern () const
 
void setIsExtern (bool inIsExtern)
 
virtual const std::string getName () const
 
void setName (const std::string &inSource) throw (Error)
 
virtual Name getOriginalName () const
 
virtual void setOriginalName (const Name &inSource)
 
const boost::shared_ptr< RootgetParent () const
 
virtual void setParent (const boost::shared_ptr< Root > &inSource)
 
void setWeakThis (const WeakPointer &inWeakThis)
 
Pointer getSharedThis () const
 
void getUserData (std::list< std::string > &outUserData) const
 
void setUserData (const std::list< std::string > &inSource)
 
void addUserData (const std::string &inSource)
 
void getStatuses (std::vector< StatusSharedPtr > &outStatus) const
 
void setStatuses (const std::vector< StatusSharedPtr > &inStatus)
 
void addStatus (const StatusSharedPtr &inStatus) throw (Error)
 
template<typename _Action >
void applyOnAllStatuses (const _Action &action) throw (Error)
 

Protected Member Functions

 Library ()
 

Private Member Functions

 Library (const Library &)
 
Libraryoperator= (const Library &)
 

Private Attributes

SymTab< Unit, ScaleFactormScaleFactors
 
EdifLevel mLevel
 
SymTab< std::string,
CellSharedPtr
mCellSymTab
 
SimulationInfoSharedPtr mSimulationInfo
 

Friends

class FactoryType< Library >
 

Detailed Description

An EDIF cell library.

A Library object defines a collection of EDIF libraries

Definition at line 60 of file Library.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< Library >::Pointer
inherited

Definition at line 36 of file SelfReferencing.hpp.

Definition at line 35 of file SelfReferencing.hpp.

Convenience typedef for visiting a library

Definition at line 73 of file Library.hpp.

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

Definition at line 37 of file SelfReferencing.hpp.

Constructor & Destructor Documentation

torc::generic::Library::~Library ( )
throw (
)
virtual

Definition at line 247 of file Library.cpp.

247  {
248  log("Library destroyed \n");
249 }
void log(const char *fmt,...)
Definition: Log.cpp:89

+ Here is the call graph for this function:

torc::generic::Library::Library ( )
protected

Definition at line 243 of file Library.cpp.

244  ParentedObject<Root>(), SelfReferencing<Library>(), UserDataContainer(), StatusContainer(),
SymTab< std::string, CellSharedPtr > mCellSymTab
Definition: Library.hpp:293
SimulationInfoSharedPtr mSimulationInfo
Definition: Library.hpp:294
SymTab< Unit, ScaleFactor > mScaleFactors
Definition: Library.hpp:291
torc::generic::Library::Library ( const Library )
private

Member Function Documentation

void torc::generic::Library::accept ( BaseVisitor inoutVisitor)
throw (Error
)
virtual

Implements torc::generic::Visitable.

Definition at line 89 of file Library.cpp.

89  {
90  try {
91  runVisitor(*this, inoutVisitor);
92  } catch(Error& e) {
93  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
94  throw;
95  }
96 }
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
Definition: VisitorType.hpp:78

+ Here is the call graph for this function:

void torc::generic::Library::addCell ( const CellSharedPtr inCell)
throw (Error
)

Add a cell to the list of cells. If an empty pointer is supplied, it returns without doing anything. If an cell already exists in EDIF file in same library, parser ignores the cell.

Parameters
[in]inCellA pointer to a cell object.
Exceptions
ErrorCell could not be added, because Cell name is empty
  • Id : eMessageIdErrorEmptyItemName
  • Context Data
    • Cell name - String
ErrorCell could not be added, because Cell name is already exists
  • Id : eMessageIdErrorItemAlreadyExists
  • Context Data
    • Cell name - String

Add a cell to the list of cells. If an empty pointer is supplied, it returns without doing anything.

Parameters
[in]inCellA pointer to a cell object.
Exceptions
ErrorCell could not be added.

Definition at line 139 of file Library.cpp.

139  {
140  if(!inCell) {
141  return;
142  }
143  std::string cellName = inCell->getName();
144  if(cellName.empty()) {
145  Error e(eMessageIdErrorEmptyItemName, __FUNCTION__, __FILE__, __LINE__);
146  e.saveContextData("Cell name", cellName);
147  throw e;
148  }
149 #ifdef GENOM_SERIALIZATION
150  std::list<std::string>::iterator it = std::find(mDumpedCells.begin(), mDumpedCells.end(),
151  cellName);
152  if(it != mDumpedCells.end()) {
153  Error e(eMessageIdErrorItemAlreadyExists, __FUNCTION__, __FILE__, __LINE__);
154  e.saveContextData("Cell name", cellName);
155  throw e;
156  }
157 #endif //GENOM_SERIALIZATION
158  if(false == mCellSymTab.set(cellName, inCell)) {
159  Error e(eMessageIdErrorItemAlreadyExists, __FUNCTION__, __FILE__, __LINE__);
160  e.saveContextData("Cell name", cellName);
161  throw e;
162  }
163  inCell->setParent(getSharedThis());
164 }
bool set(const KeyType &inKey, const ValueType &inValue)
Definition: SymTab.hpp:132
std::string string
SymTab< std::string, CellSharedPtr > mCellSymTab
Definition: Library.hpp:293

+ Here is the call 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::StatusContainer::addStatus ( const StatusSharedPtr inStatus)
throw (Error
)
inherited

Add a status to the vector of statuses. If an empty pointer is supplied, it returns without doing anything.

Parameters
[in]inStatusA pointer to a status object.
Exceptions
ErrorStatus could not be added.

Add a status to the list of statuses. If an empty pointer is supplied, it returns without doing anything.

Parameters
[in]inStatusA pointer to a status object.
Exceptions
ErrorStatus could not be added.

Definition at line 47 of file StatusContainer.cpp.

47  {
48  mStatuses.push_back(inStatus);
49 }
std::vector< StatusSharedPtr > mStatuses
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::Library::applyOnAllCells ( const _Action &  action)
throw (Error
)
inline

Apply action on all Cells.

Parameters
[in]actionAction to be applied
Note
If some cells are yet to be restored, this method is not thread safe. For non-serializable mode this is thread safe. For dump mode derived classes can write an appropriate thread safe wrapper method that can be accesed using visitors. However, using this method in dump mode should be avoided unless under dire situations, as it will lead to restoration of all cells under the library.

Apply action on all Cells.

Parameters
[in]actionAction to be applied

Definition at line 325 of file Library.hpp.

326  {
327  try {
328 #ifdef GENOM_SERIALIZATION
329  restoreAllCells();
330 #endif //GENOM_SERIALIZATION
331  mCellSymTab.applyOnAll(action);
332  } catch(Error& e) {
333  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
334  throw;
335  }
336 }
void applyOnAll(const _Action &action)
Definition: SymTab.hpp:192
SymTab< std::string, CellSharedPtr > mCellSymTab
Definition: Library.hpp:293

+ Here is the call graph for this function:

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

Apply action on all statuses.

Parameters
[in]actionAction to be applied

Definition at line 95 of file StatusContainer.hpp.

96  {
97  try {
98  std::vector<StatusSharedPtr>::iterator it = mStatuses.begin();
99  for(; it != mStatuses.end(); ++it) {
100  action(*it);
101  }
102  } catch(Error& e) {
103  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
104  throw;
105  }
106 }
std::vector< StatusSharedPtr > mStatuses

+ Here is the call graph for this function:

CellSharedPtr torc::generic::Library::findCell ( const std::string &  inName)
throw (Error
)
virtual

Find a cell by name, in the list of cells.

Parameters
[in]inNameString inSource specifying the name of the cell.
Returns
A pointer to the cell if found, an empty pointer otherwise.
Exceptions
ErrorCell could not be found, because Cell name is empty
  • Id : eMessageIdErrorEmptyItemName
  • Context Data
    • Cell name - String
Note
If some cells are yet to be restored, this method is not thread safe. For non-serializable mode this is thread safe. For dump mode derived classes can override this to make it thread safe by placing appropriate locks.

Find a cell by name, in the list of cells.

Parameters
[in]inNameString inSource specifying the name of the cell.
Returns
A pointer to the cell if found, an empty pointer otherwise.

Definition at line 173 of file Library.cpp.

173  {
174  if(inName.empty()) {
175  Error e(eMessageIdErrorEmptyItemName, __FUNCTION__, __FILE__, __LINE__);
176  e.saveContextData("Cell name", inName);
177  throw e;
178  }
179  CellSharedPtr cell;
180  mCellSymTab.get(inName, cell);
181 #ifdef GENOM_SERIALIZATION
182  if(!cell && !mDumpedCells.empty()) {
183  cell = restoreSingleCell(inName);
184  }
185 #endif //GENOM_SERIALIZATION
186  return cell;
187 }
SymTab< std::string, CellSharedPtr > mCellSymTab
Definition: Library.hpp:293
bool get(const KeyType &inKey, ValueType &outValue) const
Definition: SymTab.hpp:121
boost::shared_ptr< Cell > CellSharedPtr

+ Here is the call graph for this function:

bool torc::generic::Library::findScaleFactor ( Unit  inUnit,
ScaleFactor outResult 
) const

Find a scale factor for the given unit.

Parameters
[in]inUnitUnits for which scale factor is to be found.
[out]outResultThe scale factor if found.
Returns
true if found, false otherwise

Definition at line 117 of file Library.cpp.

117  {
118  return mScaleFactors.get(inUnit, outResult);
119 }
SymTab< Unit, ScaleFactor > mScaleFactors
Definition: Library.hpp:291
void torc::generic::Library::getCells ( std::vector< CellSharedPtr > &  outCells)
virtual

Get the list of cells. The list of cells is appended to the provided list

Parameters
[out]outCellsList of cells to be populated
Returns
List of cells in the library.
Note
If some cells are yet to be restored, this method is not thread safe. For non-serializable mode this is thread safe. For dump mode derived classes can override this to make it thread safe by placing appropriate locks. In dump mode using this method will lead to restoration of all children.

Get the list of cells.

Returns
List of cells in the library.

Definition at line 227 of file Library.cpp.

227  {
228 #ifdef GENOM_SERIALIZATION
229  restoreAllCells();
230 #endif //GENOM_SERIALIZATION
231  mCellSymTab.getValues(outCells);
232 }
void getValues(std::vector< ValueType > &outValues) const
Definition: SymTab.hpp:158
SymTab< std::string, CellSharedPtr > mCellSymTab
Definition: Library.hpp:293

+ Here is the call 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
bool torc::generic::Extern::getIsExtern ( ) const
inlineinherited

Get whether the item is an extern(placeholder) or an actual item.

Returns
True if extern, false otherwise

Definition at line 86 of file Extern.hpp.

86  {
87  return mIsExtern;
88 }
const EdifLevel torc::generic::Library::getLevel ( ) const
inline

The the level of EDIF file.

Returns
The EDIF level for this file

Definition at line 305 of file Library.hpp.

305  {
306  return mLevel;
307 }
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<Root > torc::generic::ParentedObject< Root >::getParent ( ) const
inlineinherited

Get a pointer to the parent object

Returns
Pointer to parent
const std::map< Unit, ScaleFactor > torc::generic::Library::getScaleFactors ( ) const
inline

Get scale factors for different units in the library.

Returns
Scale factors

Definition at line 314 of file Library.hpp.

314  {
315  std::map<Unit, ScaleFactor> temp;
316  mScaleFactors.getValueMap(temp);
317  return temp;
318 }
SymTab< Unit, ScaleFactor > mScaleFactors
Definition: Library.hpp:291
Pointer torc::generic::SelfReferencing< Library >::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
const SimulationInfoSharedPtr torc::generic::Library::getSimulationInfo ( ) const
inline

Get the pointer to the simulation info.

Returns
Pointer to the simulation info

Definition at line 343 of file Library.hpp.

343  {
344  return mSimulationInfo;
345 }
SimulationInfoSharedPtr mSimulationInfo
Definition: Library.hpp:294
void torc::generic::StatusContainer::getStatuses ( std::vector< StatusSharedPtr > &  outStatus) const
inlineinherited

Get a vector of pointer to Status object

Parameters
[out]outStatusThe vector of pointer to Status object

Definition at line 86 of file StatusContainer.hpp.

86  {
87  outStatus.insert(outStatus.end(), mStatuses.begin(), mStatuses.end());
88 }
std::vector< StatusSharedPtr > mStatuses
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
bool torc::generic::Extern::isExtern ( ) const
inlineinherited

Get whether the item is an extern(placeholder) or an actual item.

Returns
True if extern, false otherwise

Definition at line 95 of file Extern.hpp.

95  {
96  return mIsExtern;
97 }
Library& torc::generic::Library::operator= ( const Library )
private
void torc::generic::Library::removeCell ( const std::string &  inName)
throw (Error
)

Remove the specified cell from the list of cells. If an empty pointer is passed, it returns without doing anything

Parameters
inNameName of the object to be delete
Exceptions
ErrorCell name is empty
  • Id : eMessageIdErrorEmptyItemName
  • Context Data
    • Cell name - String
ErrorCell name not preset in collection.
  • Id : eMessageIdErrorItemNotFound
  • Context Data
    • Cell name - String

Remove the specified cell from the list of cells. If an empty pointer is passed, it returns without doing anything

Parameters
inCellPointer to a cell object.
Exceptions
ErrorCell name is empty
ErrorCell name not preset in collection.

Definition at line 197 of file Library.cpp.

197  {
198  if(inName.empty()) {
199  Error e(eMessageIdErrorEmptyItemName, __FUNCTION__, __FILE__, __LINE__);
200  e.saveContextData("Cell name", inName);
201  throw e;
202  }
203 
204 #ifdef GENOM_SERIALIZATION
205  std::list<std::string>::iterator it = std::find(mDumpedCells.begin(), mDumpedCells.end(),
206  inName);
207  if(it == mDumpedCells.end()) {
208  Error e(eMessageIdErrorItemNotFound, __FUNCTION__, __FILE__, __LINE__);
209  e.saveContextData("Cell name", inName);
210  throw e;
211  } else {
212  mDumpedCells.erase(it);
213  }
214 #endif //GENOM_SERIALIZATION
215  if(false == mCellSymTab.remove(inName)) {
216  Error e(eMessageIdErrorItemNotFound, __FUNCTION__, __FILE__, __LINE__);
217  e.saveContextData("Cell name", inName);
218  throw e;
219  }
220 }
bool remove(const KeyType &inKey)
Definition: SymTab.hpp:153
SymTab< std::string, CellSharedPtr > mCellSymTab
Definition: Library.hpp:293

+ 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::Extern::setIsExtern ( bool  inIsExtern)
inherited

Set whether an item is extern or not.

Parameters
[in]isExternTrue if extern, false otherwise

Definition at line 35 of file Extern.cpp.

35  {
36  mIsExtern = inIsExtern;
37 }
void torc::generic::Library::setLevel ( const EdifLevel inSource)

Set the EDIF level.

Note
Current parser supports LEVEL_1 edif only.
Parameters
[in]inSourceEdifLevel object

Definition at line 105 of file Library.cpp.

105  {
106  mLevel = inSource;
107 }
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< Root >::setParent ( const boost::shared_ptr< Root > &  inSource)
virtualinherited

Set a pointer to the parent

Parameters
[in]inSourceSet a pointer to the parent
bool torc::generic::Library::setScaleFactor ( Unit  inUnit,
const ScaleFactor inScale 
)

Set a scale factor for the given unit.

Parameters
[in]inUnitUnits for which scale factor is to be set.
[out]inScaleThe scale factor to store.
Returns
True if set

Set a scale factor for the given unit.

Parameters
[in]inUnitUnits for which scale factor is to be set.
[out]inScaleThe scale factor to store.

Definition at line 128 of file Library.cpp.

128  {
129  return mScaleFactors.set(inUnit, inScale);
130 }
SymTab< Unit, ScaleFactor > mScaleFactors
Definition: Library.hpp:291
void torc::generic::Library::setSimulationInfo ( const SimulationInfoSharedPtr inSource)

Set the pointer to the simulation info.

Parameters
[in]inSourcePointer to the simulation info

Definition at line 239 of file Library.cpp.

239  {
240  mSimulationInfo = inSource;
241 }
SimulationInfoSharedPtr mSimulationInfo
Definition: Library.hpp:294
void torc::generic::StatusContainer::setStatuses ( const std::vector< StatusSharedPtr > &  inStatus)
inherited

Set a vector of pointer to Status object

Parameters
[in]inStatusThe vector of pointer to Status object

Definition at line 32 of file StatusContainer.cpp.

32  {
33  std::vector<StatusSharedPtr>::const_iterator it = inStatus.begin();
34  for(; it != inStatus.end(); it++) {
35  mStatuses.push_back(*it);
36  }
37 }
std::vector< StatusSharedPtr > mStatuses
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< Library >::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< Library >
friend

Definition at line 67 of file Library.hpp.

Field Documentation

SymTab<std::string, CellSharedPtr> torc::generic::Library::mCellSymTab
private

Definition at line 293 of file Library.hpp.

EdifLevel torc::generic::Library::mLevel
private

Definition at line 292 of file Library.hpp.

SymTab<Unit, ScaleFactor> torc::generic::Library::mScaleFactors
private

Definition at line 291 of file Library.hpp.

SimulationInfoSharedPtr torc::generic::Library::mSimulationInfo
private

Definition at line 294 of file Library.hpp.


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