OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
TTAMachine::OperationTriggeredFormat Class Reference

#include <OperationTriggeredFormat.hh>

Inheritance diagram for TTAMachine::OperationTriggeredFormat:
Inheritance graph
Collaboration diagram for TTAMachine::OperationTriggeredFormat:
Collaboration graph

Public Member Functions

 OperationTriggeredFormat (const std::string &name, Machine &owner)
 
 OperationTriggeredFormat (const ObjectState *state, Machine &owner)
 
virtual ~OperationTriggeredFormat ()
 
void addOperation (const std::string &op)
 
void removeOperation (const std::string &op)
 
int operationCount () const
 
std::string operationAtIndex (int index) const
 
bool hasOperation (const std::string &opName) const
 
void addOperand (OperationTriggeredOperand &operand)
 
std::vector< OperationTriggeredOperand * > operands () const
 
virtual void setMachine (Machine &machine)
 
virtual void unsetMachine ()
 
virtual void loadState (const ObjectState *state)
 
virtual ObjectStatesaveState () const
 
- Public Member Functions inherited from TTAMachine::Component
virtual ~Component ()
 
virtual TCEString name () const
 
virtual void setName (const std::string &name)
 
virtual Machinemachine () const
 
virtual void ensureRegistration (const Component &component) const
 
virtual bool isRegistered () const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_FORMAT = "ota-format"
 
static const std::string OSKEY_OPERATION = "ota-operation"
 
- Static Public Attributes inherited from TTAMachine::Component
static const std::string OSNAME_COMPONENT = "component"
 ObjectState name for component.
 
static const std::string OSKEY_NAME = "name"
 ObjectState attribute key for the name of the component.
 

Private Attributes

std::vector< std::string > operations_
 
std::vector< OperationTriggeredOperand * > operands_
 

Additional Inherited Members

- Protected Member Functions inherited from TTAMachine::Component
 Component (const std::string &name)
 
 Component (const ObjectState *state)
 
void internalSetMachine (Machine &machine)
 
void internalUnsetMachine ()
 
- Protected Member Functions inherited from TTAMachine::MachinePart
 MachinePart ()
 
virtual ~MachinePart ()
 

Detailed Description

Definition at line 44 of file OperationTriggeredFormat.hh.

Constructor & Destructor Documentation

◆ OperationTriggeredFormat() [1/2]

TTAMachine::OperationTriggeredFormat::OperationTriggeredFormat ( const std::string &  name,
Machine owner 
)

The constructor.

Registers the operation code encoding to the parent binary encoding automatically.

Parameters
parentThe parent OperationTriggeredFormat.

Definition at line 56 of file OperationTriggeredFormat.cc.

58 : Component(name) {
59 setMachine(owner);
60}
Component(const std::string &name)
virtual TCEString name() const

References setMachine().

Here is the call graph for this function:

◆ OperationTriggeredFormat() [2/2]

TTAMachine::OperationTriggeredFormat::OperationTriggeredFormat ( const ObjectState state,
Machine owner 
)

The constructor

Loads the state of the operation code encoding from the given ObjectState tree

Parameters
stateThe ObjectState tree
parentThe parent binary encoding map
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Definition at line 74 of file OperationTriggeredFormat.cc.

76 : Component(state) {
77 const std::string procName =
78 "OperationTriggeredFormat::OperationTriggeredFormat";
79 try {
80 setMachine(owner);
81 } catch (const ComponentAlreadyExists&) {
82 MOMTextGenerator textGenerator;
83 boost::format errorMsg =
85 errorMsg % name();
87 __FILE__, __LINE__, procName, errorMsg.str());
88 }
89 try {
90 loadState(state);
91 } catch (const ObjectStateLoadingException&) {
93 throw;
94 }
95}
virtual void loadState(const ObjectState *state)
virtual boost::format text(int textId)

References loadState(), TTAMachine::Component::name(), setMachine(), Texts::TextGenerator::text(), MOMTextGenerator::TXT_IT_EXISTS_BY_NAME, and unsetMachine().

Here is the call graph for this function:

◆ ~OperationTriggeredFormat()

TTAMachine::OperationTriggeredFormat::~OperationTriggeredFormat ( )
virtual

