OpenASIP  2.0
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 }

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 }

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 }

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().

◆ 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 }

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++) {
181  OperationTriggeredField* it = fields_.at(i);
182  ObjectState* fieldObj = it->saveState();
183  state->addChild(fieldObj);
184  }
185  return state;
186 }

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_, and OperationTriggeredField::width().

Referenced by InstructionFormat::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:
OperationTriggeredEncoding::OSNAME_OTA_ENCODING
static const std::string OSNAME_OTA_ENCODING
Definition: OperationTriggeredEncoding.hh:68
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
ObjectStateLoadingException
Definition: Exception.hh:551
OperationTriggeredField::OSNAME_FIELD
static const std::string OSNAME_FIELD
Definition: OperationTriggeredField.hh:65
ObjectState
Definition: ObjectState.hh:59
OperationTriggeredEncoding::name_
std::string name_
Definition: OperationTriggeredEncoding.hh:74
OperationTriggeredField::saveState
virtual ObjectState * saveState() const
Definition: OperationTriggeredField.cc:170
ObjectState::child
ObjectState * child(int index) const
Definition: ObjectState.cc:471
ObjectState::addChild
void addChild(ObjectState *child)
Definition: ObjectState.cc:376
ObjectState::childCount
int childCount() const
Exception
Definition: Exception.hh:54
OperationTriggeredField
Definition: OperationTriggeredField.hh:43
ObjectState::name
std::string name() const
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
OperationTriggeredEncoding::setName
void setName(const std::string &name)
Definition: OperationTriggeredEncoding.cc:106
OperationTriggeredField::width
virtual int width() const
Definition: OperationTriggeredField.cc:126
OperationTriggeredEncoding::loadState
virtual void loadState(const ObjectState *state)
Definition: OperationTriggeredEncoding.cc:152
InstructionFormat::addEncoding
void addEncoding(OperationTriggeredEncoding &encoding)
Definition: InstructionFormat.cc:139
OperationTriggeredEncoding::name
std::string name() const
Definition: OperationTriggeredEncoding.cc:95
OperationTriggeredEncoding::fields_
std::vector< OperationTriggeredField * > fields_
Definition: OperationTriggeredEncoding.hh:76
OperationTriggeredEncoding::OSKEY_OTA_ENCODING_NAME
static const std::string OSKEY_OTA_ENCODING_NAME
Definition: OperationTriggeredEncoding.hh:69
OperationTriggeredEncoding::width
virtual int width() const
Definition: OperationTriggeredEncoding.cc:128
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100