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

Represents a repository of unresolved usage references. More...

#include <Linker.hpp>

+ Collaboration diagram for torc::generic::Linker:

Data Structures

class  NameSpec
 
class  UnresolvedInstances
 

Public Types

typedef boost::shared_ptr
< UnresolvedInstances
UnresolvedInstancesPtr
 
typedef SymTab< NameSpec,
UnresolvedInstancesPtr
UnresolvedInfoMap
 

Public Member Functions

ViewSharedPtr findExternView (const NameSpec &inNameSpec)
 
void setExternView (const NameSpec &inNameSpec, const ViewSharedPtr &inExternView)
 
bool findUnresolvedInstances (const NameSpec &inNameSpec, UnresolvedInstancesPtr &outInstances) throw (Error)
 
void registerUnresolvedInstance (const NameSpec &inNameSpec, const InstanceSharedPtr &inInstance) throw (Error)
 
void removeUnresolvedInstances (const NameSpec &inNameSpec) throw (Error)
 
void linkUnresolved (const NameSpec &inNameSpec, ViewSharedPtr &inView) throw (Error)
 
 Linker (const RootSharedPtr &root)
 
 ~Linker () throw ()
 
 Linker (const Linker &source)
 
Linkeroperator= (const Linker &inSource)
 

Private Attributes

RootSharedPtr mRoot
 
UnresolvedInfoMap mInfos
 

Detailed Description

Represents a repository of unresolved usage references.

The Linker class represents a repository of unresolved instances, that is instances that are yet to to be linked to concrete views. When an instance is created by the parser, it tries to find a concrete view using the name specification present in the EDIF file. If no such references were found, the instance is attached to a Extern view, that is a view that is only a place holder. As newer cells are discovered by the parser, the unresolved instances are linked to the concrete views and removed from the linker.

Note
This class is typically used by EdifParser.

Definition at line 51 of file Linker.hpp.

Member Typedef Documentation

Definition at line 131 of file Linker.hpp.

Constructor & Destructor Documentation

torc::generic::Linker::Linker ( const RootSharedPtr inRoot)

Constructor

Parameters
[in]rootRoot of the OM.

Definition at line 256 of file Linker.cpp.

257  :mRoot(inRoot),
258  mInfos() {}
RootSharedPtr mRoot
Definition: Linker.hpp:207
UnresolvedInfoMap mInfos
Definition: Linker.hpp:208
torc::generic::Linker::~Linker ( )
throw (
)

Definition at line 260 of file Linker.cpp.

260 {}
torc::generic::Linker::Linker ( const Linker source)

Definition at line 262 of file Linker.cpp.

263  : mRoot(inSource.mRoot),
264  mInfos(inSource.mInfos) {}
RootSharedPtr mRoot
Definition: Linker.hpp:207
UnresolvedInfoMap mInfos
Definition: Linker.hpp:208

Member Function Documentation

ViewSharedPtr torc::generic::Linker::findExternView ( const NameSpec inNameSpec)

Find the extern View if already present.

Parameters
[in]inNameSpecName of the view
Returns
Extern view

Find the extern View if already present. Otherwise null

Parameters
[in]inNameSpecName of the view
Returns
Extern view

Definition at line 149 of file Linker.cpp.

150  {
152  mInfos.get(inNameSpec, info);
153  if(info)
154  {
155  return info->getExternView();
156  }
157  return ViewSharedPtr();
158 }
bool get(const KeyType &inKey, ValueType &outValue) const
Definition: SymTab.hpp:121
boost::shared_ptr< View > ViewSharedPtr
boost::shared_ptr< UnresolvedInstances > UnresolvedInstancesPtr
Definition: Linker.hpp:131
UnresolvedInfoMap mInfos
Definition: Linker.hpp:208

+ Here is the call graph for this function:

bool torc::generic::Linker::findUnresolvedInstances ( const NameSpec inNameSpec,
Linker::UnresolvedInstancesPtr outInstances 
)
throw (Error
)

Find the list of instances that are waiting for a view with the specified name.

Parameters
[in]inNameSpecName of the view to be linked with.
[out]outInstancesPointer to unresolved object
Returns
True if any such instances exist

Find the list of instances that are waiting for a view with the specified name.

Parameters
[in]inNameSpecName of the view to be linked with.
[out]outInstancesPointer to unresolved object
Returns
True if such instance exists

Definition at line 190 of file Linker.cpp.

192  {
193  return mInfos.get(inNameSpec, outInstances);
194 }
bool get(const KeyType &inKey, ValueType &outValue) const
Definition: SymTab.hpp:121
UnresolvedInfoMap mInfos
Definition: Linker.hpp:208

