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

#include <OperationTriggeredEncoding.hh>

Inheritance diagram for OperationTriggeredEncoding:
Inheritance graph
Collaboration diagram for OperationTriggeredEncoding:
Collaboration graph

Public Member Functions

 OperationTriggeredEncoding (const std::string &name, InstructionFormat &parent)
 
 OperationTriggeredEncoding (const ObjectState *state, InstructionFormat &parent)
 
 ~OperationTriggeredEncoding ()
 
std::string name () const
 
void setName (const std::string &name)
 
void addField (OperationTriggeredField &field)
 
virtual int childFieldCount () const
 
virtual int width () const
 
virtual void loadState (const ObjectState *state)
 
virtual ObjectStatesaveState () const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_OTA_ENCODING
 
static const std::string OSKEY_OTA_ENCODING_NAME
 

Private Attributes

std::string name_
 
std::vector< OperationTriggeredField * > fields_
 

Detailed Description

Definition at line 44 of file OperationTriggeredEncoding.hh.

Constructor & Destructor Documentation

◆ OperationTriggeredEncoding() [1/2]

OperationTriggeredEncoding::OperationTriggeredEncoding ( const std::string &  name,
InstructionFormat parent 
)

The constructor.

Adds the instruction format to the parent binary encoding automatically.

Parameters
nameName of the instruction format.
parentThe parent Instruction Format.

Definition at line 54 of file OperationTriggeredEncoding.cc.

56 : name_(name) {
57 parent.addEncoding(*this);
58}
void addEncoding(OperationTriggeredEncoding &encoding)

References InstructionFormat::addEncoding().

Here is the call graph for this function:

◆ OperationTriggeredEncoding() [2/2]

OperationTriggeredEncoding::OperationTriggeredEncoding ( const ObjectState state,
InstructionFormat parent 
)

The constructor.

Loads the state of the instruction format 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 71 of file OperationTriggeredEncoding.cc.

72 {
73 parent.addEncoding(*this);
74 loadState(state);
75}
virtual void loadState(const ObjectState *state)

References InstructionFormat::addEncoding(), and loadState().

Here is the call graph for this function:

◆ ~OperationTriggeredEncoding()

OperationTriggeredEncoding::~OperationTriggeredEncoding ( )

The destructor

Definition at line 82 of file OperationTriggeredEncoding.cc.

82 {
83 for (unsigned int i = 0; i < fields_.size(); i++) {
84 delete fields_.at(i);
85 }
86}
std::vector< OperationTriggeredField * > fields_

References fields_.

Member Function Documentation

◆ addField()

void OperationTriggeredEncoding::addField ( OperationTriggeredField field)

Definition at line 138 of file OperationTriggeredEncoding.cc.

138 {
139 // TODO: Inspect that field is valid
140 fields_.push_back(&field);
141}

References fields_.

Referenced by OperationTriggeredField::OperationTriggeredField(), and OperationTriggeredField::OperationTriggeredField().

◆ childFieldCount()

int OperationTriggeredEncoding::childFieldCount ( ) const
virtual

Returns the number of operation triggered fields.

Returns
The number of child fields.

Definition at line 117 of file OperationTriggeredEncoding.cc.

117 {
118 return fields_.size();
119}

References fields_.

◆ loadState()

void OperationTriggeredEncoding::loadState ( const ObjectState state)
virtual

Loads the state of the instruction format from the given ObjectState tree.

Parameters
stateThe ObjectState tree.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Implements Serializable.

Definition at line 152 of file OperationTriggeredEncoding.cc.

152 {
153 ObjectState* newState = new ObjectState(*state);
154 try {
156 for (int i = 0; i < newState->childCount(); i++) {
157 ObjectState* child = newState->child(i);
159 new OperationTriggeredField(child, *this);
160 }
161 }
162 } catch (const Exception& exception) {
163 const std::string procName = "OperationTriggeredEncoding::loadState";
165 __FILE__, __LINE__, procName, exception.errorMessage());
166 }
167 delete newState;
168}
std::string errorMessage() const
Definition Exception.cc:123
ObjectState * child(int index) const
std::string stringAttribute(const std::string &name) const
std::string name() const
int childCount() const
void setName(const std::string &name)
static const std::string OSKEY_OTA_ENCODING_NAME
static const std::string OSNAME_FIELD

References ObjectState::child(), ObjectState::childCount(), Exception::errorMessage(), ObjectState::name(), OSKEY_OTA_ENCODING_NAME, OperationTriggeredField::OSNAME_FIELD, setName(), and ObjectState::stringAttribute().

Referenced by OperationTriggeredEncoding().

Here is the call graph for this function:

◆ name()

std::string OperationTriggeredEncoding::name ( ) const

Returns the name of the instruction format.

Returns
The name of the instruction format

Definition at line 95 of file OperationTriggeredEncoding.cc.

95 {
96 return name_;
97}

References name_.

Referenced by setName().

◆ saveState()

ObjectState * OperationTriggeredEncoding::saveState ( ) const
virtual

Saves the state of the instruction format to an ObjectState tree.

Returns
The newly created ObjectState tree.

Implements Serializable.

Definition at line 177 of file OperationTriggeredEncoding.cc.

177 {
180 for (unsigned int i = 0; i < fields_.size(); i++) {
182 ObjectState* fieldObj = it->saveState();
183 state->addChild(fieldObj);
184 }
185 return state;
186}
void setAttribute(const std::string &name, const std::string &value)
void addChild(ObjectState *child)
static const std::string OSNAME_OTA_ENCODING
virtual ObjectState * saveState() const

References ObjectState::addChild(), fields_, name_, OSKEY_OTA_ENCODING_NAME, OSNAME_OTA_ENCODING, OperationTriggeredField::saveState(), and ObjectState::setAttribute().

Referenced by InstructionFormat::saveState().

Here is the call graph for this function:

◆ setName()

void OperationTriggeredEncoding::setName ( const std::string &  name)

Sets the name of the instruction format.

Parameters
nameThe name of the instruction format.

Definition at line 106 of file OperationTriggeredEncoding.cc.

106 {
107 name_ = name;
108}

References name(), and name_.

Referenced by loadState().

Here is the call graph for this function:

◆ width()

int OperationTriggeredEncoding::width ( ) const
virtual

Returns the bit width of the instruction format.

Returns
Bit width of the instruction format.

Definition at line 128 of file OperationTriggeredEncoding.cc.

128 {
129 int width = 0;
130 for (unsigned int i = 0; i < fields_.size(); i++) {
131 OperationTriggeredField* field = fields_.at(i);
132 width += field->width();
133 }
134 return width;
135}

References fields_, width(), and OperationTriggeredField::width().

Referenced by InstructionFormat::width(), and width().

Here is the call graph for this function:

Member Data Documentation

◆ fields_

std::vector<OperationTriggeredField*> OperationTriggeredEncoding::fields_
private

◆ name_

std::string OperationTriggeredEncoding::name_
private

Definition at line 74 of file OperationTriggeredEncoding.hh.

Referenced by name(), saveState(), and setName().

◆ OSKEY_OTA_ENCODING_NAME

const std::string OperationTriggeredEncoding::OSKEY_OTA_ENCODING_NAME
static
Initial value:
=
"name"

Definition at line 69 of file OperationTriggeredEncoding.hh.

Referenced by loadState(), and saveState().

◆ OSNAME_OTA_ENCODING

const std::string OperationTriggeredEncoding::OSNAME_OTA_ENCODING
static
Initial value:
=
"ota-encoding"

Definition at line 68 of file OperationTriggeredEncoding.hh.

Referenced by InstructionFormat::loadState(), and saveState().


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