OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
static const std::string OSKEY_BRIDGE_NAME = "bridge_name"
 ObjectState attribute key for the name of the bridge.
 
- Static Public Attributes inherited from Encoding
static const std::string OSNAME_ENCODING = "encoding"
 ObjectState name for Encoding class.
 
static const std::string OSKEY_ENCODING = "encoding"
 ObjectState attribute key for the encoding.
 
static const std::string OSKEY_EXTRA_BITS = "extra_bits"
 ObjectState attribute key for the number of extra bits.
 

Private Attributes

std::string bridge_
 Name of the bridge.
 

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) {
66}
std::string bridge_
Name of the bridge.
SourceField * parent() const
unsigned int extraBits() const
Definition Encoding.cc:119
void setParent(InstructionField *parent)
Definition Encoding.cc:155
unsigned int encoding() const
Definition Encoding.cc:108
void addBridgeEncoding(BridgeEncoding &encoding)

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
98}
static const std::string OSNAME_BRIDGE_ENCODING
ObjectState name for bridge encoding.
static const std::string OSKEY_BRIDGE_NAME
ObjectState attribute key for the name of the bridge.
std::string errorMessage() const
Definition Exception.cc:123
std::string stringAttribute(const std::string &name) const
std::string name() const

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}
void removeBridgeEncoding(BridgeEncoding &encoding)

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}
virtual int width() const
Definition Encoding.cc:130
virtual int width() const

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}
#define assert(condition)
InstructionField * parent() const
Definition Encoding.cc:97

References assert, parent(), and Encoding::parent().

Referenced by SourceField::addBridgeEncoding(), bitPosition(), BridgeEncoding(), BridgeEncoding(), parent(), 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 {
164 return state;
165}
std::string bridgeName() const
virtual ObjectState * saveState() const
Definition Encoding.cc:141
void setName(const std::string &name)
void setAttribute(const std::string &name, const std::string &value)

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: