OpenASIP  2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
OperationContainer Class Reference

#include <OperationContainer.hh>

Collaboration diagram for OperationContainer:
Collaboration graph

Public Member Functions

virtual ~OperationContainer ()
 

Static Public Member Functions

static OperationIndexoperationIndex ()
 
static OperationSerializeroperationSerializer ()
 
static OperationContextoperationContext ()
 
static Memorymemory ()
 
static void destroy ()
 
static OperationModulemodule (const std::string &path, const std::string &mod)
 
static Operationoperation (const std::string &path, const std::string &module, const std::string &oper)
 
static bool operationExists (const std::string &name)
 
static bool isEffective (OperationModule &module, const std::string &name)
 
static Word memoryStart ()
 
static Word memoryEnd ()
 

Private Member Functions

 OperationContainer ()
 
 OperationContainer (const OperationContainer &)
 Copying not allowed. More...
 
OperationContaineroperator= (const OperationContainer &)
 Assignment not allowed. More...
 

Static Private Attributes

static const std::string CREATE_FUNCTION = "createOpBehavior_"
 Creation function name for operation behavior. More...
 
static const std::string DELETE_FUNCTION = "deleteOpBehavior_"
 Operation behavior deletion function name. More...
 
static const Word MEMORY_START = 0
 Starting point of the memory. More...
 
static const Word MEMORY_END = 65535
 End point of the memory. More...
 
static const Word MAUSIZE = 8
 MAU size of the memory. More...
 
static OperationIndexindex_ = NULL
 Contains information of operations. More...
 
static OperationSerializerserializer_ = NULL
 Static instance of operation serializer. More...
 
static OperationContext context_
 Operation context used through the execution of the program. More...
 
static InstructionAddress programCounter_
 Program counter. More...
 
static SimValue returnAddress_
 Return address. More...
 
static SimValue sysCallHandler_
 Sys call handler. More...
 
static SimValue sysCallNumber_
 Sys call number. More...
 
static IdealSRAMmemory_
 Memory used througout the execution of the program. More...
 
static PluginTools tools_
 PluginTools used by OperationContainer;. More...
 

Detailed Description

Singleton class that holds necessary information for viewing operation properties, modifying operation behavior, and simulating operation behavior.

Include also means to view and modify the contents of the memory.

Definition at line 56 of file OperationContainer.hh.

Constructor & Destructor Documentation

◆ ~OperationContainer()

OperationContainer::~OperationContainer ( )
virtual

Destructor.

Definition at line 85 of file OperationContainer.cc.

85  {
86 }

◆ OperationContainer() [1/2]

OperationContainer::OperationContainer ( )
private

Constructor.

Definition at line 79 of file OperationContainer.cc.

79  {
80 }

◆ OperationContainer() [2/2]

OperationContainer::OperationContainer ( const OperationContainer )
private

Copying not allowed.

Member Function Documentation

◆ destroy()

void OperationContainer::destroy ( )
static

This function is called to clean up the static objects.

This function should be called only when application is closed.

Definition at line 280 of file OperationContainer.cc.

280  {
281 
282  if (index_ != NULL) {
283  delete index_;
284  index_ = NULL;
285  }
286 
287  if (serializer_ != NULL) {
288  delete serializer_;
289  serializer_ = NULL;
290  }
291 
292  if (memory_ != NULL) {
293  delete memory_;
294  memory_ = NULL;
295  }
296 }

References index_, memory_, and serializer_.

Referenced by OSEd::OnExit().

◆ isEffective()

bool OperationContainer::isEffective ( OperationModule module,
const std::string &  name 
)
static

Returns true if operation is effective.

Effective means that is is found first in list of search paths.

Parameters
moduleThe module in which operation is defined.
nameThe name of the operation.
Returns
True if operation is effective.

Definition at line 244 of file OperationContainer.cc.

246  {
247 
248  try {
249  OperationIndex& index = operationIndex();
250  for (int i = 0; i < index.pathCount(); i++) {
251  string path = index.path(i);
252  for (int j = 0; j < index.moduleCount(path); j++) {
253  OperationModule& mod = index.module(j, path);
254  for (int k = 0; k < index.operationCount(mod); k++) {
255  string opName = index.operationName(k, mod);
256  if (opName == name) {
257  if (&module == &mod) {
258  return true;
259  } else {
260  return false;
261  }
262  }
263  }
264  }
265  }
266  } catch (const Exception& e) {
267  return false;
268  }
269  // never should come here
270  assert(false);
271  return false;
272 }

References assert, module(), OperationIndex::module(), OperationIndex::moduleCount(), OperationIndex::operationCount(), operationIndex(), OperationIndex::operationName(), OperationIndex::path(), and OperationIndex::pathCount().

Referenced by OSEdInfoView::operationView().

Here is the call graph for this function:

◆ memory()

Memory & OperationContainer::memory ( )
static

Returns the memory model instance.

Returns
Memory model instance.

Definition at line 134 of file OperationContainer.cc.

134  {
135  return *memory_;
136 }

References memory_.

Referenced by MemoryDialog::createContents(), and SimulateDialog::onAdvanceClock().

◆ memoryEnd()

Word OperationContainer::memoryEnd ( )
static

Returns the end point of the memory.

Returns
Memory end point.

Definition at line 314 of file OperationContainer.cc.

314  {
315  return MEMORY_END;
316 }

References MEMORY_END.

◆ memoryStart()

Word OperationContainer::memoryStart ( )
static

Returns the start point of the memory.

Returns
Memory start point.

Definition at line 304 of file OperationContainer.cc.

304  {
305  return MEMORY_START;
306 }

References MEMORY_START.

◆ module()

OperationModule & OperationContainer::module ( const std::string &  path,
const std::string &  mod 
)
static

Returns a certain module in a certain path.

If module is not found, a NullOperationModule is returned.

Parameters
pathThe name of the path.
modThe name of the module.
Returns
The module or NullOperationModule.

Definition at line 148 of file OperationContainer.cc.

148  {
149  OperationIndex& index = operationIndex();
150  try {
151  for (int i = 0; i < index.moduleCount(path); i++) {
152  if (index.module(i, path).name() == mod) {
153  return index.module(i, path);
154  }
155  }
156  } catch (const Exception& e) {
158  }
160 }

References NullOperationModule::instance(), OperationIndex::module(), OperationIndex::moduleCount(), OperationModule::name(), and operationIndex().

Referenced by OSEdAddOperationCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdBuildCmd::Do(), OSEdModifyBehaviorCmd::Do(), OSEdPropertiesCmd::Do(), OSEdRemoveModuleCmd::Do(), isEffective(), OSEdBuildCmd::isEnabled(), AddModuleDialog::onOk(), operation(), and OSEdInfoView::operationView().

Here is the call graph for this function:

◆ operation()

Operation * OperationContainer::operation ( const std::string &  path,
const std::string &  mod,
const std::string &  oper 
)
static

Returns a certain operation in a certain module and a path.

If operation is not found, NULL is returned.

Parameters
pathThe name of the path.
modThe name of the module.
operThe name of the operation.
Returns
The operation.

Definition at line 173 of file OperationContainer.cc.

176  {
177 
178  OperationModule& opModule = module(path, mod);
179  assert(&opModule != &NullOperationModule::instance());
180 
182  serializer.setSourceFile(opModule.propertiesModule());
183  try {
184  ObjectState* root = serializer.readState();
185  for (int i = 0; i < root->childCount(); i++) {
186  if (root->child(i)->stringAttribute("name") == oper) {
187 
188  OperationIndex* index = new OperationIndex;
189  index->addPath(path);
190 
191  Operation* op =
193  op->loadState(root->child(i));
194 
195  OperationBehaviorLoader* behaviorLoader =
196  new OperationBehaviorLoader(*index);
197  OperationBehaviorProxy* behaviorProxy =
198  new OperationBehaviorProxy(*op, *behaviorLoader, true);
199 
200  op->setBehavior(*behaviorProxy);
201 
202  delete root;
203  return op;
204  }
205  }
206  } catch (const Exception& e) {
207  return NULL;
208  }
209  return NULL;
210 }

References OperationIndex::addPath(), assert, ObjectState::child(), ObjectState::childCount(), NullOperationModule::instance(), NullOperationBehavior::instance(), Operation::loadState(), module(), operationSerializer(), OperationModule::propertiesModule(), OperationSerializer::readState(), Operation::setBehavior(), OperationSerializer::setSourceFile(), and ObjectState::stringAttribute().

Referenced by OSEdAddOperationCmd::Do(), OSEdInfoView::operationPropertyView(), OSEdTreeView::selectedOperation(), and OperationPropertyDialog::updateOperation().

Here is the call graph for this function:

◆ operationContext()

