OpenASIP
2.0
|
#include <OperationSerializer.hh>
Public Member Functions | |
OperationSerializer () | |
virtual | ~OperationSerializer () |
virtual void | writeState (const ObjectState *state) |
virtual ObjectState * | readState () |
void | setSourceFile (const std::string &filename) |
void | setDestinationFile (const std::string &filename) |
void | setSchemaFile (const std::string &filename) |
void | setUseSchema (bool useSchema) |
Public Member Functions inherited from TCETools::Serializer | |
virtual | ~Serializer () |
Private Member Functions | |
OperationSerializer (const OperationSerializer &) | |
Copying not allowed. More... | |
OperationSerializer & | operator= (const OperationSerializer &) |
Assignment not allowed. More... | |
ObjectState * | convertToXMLFormat (const ObjectState *state) |
ObjectState * | convertToOperationFormat (const ObjectState *state) |
ObjectState * | toOperation (const ObjectState *state) |
ObjectState * | toXMLFormat (const ObjectState *state) |
void | setOperandProperties (ObjectState *operand, ObjectState *source) |
Private Attributes | |
XMLSerializer | serializer_ |
Constructs the ObjectState tree from the XML file. More... | |
Class that constructs an ObjectState tree that represents the information contents of an operation module from a given external file.
Definition at line 49 of file OperationSerializer.hh.
OperationSerializer::OperationSerializer | ( | ) |
Constructor.
If schema file is found it is used.
Definition at line 67 of file OperationSerializer.cc.
References FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), LIBRARY_NAME, SCHEMA_FILE_NAME, Environment::schemaDirPath(), setSchemaFile(), and setUseSchema().
|
virtual |
|
private |
Copying not allowed.
|
private |
Converts ObjectState to more easily parseable format.
More easily parseable format is such that there are less nodes. Only children of the main node are the operands, affects, and affected-by nodes.
state | ObjectState to be converted. |
ObjectStateLoadingException | If ObjectState conversion fails. |
Definition at line 318 of file OperationSerializer.cc.
References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), OPSER_OSAL, and toOperation().
Referenced by readState().
|
private |
Converts ObjectState to the format understood by XMLSerializer.
XMLSerializer needs an ObjectState tree in which each attribute is in its own node. ObjectState tree obtained form an operation is not in that format. This is why conversion is needed.
state | ObjectState to be converted. |
ObjectStateLoadingException | If ObjectState conversion fails. |
Definition at line 147 of file OperationSerializer.cc.
References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), OPSER_OSAL, OPSER_VERSION, ObjectState::setAttribute(), toXMLFormat(), and VERSION_NUMBER.
Referenced by writeState().
|
private |
Assignment not allowed.
|
virtual |
Reads the Operation property file and returns a corresponding ObjectState.
ObjectState is converted to more easily parseable format before returning.
Implements TCETools::Serializer.
Definition at line 118 of file OperationSerializer.cc.
References __func__, convertToOperationFormat(), Exception::errorMessage(), XMLSerializer::readState(), serializer_, and Exception::setCause().
Referenced by OSEdTreeView::constructTree(), OSEdRemoveOperationCmd::Do(), OSEdPropertiesCmd::Do(), OperationPropertyLoader::loadModule(), OperationContainer::operation(), OperationIndex::readOperations(), and OperationBuilder::verifyXML().
void OperationSerializer::setDestinationFile | ( | const std::string & | filename | ) |
Sets destination file.
filename | The name of the file. |
Definition at line 546 of file OperationSerializer.cc.
References serializer_, and XMLSerializer::setDestinationFile().
Referenced by OSEdAddModuleCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdPropertiesCmd::Do(), and OSEdAddOperationCmd::Do().
|
private |
Set operand properties to right values.
operand | Operand which properties are set. |
source | Original ObjectState tree. |
Definition at line 508 of file OperationSerializer.cc.
References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), ObjectState::intValue(), ObjectState::name(), Operand::OPRND_CAN_SWAP, Operand::OPRND_MEM_ADDRESS, Operand::OPRND_MEM_DATA, Operand::OPRND_MEM_UNITS, and ObjectState::setAttribute().
Referenced by toOperation().
void OperationSerializer::setSchemaFile | ( | const std::string & | filename | ) |
Sets schema file.
fileName | The name of the file. |
Definition at line 556 of file OperationSerializer.cc.
References serializer_, and XMLSerializer::setSchemaFile().
Referenced by OperationSerializer().
void OperationSerializer::setSourceFile | ( | const std::string & | filename | ) |
Sets source file.
filename | The name of the file. |
Definition at line 536 of file OperationSerializer.cc.
References serializer_, and XMLSerializer::setSourceFile().
Referenced by OSEdTreeView::constructTree(), OSEdRemoveOperationCmd::Do(), OSEdPropertiesCmd::Do(), OperationPropertyLoader::loadModule(), OperationContainer::operation(), OperationIndex::readOperations(), and OperationBuilder::verifyXML().
void OperationSerializer::setUseSchema | ( | bool | useSchema | ) |
Sets whether schema is used or not.
useSchema | True or false, depending on if schema is to be used or not. |
Definition at line 566 of file OperationSerializer.cc.
References serializer_, and XMLSerializer::setUseSchema().
Referenced by OperationSerializer().
|
private |
Converts Operation ObjectState tree to more easily parsed format.
state | ObjectState to be converted. |
ObjectStateLoadingException | If ObjectState conversion fails. |
Definition at line 335 of file OperationSerializer.cc.
References __func__, ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), Exception::errorMessage(), ObjectState::hasAttribute(), ObjectState::intAttribute(), ObjectState::intValue(), ObjectState::name(), Operation::OPRN_CLOCKED, Operation::OPRN_CONTROL_FLOW, Operation::OPRN_DESCRIPTION, Operation::OPRN_IN, Operation::OPRN_INPUTS, Operation::OPRN_ISBRANCH, Operation::OPRN_ISCALL, Operation::OPRN_NAME, Operation::OPRN_OPERATION, Operation::OPRN_OUT, Operation::OPRN_OUTPUTS, Operation::OPRN_READS_MEMORY, Operation::OPRN_SIDE_EFFECTS, Operation::OPRN_TRAP, Operation::OPRN_WRITES_MEMORY, Operand::OPRND_ELEM_COUNT, Operand::OPRND_ELEM_WIDTH, Operand::OPRND_ID, Operand::OPRND_MEM_ADDRESS, Operand::OPRND_MEM_DATA, Operand::OPRND_TYPE, ObjectState::setAttribute(), Exception::setCause(), setOperandProperties(), ObjectState::stringAttribute(), StringTools::stringToUpper(), and ObjectState::stringValue().
Referenced by convertToOperationFormat().
|
private |
Converts an individual operation to xml format.
state | ObjectState to be converted. |
ObjectStateLoadingException | If ObjectState conversion fails. |
Definition at line 165 of file OperationSerializer.cc.
References __func__, ObjectState::addChild(), ObjectState::boolAttribute(), ObjectState::child(), ObjectState::childCount(), Exception::errorMessage(), ObjectState::hasAttribute(), ObjectState::intAttribute(), ObjectState::name(), Operation::OPRN_CLOCKED, Operation::OPRN_CONTROL_FLOW, Operation::OPRN_DESCRIPTION, Operation::OPRN_IN, Operation::OPRN_INPUTS, Operation::OPRN_ISBRANCH, Operation::OPRN_ISCALL, Operation::OPRN_NAME, Operation::OPRN_OPERATION, Operation::OPRN_OUT, Operation::OPRN_OUTPUTS, Operation::OPRN_READS_MEMORY, Operation::OPRN_SIDE_EFFECTS, Operation::OPRN_TRAP, Operation::OPRN_WRITES_MEMORY, Operand::OPRND_CAN_SWAP, Operand::OPRND_ELEM_COUNT, Operand::OPRND_ELEM_WIDTH, Operand::OPRND_ID, Operand::OPRND_IN, Operand::OPRND_MEM_ADDRESS, Operand::OPRND_MEM_DATA, Operand::OPRND_MEM_UNITS, Operand::OPRND_TYPE, ObjectState::setAttribute(), Exception::setCause(), ObjectState::setValue(), and ObjectState::stringAttribute().
Referenced by convertToXMLFormat().
|
virtual |
Writes the state of operations to XML file.
The states of operations are first converted to the format understood by XMLSerializer and then written.
state | ObjectState to be written. |
SerializerException | If error occurs. |
Implements TCETools::Serializer.
Definition at line 96 of file OperationSerializer.cc.
References __func__, convertToXMLFormat(), Exception::errorMessage(), serializer_, Exception::setCause(), and XMLSerializer::writeState().
Referenced by OSEdAddModuleCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdPropertiesCmd::Do(), and OSEdAddOperationCmd::Do().
|
private |
Constructs the ObjectState tree from the XML file.
Definition at line 77 of file OperationSerializer.hh.
Referenced by readState(), setDestinationFile(), setSchemaFile(), setSourceFile(), setUseSchema(), and writeState().