OpenASIP  2.0
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
BridgeEncoding Class Reference

#include <BridgeEncoding.hh>

Inheritance diagram for BridgeEncoding:
Inheritance graph
Collaboration diagram for BridgeEncoding:
Collaboration graph

Public Member Functions

 BridgeEncoding (const std::string &name, unsigned int encoding, unsigned int extraBits, SourceField &parent)
 
 BridgeEncoding (const ObjectState *state, SourceField &parent)
 
virtual ~BridgeEncoding ()
 
SourceFieldparent () const
 
std::string bridgeName () const
 
virtual int bitPosition () const
 
virtual ObjectStatesaveState () const
 
- Public Member Functions inherited from Encoding
virtual ~Encoding ()
 
InstructionFieldparent () const
 
unsigned int encoding () const
 
unsigned int extraBits () const
 
virtual int width () const
 

Static Public Attributes

static const std::string OSNAME_BRIDGE_ENCODING = "bridge_encoding"
 ObjectState name for bridge encoding. More...
 
static const std::string OSKEY_BRIDGE_NAME = "bridge_name"
 ObjectState attribute key for the name of the bridge. More...
 
- Static Public Attributes inherited from Encoding
static const std::string OSNAME_ENCODING = "encoding"
 ObjectState name for Encoding class. More...
 
static const std::string OSKEY_ENCODING = "encoding"
 ObjectState attribute key for the encoding. More...
 
static const std::string OSKEY_EXTRA_BITS = "extra_bits"
 ObjectState attribute key for the number of extra bits. More...
 

Private Attributes

std::string bridge_
 Name of the bridge. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Encoding
 Encoding (unsigned int encoding, unsigned int extraBits, InstructionField *parent)
 
 Encoding (const ObjectState *state, InstructionField *parent)
 
void setParent (InstructionField *parent)
 
void setEncoding (unsigned int encoding, unsigned int extraBits)
 

Detailed Description

Class BridgeEncoding maps a bridge to a binary encoding.

Definition at line 47 of file BridgeEncoding.hh.

Constructor & Destructor Documentation

◆ BridgeEncoding() [1/2]

BridgeEncoding::BridgeEncoding ( const std::string &  name,
unsigned int  encoding,
unsigned int  extraBits,
SourceField parent 
)

The constructor.

Creates an encoding for the given bridge and registers it into the given source field.

Parameters
nameName of the bridge.
encodingThe encoding.
extraBitsThe number of extra (zero) bits in the encoding.
parentThe parent source field.
Exceptions
ObjectAlreadyExistsIf the parent source field has an encoding for this bridge already or if the encoding is ambiguous with some other encoding.

Definition at line 60 of file BridgeEncoding.cc.

63  : Encoding(encoding, extraBits, NULL), bridge_(name) {
65  setParent(&parent);
66 }

References SourceField::addBridgeEncoding(), parent(), and Encoding::setParent().

Here is the call graph for this function:

◆ BridgeEncoding() [2/2]

BridgeEncoding::BridgeEncoding ( const ObjectState state,
SourceField parent 
)

The constructor.

Loads the state of the object from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
parentThe parent source field.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.
ObjectAlreadyExistsIf the parent source field has an encoding for this bridge already or if the encoding is ambiguous with some other encoding.

Definition at line 81 of file BridgeEncoding.cc.

82  : Encoding(state, NULL), bridge_("") {
83  const string procName = "BridgeEncoding::BridgeEncoding";
84 
85  if (state->name() != OSNAME_BRIDGE_ENCODING) {
86  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
87  }
88 
89  try {
91  } catch (const Exception& exception) {
93  __FILE__, __LINE__, procName, exception.errorMessage());
94  }
95 
97  setParent(&parent);
98 }

References SourceField::addBridgeEncoding(), bridge_, Exception::errorMessage(), ObjectState::name(), OSKEY_BRIDGE_NAME, OSNAME_BRIDGE_ENCODING, parent(), Encoding::setParent(), and ObjectState::stringAttribute().

Here is the call graph for this function:

◆ ~BridgeEncoding()

BridgeEncoding::~BridgeEncoding ( )
virtual

The destructor.

Definition at line 103 of file BridgeEncoding.cc.

103  {
104  SourceField* parent = this->parent();
105  setParent(NULL);
107 }

References parent(), SourceField::removeBridgeEncoding(), and Encoding::setParent().

Here is the call graph for this function:

Member Function Documentation

◆ bitPosition()

int BridgeEncoding::bitPosition ( ) const
virtual

Returns the position of the bridge encoding within the source field.

Returns
The position.

Implements Encoding.

Definition at line 145 of file BridgeEncoding.cc.

145  {
146  if (parent()->componentIDPosition() == BinaryEncoding::RIGHT) {
147  return 0;
148  } else {
149  return parent()->width() - parent()->extraBits() - width();
150  }
151 }

References InstructionField::extraBits(), parent(), BinaryEncoding::RIGHT, Encoding::width(), and SourceField::width().