OperationContext & OperationContainer::operationContext ( )
static

◆ operationExists()

bool OperationContainer::operationExists ( const std::string &  name)
static

Returns true if operation exists.

Parameters
nameThe name of the operation.
Returns
True if operation exists, false otherwise.

Definition at line 219 of file OperationContainer.cc.

219  {
220 
221  OperationIndex& index = operationIndex();
222 
223  for (int i = 0; i < index.moduleCount(); i++) {
224  OperationModule& mod = index.module(i);
225  for (int j = 0; j < index.operationCount(mod); j++) {
226  if (index.operationName(j, mod) == name) {
227  return true;
228  }
229  }
230  }
231  return false;
232 }

References OperationIndex::module(), OperationIndex::moduleCount(), OperationIndex::operationCount(), operationIndex(), and OperationIndex::operationName().

Referenced by OperationPropertyDialog::onAddAffectedBy(), and OperationPropertyDialog::onAddAffects().

Here is the call graph for this function:

◆ operationIndex()

OperationIndex & OperationContainer::operationIndex ( )
static

Returns the instance of OperationIndex.

Returns
The instance of OperationIndex.

Definition at line 94 of file OperationContainer.cc.

94  {
95  if (index_ == NULL) {
96  index_ = new OperationIndex();
97  vector<string> paths = Environment::osalPaths();
98  for (size_t i = 0; i < paths.size(); i++) {
99  index_->addPath(paths[i]);
100  }
101  }
102  return *index_;
103 }

References OperationIndex::addPath(), index_, and Environment::osalPaths().

Referenced by OSEdTreeView::constructTree(), OSEdBuildAllCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdPropertiesCmd::Do(), OSEdAddModuleCmd::Do(), OSEdRemoveModuleCmd::Do(), OSEdAddOperationCmd::Do(), isEffective(), OSEdBuildAllCmd::isEnabled(), module(), OSEdInfoView::moduleView(), operationExists(), OSEdInfoView::operationView(), and OperationPropertyDialog::updateAffected().

Here is the call graph for this function:

◆ operationSerializer()

OperationSerializer & OperationContainer::operationSerializer ( )
static

Returns the instance of OperationSerializer.

Returns
The instance of OperationSerializer.

Definition at line 111 of file OperationContainer.cc.

111  {
112  if (serializer_ == NULL) {
114  }
115  return *serializer_;
116 }

References serializer_.

Referenced by OSEdTreeView::constructTree(), OSEdAddOperationCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdPropertiesCmd::Do(), OSEdAddModuleCmd::Do(), and operation().

◆ operator=()

OperationContainer& OperationContainer::operator= ( const OperationContainer )
private

Assignment not allowed.

Member Data Documentation

◆ context_

OperationContext OperationContainer::context_
staticprivate

Operation context used through the execution of the program.

Definition at line 107 of file OperationContainer.hh.

Referenced by operationContext().

◆ CREATE_FUNCTION

const string OperationContainer::CREATE_FUNCTION = "createOpBehavior_"
staticprivate

Creation function name for operation behavior.

Definition at line 91 of file OperationContainer.hh.

◆ DELETE_FUNCTION

const string OperationContainer::DELETE_FUNCTION = "deleteOpBehavior_"
staticprivate

Operation behavior deletion function name.

Definition at line 93 of file OperationContainer.hh.

◆ index_

OperationIndex * OperationContainer::index_ = NULL
staticprivate

Contains information of operations.

Definition at line 103 of file OperationContainer.hh.

Referenced by destroy(), and operationIndex().

◆ MAUSIZE

const Word OperationContainer::MAUSIZE = 8
staticprivate

MAU size of the memory.

Definition at line 100 of file OperationContainer.hh.

◆ memory_

IdealSRAM * OperationContainer::memory_
staticprivate
Initial value:

Memory used througout the execution of the program.

Definition at line 117 of file OperationContainer.hh.

Referenced by destroy(), and memory().

◆ MEMORY_END

const Word OperationContainer::MEMORY_END = 65535
staticprivate

End point of the memory.

Definition at line 98 of file OperationContainer.hh.

Referenced by memoryEnd().

◆ MEMORY_START

const Word OperationContainer::MEMORY_START = 0
staticprivate

Starting point of the memory.

Definition at line 96 of file OperationContainer.hh.

Referenced by memoryStart().

◆ programCounter_

InstructionAddress OperationContainer::programCounter_
staticprivate

Program counter.