Destructor.

Definition at line 100 of file OperationTriggeredFormat.cc.

100 {
101 for (unsigned int i = 0; i < operands_.size(); i++) {
102 delete operands_.at(i);
103 }
104 unsetMachine();
105}
std::vector< OperationTriggeredOperand * > operands_

References operands_, and unsetMachine().

Here is the call graph for this function:

Member Function Documentation

◆ addOperand()

void TTAMachine::OperationTriggeredFormat::addOperand ( OperationTriggeredOperand operand)

◆ addOperation()

void TTAMachine::OperationTriggeredFormat::addOperation ( const std::string &  op)

Definition at line 108 of file OperationTriggeredFormat.cc.

108 {
109 operations_.push_back(op);
110}

References operations_.

Referenced by OTAOperationDialog::onOK().

◆ hasOperation()

bool TTAMachine::OperationTriggeredFormat::hasOperation ( const std::string &  opName) const

Definition at line 136 of file OperationTriggeredFormat.cc.

136 {
137 for (const std::string& op : operations_) {
138 if (op == opName) {
139 return true;
140 }
141 }
142 return false;
143}

References operations_.

Referenced by OTAOperationDialog::addRISCVBaseOperations(), OTAOperationDialog::onOK(), and OTAOperationDialog::TransferDataToWindow().

◆ loadState()

void TTAMachine::OperationTriggeredFormat::loadState ( const ObjectState state)
virtual

Loads the name of the component from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
Exceptions
ObjectStateLoadingExceptionIf the machine already contains same type of component with the same name.

Reimplemented from TTAMachine::Component.

Definition at line 185 of file OperationTriggeredFormat.cc.

185 {
186 operations_.clear();
187 operands_.clear();
188 const std::string procName = "OperationTriggeredOperand::loadState";
189
190 ObjectState* newState = new ObjectState(*state);
191
192 if (newState->name() != OSNAME_FORMAT) {
193 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
194 }
195 Component::loadState(newState);
196 try {
197 for (int i = 0; i < newState->childCount(); i++) {
198 ObjectState* child = newState->child(i);
200 new OperationTriggeredOperand(child, *this);
201 } else if (
203 operations_.push_back(child->stringValue());
204 }
205 }
206 } catch (const Exception& exception) {
208 __FILE__, __LINE__, procName, exception.errorMessage());
209 }
210 delete newState;
211}
std::string errorMessage() const
Definition Exception.cc:123
ObjectState * child(int index) const
std::string stringValue() const
std::string name() const
int childCount() const
virtual void loadState(const ObjectState *state)

References ObjectState::child(), ObjectState::childCount(), Exception::errorMessage(), TTAMachine::Component::loadState(), ObjectState::name(), operands_, operations_, OSKEY_OPERATION, OSNAME_FORMAT, TTAMachine::OperationTriggeredOperand::OSNAME_OPERAND, and ObjectState::stringValue().

Referenced by OperationTriggeredFormat().

Here is the call graph for this function:

◆ operands()

std::vector< OperationTriggeredOperand * > TTAMachine::OperationTriggeredFormat::operands ( ) const

Definition at line 146 of file OperationTriggeredFormat.cc.

146 {
147 return operands_;
148}

References operands_.

◆ operationAtIndex()

std::string TTAMachine::OperationTriggeredFormat::operationAtIndex ( int  index) const

Definition at line 127 of file OperationTriggeredFormat.cc.

127 {
128 if (index > operationCount() - 1) {
129 const std::string msg = "Operation index out of range.";
130 throw OutOfRange(__FILE__, __LINE__, __func__, msg);
131 }
132 return operations_.at(index);
133}
#define __func__

References __func__, operationCount(), and operations_.

Referenced by BEMGenerator::addRiscvFormat(), and OTAFormatListDialog::updateOperationList().

Here is the call graph for this function:

◆ operationCount()

int TTAMachine::OperationTriggeredFormat::operationCount ( ) const

Definition at line 122 of file OperationTriggeredFormat.cc.

122 {
123 return operations_.size();
124}

References operations_.

Referenced by BEMGenerator::addRiscvFormat(), operationAtIndex(), and OTAFormatListDialog::updateOperationList().