+ Here is the call graph for this function:

void torc::generic::Linker::linkUnresolved ( const NameSpec inNameSpec,
ViewSharedPtr inView 
)
throw (Error
)

Resolves all unlinked references for the given namespec to the given view

Parameters
[in]inNameSpecName specification for unresolved view
[in]inViewView to be bound to

Definition at line 231 of file Linker.cpp.

232  {
234  mInfos.get(inNameSpec, info);
235  LinkAction linkAction(inView);
236  if(info)
237  {
238  try
239  {
240  info->applyActionOnInstances(linkAction);
241  }
242  catch(Error& e)
243  {
244  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
245  throw;
246  }
247  removeUnresolvedInstances(inNameSpec);
248  }
249 }
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
bool get(const KeyType &inKey, ValueType &outValue) const
Definition: SymTab.hpp:121
void removeUnresolvedInstances(const NameSpec &inNameSpec)
Definition: Linker.cpp:225
boost::shared_ptr< UnresolvedInstances > UnresolvedInstancesPtr
Definition: Linker.hpp:131
UnresolvedInfoMap mInfos
Definition: Linker.hpp:208
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73

+ Here is the call graph for this function:

Linker & torc::generic::Linker::operator= ( const Linker inSource)

Definition at line 267 of file Linker.cpp.

267  {
268  if(this != &inSource)
269  {
270  mRoot = inSource.mRoot;
271  mInfos = inSource.mInfos;
272  }
273  return *this;
274 }
RootSharedPtr mRoot
Definition: Linker.hpp:207
UnresolvedInfoMap mInfos
Definition: Linker.hpp:208
void torc::generic::Linker::registerUnresolvedInstance ( const NameSpec inNameSpec,
const InstanceSharedPtr inInstance 
)
throw (Error
)

Add an instance to the list of unresolved instances for a given name specification. If a new UnresolvedInstances object is to be created, this method will also call the setExternView() method to update the externView, with the view set for this object.

Parameters
[in]inNameSpecname specification for a view.
[in]inInstanceinstance to be added.
Exceptions
ErrorThe master for this instance is not an extern or no extern is set for this view.

Definition at line 205 of file Linker.cpp.

207  {
209  mInfos.get(inNameSpec, info);
210  if(!info)
211  {
212  info = UnresolvedInstancesPtr(new UnresolvedInstances());
213  mInfos.set(inNameSpec, info);
214  }
215  info->addInstance(inInstance);
216  return;
217 }
bool set(const KeyType &inKey, const ValueType &inValue)
Definition: SymTab.hpp:132
bool get(const KeyType &inKey, ValueType &outValue) const
Definition: SymTab.hpp:121
boost::shared_ptr< UnresolvedInstances > UnresolvedInstancesPtr
Definition: Linker.hpp:131
UnresolvedInfoMap mInfos
Definition: Linker.hpp:208

+ Here is the call graph for this function:

void torc::generic::Linker::removeUnresolvedInstances ( const NameSpec inNameSpec)
throw (Error
)

Remove all unresolved objects for the given name specification.

Parameters
[in]inNameSpecName specification

Definition at line 225 of file Linker.cpp.

226  {
227  mInfos.remove(inNameSpec);
228 }
bool remove(const KeyType &inKey)
Definition: SymTab.hpp:153
UnresolvedInfoMap mInfos
Definition: Linker.hpp:208

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::generic::Linker::setExternView ( const NameSpec inNameSpec,
const ViewSharedPtr inExternView 
)

Set an extern View

Parameters
[in]inNameSpecName of the view
[in]inExternViewan Extern View

Set an extern View

Parameters
[in]inNameSpecName of the view
[in]externViewan Extern View

Definition at line 167 of file Linker.cpp.

169  {
171  mInfos.get(inNameSpec, info);
172  if(!info)
173  {
174  info = UnresolvedInstancesPtr(new UnresolvedInstances());
175  mInfos.set(inNameSpec, info);
176  }
177  info->setExternView(inExternView);
178  return;
179 }
bool set(const KeyType &inKey, const ValueType &inValue)
Definition: SymTab.hpp:132
bool get(const KeyType &inKey, ValueType &outValue) const
Definition: SymTab.hpp:121
boost::shared_ptr< UnresolvedInstances > UnresolvedInstancesPtr
Definition: Linker.hpp:131
UnresolvedInfoMap mInfos
Definition: Linker.hpp:208

+ Here is the call graph for this function:

Field Documentation

UnresolvedInfoMap torc::generic::Linker::mInfos
private

Definition at line 208 of file Linker.hpp.

RootSharedPtr torc::generic::Linker::mRoot
private

Definition at line 207 of file Linker.hpp.


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