Definition at line 109 of file OperationContainer.hh.

◆ returnAddress_

SimValue OperationContainer::returnAddress_
staticprivate

Return address.

Definition at line 111 of file OperationContainer.hh.

◆ serializer_

OperationSerializer * OperationContainer::serializer_ = NULL
staticprivate

Static instance of operation serializer.

Definition at line 105 of file OperationContainer.hh.

Referenced by destroy(), and operationSerializer().

◆ sysCallHandler_

SimValue OperationContainer::sysCallHandler_
staticprivate

Sys call handler.

Definition at line 113 of file OperationContainer.hh.

◆ sysCallNumber_

SimValue OperationContainer::sysCallNumber_
staticprivate

Sys call number.

Definition at line 115 of file OperationContainer.hh.

◆ tools_

PluginTools OperationContainer::tools_
staticprivate

PluginTools used by OperationContainer;.

Definition at line 119 of file OperationContainer.hh.


The documentation for this class was generated from the following files:
OperationContainer::memory_
static IdealSRAM * memory_
Memory used througout the execution of the program.
Definition: OperationContainer.hh:117
OperationIndex::addPath
void addPath(const std::string &path)
Definition: OperationIndex.cc:82
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
OperationContainer::MEMORY_END
static const Word MEMORY_END
End point of the memory.
Definition: OperationContainer.hh:98
OperationContainer::operationSerializer
static OperationSerializer & operationSerializer()
Definition: OperationContainer.cc:111
OperationContainer::module
static OperationModule & module(const std::string &path, const std::string &mod)
Definition: OperationContainer.cc:148
ObjectState
Definition: ObjectState.hh:59
assert
#define assert(condition)
Definition: Application.hh:86
OperationContainer::index_
static OperationIndex * index_
Contains information of operations.
Definition: OperationContainer.hh:103
OperationIndex::pathCount
int pathCount() const
OperationContainer::context_
static OperationContext context_
Operation context used through the execution of the program.
Definition: OperationContainer.hh:107
OperationModule::propertiesModule
virtual std::string propertiesModule() const
Definition: OperationModule.cc:121
Operation::setBehavior
virtual void setBehavior(OperationBehavior &behavior)
Definition: Operation.cc:378
OperationBehaviorProxy
Definition: OperationBehaviorProxy.hh:58
OperationSerializer::readState
virtual ObjectState * readState()
Definition: OperationSerializer.cc:118
Operation::loadState
virtual void loadState(const ObjectState *state)
Definition: Operation.cc:480
OperationSerializer
Definition: OperationSerializer.hh:49
ObjectState::child
ObjectState * child(int index) const
Definition: ObjectState.cc:471
ObjectState::childCount
int childCount() const
OperationBehaviorLoader
Definition: OperationBehaviorLoader.hh:54
OperationSerializer::setSourceFile
void setSourceFile(const std::string &filename)
Definition: OperationSerializer.cc:536
Exception
Definition: Exception.hh:54
Environment::osalPaths
static std::vector< std::string > osalPaths()
Definition: Environment.cc:519
Operation
Definition: Operation.hh:59
OperationContainer::serializer_
static OperationSerializer * serializer_
Static instance of operation serializer.
Definition: OperationContainer.hh:105
NullOperationBehavior::instance
static NullOperationBehavior & instance()
Definition: OperationBehavior.hh:95
OperationIndex::moduleCount
int moduleCount() const
OperationModule
Definition: OperationModule.hh:46
OperationIndex::path
std::string path(int i) const
OperationContainer::MEMORY_START
static const Word MEMORY_START
Starting point of the memory.
Definition: OperationContainer.hh:96
OperationIndex
Definition: OperationIndex.hh:58
IdealSRAM
Definition: IdealSRAM.hh:55
OperationModule::name
virtual std::string name() const
Definition: OperationModule.cc:160
OperationContainer::MAUSIZE
static const Word MAUSIZE
MAU size of the memory.
Definition: OperationContainer.hh:100
NullOperationModule::instance
static NullOperationModule & instance()
OperationIndex::operationCount
int operationCount(const OperationModule &om)
Definition: OperationIndex.cc:363
OperationContainer::operationIndex
static OperationIndex & operationIndex()
Definition: OperationContainer.cc:94
OperationIndex::module
OperationModule & module(int i)
OperationIndex::operationName
std::string operationName(int i, const OperationModule &om)
Definition: OperationIndex.cc:337