OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
OperationPropertyLoader Class Reference

#include <OperationPropertyLoader.hh>

Collaboration diagram for OperationPropertyLoader:
Collaboration graph

Public Member Functions

 OperationPropertyLoader ()
 
virtual ~OperationPropertyLoader ()
 
void loadOperationProperties (Operation &operation, const OperationModule &module)
 

Private Types

typedef std::map< std::string, std::vector< ObjectState * > > ObjectStateCache
 Container containing already read ObjectState trees.
 
typedef ObjectStateCache::iterator MapIter
 Iterator for map containing already read ObjectState trees.
 
typedef ObjectStateCache::value_type ValueType
 value_type for map containing already read ObjectState trees.
 

Private Member Functions

 OperationPropertyLoader (const OperationPropertyLoader &)
 Copying not allowed.
 
OperationPropertyLoaderoperator= (const OperationPropertyLoader &)
 Assignment not allowed.
 
void loadModule (const OperationModule &module)
 

Private Attributes

OperationSerializer serializer_
 Serializer instance.
 
ObjectStateCache operations_
 Cache for already read ObjectState trees.
 

Detailed Description

Imports the static information contents of an operation from a data file.

Definition at line 51 of file OperationPropertyLoader.hh.

Member Typedef Documentation

◆ MapIter

typedef ObjectStateCache::iterator OperationPropertyLoader::MapIter
private

Iterator for map containing already read ObjectState trees.

Definition at line 64 of file OperationPropertyLoader.hh.

◆ ObjectStateCache

typedef std::map<std::string, std::vector<ObjectState*> > OperationPropertyLoader::ObjectStateCache
private

Container containing already read ObjectState trees.

Definition at line 61 of file OperationPropertyLoader.hh.

◆ ValueType

typedef ObjectStateCache::value_type OperationPropertyLoader::ValueType
private

value_type for map containing already read ObjectState trees.

Definition at line 66 of file OperationPropertyLoader.hh.

Constructor & Destructor Documentation

◆ OperationPropertyLoader() [1/2]

OperationPropertyLoader::OperationPropertyLoader ( )

Constructor.

Definition at line 50 of file OperationPropertyLoader.cc.

50 {
51}

◆ ~OperationPropertyLoader()

OperationPropertyLoader::~OperationPropertyLoader ( )
virtual

Destructor.

Definition at line 56 of file OperationPropertyLoader.cc.

56 {
57 MapIter it = operations_.begin();
58 while (it != operations_.end()) {
60 it++;
61 }
62}
ObjectStateCache::iterator MapIter
Iterator for map containing already read ObjectState trees.
ObjectStateCache operations_
Cache for already read ObjectState trees.
static void deleteAllItems(SequenceType &aSequence)

References SequenceTools::deleteAllItems(), and operations_.

Here is the call graph for this function:

◆ OperationPropertyLoader() [2/2]

OperationPropertyLoader::OperationPropertyLoader ( const OperationPropertyLoader )
private

Copying not allowed.

Member Function Documentation

◆ loadModule()

void OperationPropertyLoader::loadModule ( const OperationModule module)
private

Loads the module.

Saves its operations as an ObjectState objects.

Parameters
moduleThe OperationModule.
Exceptions
InstanceNotFoundIf loading the module fails.

Definition at line 120 of file OperationPropertyLoader.cc.

120 {
122 ObjectState* root = NULL;
123 try {
124 root = serializer_.readState();
125 } catch (const SerializerException& s) {
126 string msg = "Problems when reading the XML file: " + s.errorMessage();
127 throw InstanceNotFound(__FILE__, __LINE__, __func__, msg);
128 }
129 vector<ObjectState*> ops;
130 for (int i = 0; i < root->childCount(); i++) {
131 ObjectState* child = new ObjectState(*root->child(i));
132 ops.push_back(child);
133 }
134 delete root;
135 operations_.insert(ValueType(module.propertiesModule(), ops));
136}
#define __func__
std::string errorMessage() const
Definition Exception.cc:123
ObjectState * child(int index) const
int childCount() const
virtual std::string propertiesModule() const
ObjectStateCache::value_type ValueType
value_type for map containing already read ObjectState trees.
OperationSerializer serializer_
Serializer instance.
void setSourceFile(const std::string &filename)
virtual ObjectState * readState()

References __func__, ObjectState::child(), ObjectState::childCount(), Exception::errorMessage(), operations_, OperationModule::propertiesModule(), OperationSerializer::readState(), serializer_, and OperationSerializer::setSourceFile().

Referenced by loadOperationProperties().

Here is the call graph for this function:

◆ loadOperationProperties()

void OperationPropertyLoader::loadOperationProperties ( Operation operation,
const OperationModule module 
)

Loads the properties of an operation.

If operation properties has not yet been loaded, it is done first.

Parameters
operationOperation which properties are loaded and updated.
moduleModule where properties are loaded from.
Exceptions
InstanceNotFoundIf reading of XML fails, if Operation fails to load its state, or if properties are not found at all.

Definition at line 76 of file OperationPropertyLoader.cc.

77 {
78 MapIter it = operations_.find(module.propertiesModule());
79 if (it == operations_.end()) {
80 // properties are not yet read, let's do it first
81 loadModule(module);
82 it = operations_.find(module.propertiesModule());
83 }
84
85 const vector<ObjectState*> ops = (*it).second;
86 bool operationFound = false;
87
88 for (unsigned int i = 0; i < ops.size(); i++) {
89 if (ops[i]->stringAttribute(Operation::OPRN_NAME) ==
90 operation.name()) {
91
92 operationFound = true;
93 try {
94 operation.loadState(ops[i]);
95 } catch (const ObjectStateLoadingException& o) {
96 string msg = "Problems when loading the state of the Object: "
97 + o.errorMessage();
98 throw InstanceNotFound(__FILE__, __LINE__, __func__, msg);
99 }
100 break;
101 }
102 }
103
104 if (!operationFound) {
105 string msg = string("Properties for operation ") + operation.name() +
106 " not found";
107 throw InstanceNotFound(__FILE__, __LINE__, __func__, msg);
108 }
109}
void loadModule(const OperationModule &module)
virtual TCEString name() const
Definition Operation.cc:93
static const char * OPRN_NAME
Object state name for name.
Definition Operation.hh:67
virtual void loadState(const ObjectState *state)
Definition Operation.cc:480

References __func__, Exception::errorMessage(), loadModule(), Operation::loadState(), Operation::name(), operations_, Operation::OPRN_NAME, and OperationModule::propertiesModule().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

Member Data Documentation

◆ operations_

ObjectStateCache OperationPropertyLoader::operations_
private

Cache for already read ObjectState trees.

Definition at line 78 of file OperationPropertyLoader.hh.

Referenced by loadModule(), loadOperationProperties(), and ~OperationPropertyLoader().

◆ serializer_

OperationSerializer OperationPropertyLoader::serializer_
private

Serializer instance.

Definition at line 76 of file OperationPropertyLoader.hh.

Referenced by loadModule().


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