Here is the call graph for this function:

◆ bridgeName()

std::string BridgeEncoding::bridgeName ( ) const

Returns the name of the bridge.

Returns
The name of the bridge.

Definition at line 134 of file BridgeEncoding.cc.

134  {
135  return bridge_;
136 }

References bridge_.

Referenced by SourceField::addBridgeEncoding(), SourceField::bridgeEncoding(), SourceField::hasBridgeEncoding(), printSourceFieldEncodings(), and saveState().

◆ parent()

SourceField * BridgeEncoding::parent ( ) const

Returns the parent source field.

Returns
The parent source field.

Definition at line 116 of file BridgeEncoding.cc.

116  {
118  if (parent != NULL) {
119  SourceField* sField = dynamic_cast<SourceField*>(parent);
120  assert(sField != NULL);
121  return sField;
122  } else {
123  return NULL;
124  }
125 }

References assert, and Encoding::parent().

Referenced by SourceField::addBridgeEncoding(), bitPosition(), BridgeEncoding(), SourceField::removeBridgeEncoding(), and ~BridgeEncoding().

Here is the call graph for this function:

◆ saveState()

ObjectState * BridgeEncoding::saveState ( ) const
virtual

Saves the state of the object to an ObjectState instance.

Returns
The newly created ObjectState instance.

Reimplemented from Encoding.

Definition at line 160 of file BridgeEncoding.cc.

160  {
161  ObjectState* state = Encoding::saveState();
164  return state;
165 }

References bridgeName(), OSKEY_BRIDGE_NAME, OSNAME_BRIDGE_ENCODING, Encoding::saveState(), ObjectState::setAttribute(), and ObjectState::setName().

Referenced by SourceField::saveState().

Here is the call graph for this function:

Member Data Documentation

◆ bridge_

std::string BridgeEncoding::bridge_
private

Name of the bridge.

Definition at line 68 of file BridgeEncoding.hh.

Referenced by BridgeEncoding(), and bridgeName().

◆ OSKEY_BRIDGE_NAME

const std::string BridgeEncoding::OSKEY_BRIDGE_NAME = "bridge_name"
static

ObjectState attribute key for the name of the bridge.

Definition at line 64 of file BridgeEncoding.hh.

Referenced by BridgeEncoding(), saveState(), BEMSerializer::sourceFieldToFile(), and BEMSerializer::sourceFieldToOM().

◆ OSNAME_BRIDGE_ENCODING

const std::string BridgeEncoding::OSNAME_BRIDGE_ENCODING = "bridge_encoding"
static

The documentation for this class was generated from the following files:
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
ObjectStateLoadingException
Definition: Exception.hh:551
BridgeEncoding::parent
SourceField * parent() const
Definition: BridgeEncoding.cc:116
Encoding::setParent
void setParent(InstructionField *parent)
Definition: Encoding.cc:155
Encoding::parent
InstructionField * parent() const
Definition: Encoding.cc:97
ObjectState
Definition: ObjectState.hh:59
ObjectState::setName
void setName(const std::string &name)
BridgeEncoding::OSNAME_BRIDGE_ENCODING
static const std::string OSNAME_BRIDGE_ENCODING
ObjectState name for bridge encoding.
Definition: BridgeEncoding.hh:62
InstructionField
Definition: InstructionField.hh:43
assert
#define assert(condition)
Definition: Application.hh:86
Encoding::width
virtual int width() const
Definition: Encoding.cc:130
BridgeEncoding::bridge_
std::string bridge_
Name of the bridge.
Definition: BridgeEncoding.hh:68
SourceField::removeBridgeEncoding
void removeBridgeEncoding(BridgeEncoding &encoding)
Definition: SourceField.cc:154
SourceField::width
virtual int width() const
Definition: SourceField.cc:308
BridgeEncoding::bridgeName
std::string bridgeName() const
Definition: BridgeEncoding.cc:134
Encoding::encoding
unsigned int encoding() const
Definition: Encoding.cc:108
Exception
Definition: Exception.hh:54
ObjectState::name
std::string name() const
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
BridgeEncoding::OSKEY_BRIDGE_NAME
static const std::string OSKEY_BRIDGE_NAME
ObjectState attribute key for the name of the bridge.
Definition: BridgeEncoding.hh:64
Encoding::saveState
virtual ObjectState * saveState() const
Definition: Encoding.cc:141
InstructionField::extraBits
int extraBits() const
Definition: InstructionField.cc:229
Encoding::Encoding
Encoding(unsigned int encoding, unsigned int extraBits, InstructionField *parent)
Definition: Encoding.cc:53
BinaryEncoding::RIGHT
@ RIGHT
Definition: BinaryEncoding.hh:65
SourceField::addBridgeEncoding
void addBridgeEncoding(BridgeEncoding &encoding)
Definition: SourceField.cc:130
Encoding::extraBits
unsigned int extraBits() const
Definition: Encoding.cc:119
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
SourceField
Definition: SourceField.hh:48