OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
OperationContaineroperator= (const OperationContainer &)
 Assignment not allowed.
 

Static Private Attributes

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

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}
static IdealSRAM * memory_
Memory used througout the execution of the program.
static OperationIndex * index_
Contains information of operations.
static OperationSerializer * serializer_
Static instance of operation serializer.

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 {
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}
#define assert(condition)
static OperationModule & module(const std::string &path, const std::string &mod)
static OperationIndex & operationIndex()
std::string operationName(int i, const OperationModule &om)
OperationModule & module(int i)
std::string path(int i) const
int operationCount(const OperationModule &om)
int pathCount() const
int moduleCount() const

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}
static const Word MEMORY_END
End point of the memory.

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}
static const Word MEMORY_START
Starting point of the memory.

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 {
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}
static NullOperationModule & instance()
virtual std::string name() const

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

Referenced by isEffective(), AddModuleDialog::onOk(), and operation().

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}
static NullOperationBehavior & instance()
ObjectState * child(int index) const
std::string stringAttribute(const std::string &name) const
int childCount() const
static OperationSerializer & operationSerializer()
void addPath(const std::string &path)
virtual std::string propertiesModule() const
void setSourceFile(const std::string &filename)
virtual ObjectState * readState()
virtual void setBehavior(OperationBehavior &behavior)
Definition Operation.cc:378
virtual void loadState(const ObjectState *state)
Definition Operation.cc:480

References OperationIndex::addPath(), assert, ObjectState::child(), ObjectState::childCount(), NullOperationBehavior::instance(), NullOperationModule::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

Returns the instance of OperationContext.

Returns
Instance of OperationContext.

Definition at line 124 of file OperationContainer.cc.

124 {
125 return context_;
126}
static OperationContext context_
Operation context used through the execution of the program.

References context_.

Referenced by SimulateDialog::createState(), SimulateDialog::onAdvanceClock(), SimulateDialog::onReset(), SimulateDialog::onTrigger(), SimulateDialog::SimulateDialog(), and SimulateDialog::~SimulateDialog().

◆ 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
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}
static std::vector< std::string > osalPaths()

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

Referenced by OSEdTreeView::constructTree(), OSEdAddModuleCmd::Do(), OSEdAddOperationCmd::Do(), OSEdBuildAllCmd::Do(), OSEdPropertiesCmd::Do(), OSEdRemoveModuleCmd::Do(), OSEdRemoveOperationCmd::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(), OSEdAddModuleCmd::Do(), OSEdAddOperationCmd::Do(), OSEdPropertiesCmd::Do(), OSEdRemoveOperationCmd::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:
=
static const Word MAUSIZE
MAU size of the memory.

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: