OpenASIP
2.0
|
#include <Bridge.hh>
Public Member Functions | |
Bridge (const std::string &name, Bus &sourceBus, Bus &destinationBus) | |
Bridge (const ObjectState *state, Machine &mach) | |
virtual | ~Bridge () |
virtual void | setName (const std::string &name) |
Bus * | sourceBus () const |
Bus * | destinationBus () const |
Bus * | previousBus () const |
Bus * | nextBus () const |
virtual void | setMachine (Machine &mach) |
virtual void | unsetMachine () |
virtual ObjectState * | saveState () const |
virtual void | loadState (const ObjectState *state) |
Public Member Functions inherited from TTAMachine::Component | |
virtual | ~Component () |
virtual TCEString | name () const |
virtual Machine * | machine () 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_BRIDGE = "bridge" |
ObjectState name for bridge. More... | |
static const std::string | OSKEY_SOURCE_BUS = "source" |
ObjectState attribute key for source bus name. More... | |
static const std::string | OSKEY_DESTINATION_BUS = "destination" |
ObjectState attribute key for destination bus name. More... | |
Static Public Attributes inherited from TTAMachine::Component | |
static const std::string | OSNAME_COMPONENT = "component" |
ObjectState name for component. More... | |
static const std::string | OSKEY_NAME = "name" |
ObjectState attribute key for the name of the component. More... | |
Private Member Functions | |
void | adjustChainDirection (const Bus &sourceBus, const Bus &destinationBus) |
void | setSourceAndDestination (Bus &sourceBus, Bus &destination) |
Static Private Member Functions | |
static void | setFirstOfChain (const Bus &bus) |
Private Attributes | |
Bus * | sourceBus_ |
Source bus. More... | |
Bus * | destinationBus_ |
Destination bus. More... | |
bool | sourcePrevious_ |
Indicates which of the buses is previous and next. More... | |
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 () |
Constructor.
name | Name of the bridge. |
sourceBus | Bus from which the bridge reads data. |
destinationBus | Bus to which the bridge writes data. |
IllegalRegistration | If the given source and destination buses are not registered to the same machine. |
ComponentAlreadyExists | If there is another bridge by the same name in the machine which contains the source and destination buses. |
IllegalConnectivity | If the bridge cannot be created because it would violate a connectivity constraint. |
IllegalParameters | If the given buses are the same instance. |
InvalidName | If the given name is not a valid component name. |
Definition at line 74 of file Bridge.cc.
References MachineTestReporter::bridgingError(), MachineTester::canBridge(), destinationBus(), TTAMachine::Component::ensureRegistration(), TTAMachine::Component::machine(), TTAMachine::Machine::machineTester(), setMachine(), setSourceAndDestination(), and sourceBus().
TTAMachine::Bridge::Bridge | ( | const ObjectState * | state, |
Machine & | mach | ||
) |
Constructor.
Creates a skeleton objects with name only. This constructor should be used by Machine::loadState only. Do not use this constructor.
state | The ObjectState instance. |
mach | The machine to which the bridge belongs. |
ObjectStateLoadingException | If the machine already has a bridge by the same name as the coming name of this bridge or if the ObjectState instance is invalid. |
Definition at line 107 of file Bridge.cc.
References TTAMachine::Machine::bridgeNavigator(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Component::name(), setMachine(), and Texts::TextGenerator::text().
|
virtual |
Destructor.
Definition at line 127 of file Bridge.cc.
References unsetMachine().
|
private |
Adjusts the direction of the bus chain (next/previous).
When two bus chains are joined by a new bridge the direction of the destination side chain may have to be changed to verify that the direction of the new longer chain does not change in the middle of the chain. That is, if the source bus of the new bridge is the last of its chain and the destination bus of the new bridge is also the last, the direction of the destination side chain has to be changed such that the destination bus will become the first bus of its chain.
sourceBus | The new source side bus. |
destinationBus | The new destination side bus. |
Definition at line 327 of file Bridge.cc.
References TTAMachine::Machine::bridgeNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), destinationBus(), TTAMachine::Bus::hasNextBus(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Bus::nextBus(), previousBus(), setFirstOfChain(), sourceBus(), and sourcePrevious_.
Referenced by setSourceAndDestination().
Bus* TTAMachine::Bridge::destinationBus | ( | ) | const |
Referenced by adjustChainDirection(), Bridge(), BEMValidator::checkSourceField(), TTAMachine::Bus::clearSourceBridge(), MachineEditPartFactory::connected(), BridgeFactory::createEditPart(), loadState(), setFirstOfChain(), setSourceAndDestination(), TTAMachine::Bus::setSourceBridge(), BEMGenerator::sourceBridge(), and BEMGenerator::sourceBridgeCount().
|
virtual |
Loads its state from the given ObjectState instance.
If the bridge is already joining two buses, the function will not work and ObjectStateLoadingException is thrown. This method works only if the bridge was created by the constructor with ObjectState argument.
state | The ObjectState instance. |
ObjectStateLoadingException | If the machine already a bridge by the same name as the coming name of this bridge or if creating references fails or if the given ObjectState instance is invalid. |
Reimplemented from TTAMachine::Component.
Definition at line 264 of file Bridge.cc.
References assert, MachineTestReporter::bridgingError(), TTAMachine::Machine::busNavigator(), MachineTester::canBridge(), destinationBus(), Exception::errorMessage(), TTAMachine::Component::isRegistered(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::loadState(), TTAMachine::Component::machine(), TTAMachine::Machine::machineTester(), ObjectState::name(), TTAMachine::Component::name(), OSKEY_DESTINATION_BUS, OSKEY_SOURCE_BUS, OSNAME_BRIDGE, setSourceAndDestination(), sourceBus(), ObjectState::stringAttribute(), Texts::TextGenerator::text(), and MOMTextGenerator::TXT_BRIDGE_UNKNOWN_SRC_OR_DST.
Referenced by TTAMachine::Machine::loadState().
Bus * TTAMachine::Bridge::nextBus | ( | ) | const |
Returns the next bus from location point of view.
Definition at line 179 of file Bridge.cc.
References destinationBus_, sourceBus_, and sourcePrevious_.
Referenced by TTAMachine::Bus::nextBus(), TTAMachine::Bus::previousBridge(), and setFirstOfChain().
Bus * TTAMachine::Bridge::previousBus | ( | ) | const |
Returns the previous bus from location point of view.
Definition at line 164 of file Bridge.cc.
References destinationBus_, sourceBus_, and sourcePrevious_.
Referenced by adjustChainDirection(), TTAMachine::Bus::nextBridge(), and TTAMachine::Bus::previousBus().
|
virtual |
Saves the contents to an ObjectState object.
Reimplemented from TTAMachine::Component.
Definition at line 238 of file Bridge.cc.
References destinationBus_, TTAMachine::Component::name(), OSKEY_DESTINATION_BUS, OSKEY_SOURCE_BUS, OSNAME_BRIDGE, TTAMachine::Component::saveState(), ObjectState::setAttribute(), ObjectState::setName(), and sourceBus_.
|
staticprivate |
Sets the given bus to the first bus of the bus chain.
That is, changes the direction of the chain if the given bus is currently the last bus of the chain. The given bus must be at the end of chain.
bus | The bus to be set to the first bus of the chain. |
Definition at line 400 of file Bridge.cc.
References assert, TTAMachine::Machine::bridgeNavigator(), AssocTools::containsKey(), TTAMachine::Machine::Navigator< ComponentType >::count(), destinationBus(), TTAMachine::Bus::hasNextBus(), TTAMachine::Bus::hasPreviousBus(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), nextBus(), TTAMachine::Bus::previousBus(), sourceBus(), and sourcePrevious_.
Referenced by adjustChainDirection().
|
virtual |
Registers the bridge to a machine.
mach | Machine to which the bridge is going to be registered. |
ComponentAlreadyExists | If the given machine already has another bridge by the same name. |
Implements TTAMachine::Component.
Definition at line 196 of file Bridge.cc.
References TTAMachine::Machine::addBridge(), and TTAMachine::Component::internalSetMachine().
Referenced by Bridge().
|
virtual |
Sets the name of the bridge.
name | Name of the bridge. |
ComponentAlreadyExists | If a bridge with the given name is already in the same machine. |
InvalidName | If the given name is not a valid component name. |
Reimplemented from TTAMachine::Component.
Definition at line 141 of file Bridge.cc.
References TTAMachine::Component::machine(), TTAMachine::Component::name(), and TTAMachine::Component::setName().
Sets the source and destination buses of the bridge.
The bridge must not have source and destination buses before calling this method.
sourceBus | The source bus. |
destinationBus | The destination bus. |
Definition at line 379 of file Bridge.cc.
References adjustChainDirection(), assert, TTAMachine::Bus::canRead(), TTAMachine::Bus::canWrite(), destinationBus(), destinationBus_, TTAMachine::Bus::setDestinationBridge(), TTAMachine::Bus::setSourceBridge(), sourceBus(), and sourceBus_.
Referenced by Bridge(), and loadState().
Bus* TTAMachine::Bridge::sourceBus | ( | ) | const |
|
virtual |
Removes registration of the bridge from its current machine.
The bridge is deleted because it cannot be unregistered from the machine.
Implements TTAMachine::Component.
Definition at line 207 of file Bridge.cc.
References assert, TTAMachine::Bus::clearDestinationBridge(), TTAMachine::Bus::clearSourceBridge(), TTAMachine::Machine::deleteBridge(), destinationBus_, TTAMachine::Component::internalUnsetMachine(), TTAMachine::Component::machine(), and sourceBus_.
Referenced by ~Bridge().
|
private |
Destination bus.
Definition at line 86 of file Bridge.hh.
Referenced by nextBus(), previousBus(), saveState(), setSourceAndDestination(), and unsetMachine().
|
static |
ObjectState attribute key for destination bus name.
Definition at line 74 of file Bridge.hh.
Referenced by loadState(), and saveState().
|
static |
ObjectState attribute key for source bus name.
Definition at line 72 of file Bridge.hh.
Referenced by loadState(), and saveState().
|
static |
ObjectState name for bridge.
Definition at line 70 of file Bridge.hh.
Referenced by loadState(), TTAMachine::Machine::loadState(), and saveState().
|
private |
Source bus.
Definition at line 84 of file Bridge.hh.
Referenced by nextBus(), previousBus(), saveState(), setSourceAndDestination(), and unsetMachine().
|
private |
Indicates which of the buses is previous and next.
Definition at line 88 of file Bridge.hh.
Referenced by adjustChainDirection(), nextBus(), previousBus(), and setFirstOfChain().