◆ removeOperation()

void TTAMachine::OperationTriggeredFormat::removeOperation ( const std::string &  op)

Definition at line 113 of file OperationTriggeredFormat.cc.

113 {
114 for (unsigned int i = 0; i < operations_.size(); i++) {
115 if (operations_.at(i) == op) {
116 operations_.erase(operations_.begin() + i);
117 }
118 }
119}

References operations_.

Referenced by OTAFormatListDialog::onDeleteOperation().

◆ saveState()

ObjectState * TTAMachine::OperationTriggeredFormat::saveState ( ) const
virtual

Saves the state of the operation code encoding to an ObjectState tree.

Returns
The newly created ObjectState tree.

Reimplemented from TTAMachine::Component.

Definition at line 221 of file OperationTriggeredFormat.cc.

221 {
223 state->setName(OSNAME_FORMAT);
224 for (unsigned int i = 0; i < operands_.size(); i++) {
225 ObjectState* operandObject = operands_.at(i)->saveState();
226 state->addChild(operandObject);
227 }
228 for (unsigned int i = 0; i < operations_.size(); i++) {
229 ObjectState* operationObject = new ObjectState(OSKEY_OPERATION);
230 operationObject->setValue(operations_.at(i));
231 state->addChild(operationObject);
232 }
233
234 return state;
235}
void setName(const std::string &name)
void setValue(const std::string &value)
void addChild(ObjectState *child)
virtual ObjectState * saveState() const

References ObjectState::addChild(), operands_, operations_, OSKEY_OPERATION, OSNAME_FORMAT, TTAMachine::Component::saveState(), ObjectState::setName(), and ObjectState::setValue().

Here is the call graph for this function:

◆ setMachine()

void TTAMachine::OperationTriggeredFormat::setMachine ( Machine machine)
virtual

Adds the OperationTriggeredFormat to the given machine.

Parameters
machineMachine to which the OperationTriggeredFormat Format is added.
Exceptions
ComponentAlreadyExistsIf there already is another OperationTriggeredFormat Format by the same name or another empty OperationTriggeredFormat Format in the given machine.

Implements TTAMachine::Component.

Definition at line 165 of file OperationTriggeredFormat.cc.

165 {
168}
virtual Machine * machine() const
void internalSetMachine(Machine &machine)
virtual void addOperationTriggeredFormat(OperationTriggeredFormat &format)
Definition Machine.cc:287

References TTAMachine::Machine::addOperationTriggeredFormat(), TTAMachine::Component::internalSetMachine(), and TTAMachine::Component::machine().

Referenced by OperationTriggeredFormat(), and OperationTriggeredFormat().

Here is the call graph for this function:

◆ unsetMachine()

void TTAMachine::OperationTriggeredFormat::unsetMachine ( )
virtual

Removes the OperationTriggeredFormat Format from its machine.

The OperationTriggeredFormat Format is also deleted because it cannot be alone. It must be registered to a machine.

Implements TTAMachine::Component.

Definition at line 177 of file OperationTriggeredFormat.cc.

177 {
178 Machine* mach = machine();
179 assert(mach != NULL);
181 mach->deleteOperationTriggeredFormat(*this);
182}
#define assert(condition)

References assert, TTAMachine::Machine::deleteOperationTriggeredFormat(), TTAMachine::Component::internalUnsetMachine(), and TTAMachine::Component::machine().

Referenced by OperationTriggeredFormat(), and ~OperationTriggeredFormat().

Here is the call graph for this function:

Member Data Documentation

◆ operands_

std::vector<OperationTriggeredOperand*> TTAMachine::OperationTriggeredFormat::operands_
private

◆ operations_

std::vector<std::string> TTAMachine::OperationTriggeredFormat::operations_
private

◆ OSKEY_OPERATION

const std::string TTAMachine::OperationTriggeredFormat::OSKEY_OPERATION = "ota-operation"
static

Definition at line 71 of file OperationTriggeredFormat.hh.

Referenced by loadState(), and saveState().

◆ OSNAME_FORMAT

const std::string TTAMachine::OperationTriggeredFormat::OSNAME_FORMAT = "ota-format"
static

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