OpenASIP
2.0
|
#include <Segment.hh>
Public Member Functions | |
Segment (const std::string &name, Bus &parent) | |
Segment (const ObjectState *state, Bus &parent) | |
~Segment () | |
void | setName (const std::string &name) |
std::string | name () const |
void | attachSocket (Socket &socket) |
void | detachSocket (Socket &socket) |
void | detachAllSockets () |
bool | isConnectedTo (const Socket &socket) const |
const Connection & | connection (const Socket &socket) const |
Socket * | connection (int index) const |
int | connectionCount () const |
Bus * | parentBus () const |
void | moveBefore (Segment &segment) |
void | moveAfter (Segment &segment) |
bool | hasSourceSegment () const |
bool | hasDestinationSegment () const |
Segment * | sourceSegment () const |
Segment * | destinationSegment () const |
virtual ObjectState * | saveState () const |
virtual void | loadState (const ObjectState *state) |
Public Member Functions inherited from Serializable | |
virtual | ~Serializable () |
Static Public Attributes | |
static const std::string | OSNAME_SEGMENT = "segment" |
ObjectState name for Segment. More... | |
static const std::string | OSKEY_NAME = "name" |
ObjectState attribute key for segment name. More... | |
static const std::string | OSKEY_DESTINATION = "destination" |
ObjectState attribute key for destination segment name. More... | |
Private Types | |
typedef std::vector< const Connection * > | ConnectionTable |
Vector of Connection pointers. More... | |
Private Member Functions | |
void | loadStateWithoutReferences (const ObjectState *state) |
void | removeConnection (const Connection *connection) |
Private Attributes | |
std::string | name_ |
Name of the segment. More... | |
Bus * | parent_ |
The parent bus. More... | |
Segment * | sourceSegment_ |
Source segment. More... | |
Segment * | destinationSegment_ |
Destination segment. More... | |
ConnectionTable | connections_ |
Contains all the connections to sockets. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from TTAMachine::SubComponent | |
SubComponent () | |
virtual | ~SubComponent () |
Protected Member Functions inherited from TTAMachine::MachinePart | |
MachinePart () | |
virtual | ~MachinePart () |
Represents a segment of a bus.
Definition at line 54 of file Segment.hh.
|
private |
Vector of Connection pointers.
Definition at line 95 of file Segment.hh.
TTAMachine::Segment::Segment | ( | const std::string & | name, |
Bus & | parent | ||
) |
Constructor.
The segment is appended at the end of the segment chain of its parent bus.
name | Name of the segment. |
parent | The bus this segment belongs to (parent bus). |
ComponentAlreadyExists | If a segment with the same name already exists in the same segment chain. |
InvalidName | If the given name is not a valid component name. |
Definition at line 70 of file Segment.cc.
References TTAMachine::Bus::addSegment(), destinationSegment_, MachineTester::isValidComponentName(), name(), parent_, TTAMachine::Bus::segment(), TTAMachine::Bus::segmentCount(), and sourceSegment_.
TTAMachine::Segment::Segment | ( | const ObjectState * | state, |
Bus & | parent | ||
) |
Constructor.
Creates a skeleton segment with name only. This method should be called by Bus::loadStateWithoutReferences only. Do not use this constructor.
state | The ObjectState instance from which the name is loaded. |
parent | The bus this segment belongs to (parent bus). |
ComponentAlreadyExists | If a segment with the same name already exists in the given parent bus. |
ObjectStateLoadingException | If an error occurs while loading the state. |
Definition at line 106 of file Segment.cc.
References TTAMachine::Bus::addSegment(), loadStateWithoutReferences(), and parent_.
TTAMachine::Segment::~Segment | ( | ) |
Destructor.
Detaches all the sockets before destruction.
Definition at line 121 of file Segment.cc.
References destinationSegment_, detachAllSockets(), parent_, parentBus(), TTAMachine::Bus::removeSegment(), and sourceSegment_.
void TTAMachine::Segment::attachSocket | ( | Socket & | socket | ) |
Connects a socket to the segment.
socket | Socket to be connected. |
IllegalRegistration | If socket and segment do not belong to the same machine. |
IllegalConnectivity | If the connection would violate a connectivity constraint. |
Definition at line 180 of file Segment.cc.
References assert, TTAMachine::Socket::attachBus(), MachineTester::canConnect(), TTAMachine::Socket::connection(), connections_, TTAMachine::Component::ensureRegistration(), isConnectedTo(), TTAMachine::Socket::isConnectedTo(), TTAMachine::Component::machine(), TTAMachine::Machine::machineTester(), parentBus(), and MachineTestReporter::socketSegmentConnectionError().
Referenced by TTAMachine::Socket::attachBus(), VLIWConnectIC::explore(), and BlocksConnectIC::explore().
const Connection & TTAMachine::Segment::connection | ( | const Socket & | socket | ) | const |
Returns the Connection object which joins this segment and the given socket.
The connection must exist before calling this method. This method is not intended for clients. Do not use this method.
socket | Socket which is attached to this segment. |
Definition at line 250 of file Segment.cc.
References assert, and connections_.
Referenced by BEMValidator::checkDestinationField(), BEMValidator::checkSourceField(), SegmentFactory::createEditPart(), detachSocket(), CostEstimator::Estimator::findAllICPaths(), DefaultICGenerator::inputSockets(), BEMValidator::needsSourceField(), DefaultICGenerator::outputSockets(), removeConnection(), BusBroker::setupResourceLinks(), BEMGenerator::socket(), BEMGenerator::socketCount(), ConnectionSweeper::sweepBypasses(), and ConnectionSweeper::sweepRFs().
Socket * TTAMachine::Segment::connection | ( | int | index | ) | const |
Returns the connected socket by the given index.
The index must be greater or equal to 0 and less than the number of socket connections.
index | Index. |
OutOfRange | If the given index is out of range. |
Definition at line 300 of file Segment.cc.
References connectionCount(), and connections_.
int TTAMachine::Segment::connectionCount | ( | ) | const |
Referenced by BusBroker::buildResources(), BEMValidator::checkDestinationField(), BEMValidator::checkSourceField(), connection(), SegmentFactory::createEditPart(), CostEstimator::Estimator::findAllICPaths(), DefaultICGenerator::inputSockets(), DefaultICGenerator::isBusConnected(), CostEstimator::Estimator::longestPath(), BEMValidator::needsSourceField(), DefaultICGenerator::outputSockets(), BusBroker::setupResourceLinks(), BEMGenerator::socket(), BEMGenerator::socketCount(), ConnectionSweeper::sweepBypasses(), ConnectionSweeper::sweepRFs(), and MachineConnectivityCheck::totalConnectionCount().
Segment* TTAMachine::Segment::destinationSegment | ( | ) | const |
Referenced by BusDialog::onSegmentDown(), and TTAMachine::Bus::segment().
void TTAMachine::Segment::detachAllSockets | ( | ) |
Detaches all the sockets attached to the segment.
Definition at line 229 of file Segment.cc.
References connections_, and detachSocket().
Referenced by loadState(), and ~Segment().
void TTAMachine::Segment::detachSocket | ( | Socket & | socket | ) |
Detaches socket from the segment.
socket | Socket which is detached. |
InstanceNotFound | If the segment is not attached to the given socket. |
Definition at line 210 of file Segment.cc.
References connection(), TTAMachine::Socket::detachBus(), isConnectedTo(), TTAMachine::Socket::isConnectedTo(), and removeConnection().
Referenced by detachAllSockets(), TTAMachine::Socket::detachBus(), and ConnectionSweeper::removeConnection().
bool TTAMachine::Segment::hasDestinationSegment | ( | ) | const |
Returns true if the segment has a destination segment, otherwise false.
Definition at line 399 of file Segment.cc.
References destinationSegment_.
Referenced by BusDialog::onSegmentDown().
bool TTAMachine::Segment::hasSourceSegment | ( | ) | const |
Returns true if the segment has a source segment, otherwise false.
Definition at line 388 of file Segment.cc.
References sourceSegment_.
Referenced by BusDialog::onSegmentUp(), and TTAMachine::Bus::segment().
bool TTAMachine::Segment::isConnectedTo | ( | const Socket & | socket | ) | const |
Checks whether the segment is connected to the given socket.
socket | Socket. |
Definition at line 274 of file Segment.cc.
References connections_.
Referenced by TTAMachine::Socket::attachBus(), attachSocket(), TTAMachine::Socket::detachBus(), detachSocket(), BlocksConnectIC::explore(), and TTAMachine::Connection::~Connection().
|
virtual |
Loads the state of the segment from the given ObjectState instance.
Loads only name of the segment. Does not load connections to sockets. The destination of the segment and the order the segments in the chain is set later, in Bus::loadState.
state | The ObjectState instance. |
ObjectStateLoadingException | If the parent bus has a segment with the same name that is assigned to this segment or if the ObjectState tree is invalid. |
Implements Serializable.
Definition at line 448 of file Segment.cc.
References detachAllSockets(), loadStateWithoutReferences(), ObjectState::name(), and OSNAME_SEGMENT.
Referenced by TTAMachine::Bus::loadState().
|
private |
Loads the state of the object from the given ObjectState instance without references to other machine parts.
state | The ObjectState instance. |
ObjectStateLoadingException | If the given ObjectState instance is invalid. |
Definition at line 469 of file Segment.cc.
References Exception::errorMessage(), TTAMachine::Bus::hasSegment(), MachineTester::isValidComponentName(), name(), ObjectState::name(), name_, OSKEY_NAME, OSNAME_SEGMENT, parent_, and ObjectState::stringAttribute().
Referenced by loadState(), and Segment().
void TTAMachine::Segment::moveAfter | ( | Segment & | segment | ) |
Moves the segment behind the given segment in the segment chain.
The successor of this segment will become the successor of the current predecessor of this segment. The current successor of the given segment will become the successor the this segment.
segment | The segment behind of which the segment is moved. |
IllegalRegistration | If the given segment is in different bus than this segment. |
Definition at line 357 of file Segment.cc.
References destinationSegment_, parentBus(), and sourceSegment_.
Referenced by BusDialog::onSegmentDown().
void TTAMachine::Segment::moveBefore | ( | Segment & | segment | ) |
Moves the segment to the front of the given segment in the segment chain.
The successor of this segment will become the successor of the current predecessor of this segment. The current predecessor of the given segment will become the predecessor of this segment.
segment | The segment in front of which the segment is moved. |
IllegalRegistration | If the given segment is in different bus than this segment. |
Definition at line 320 of file Segment.cc.
References destinationSegment_, parentBus(), and sourceSegment_.
Referenced by TTAMachine::Bus::adjustSegmentChain(), and BusDialog::onSegmentUp().
std::string TTAMachine::Segment::name | ( | ) | const |
Referenced by TTAMachine::Bus::addSegment(), TTAMachine::Bus::adjustSegmentChain(), ADFCombiner::createBus(), InfoBussesCommand::execute(), ProDeSegmentEditPolicy::getCommand(), loadStateWithoutReferences(), BusDialog::onSegmentDown(), BusDialog::onSegmentUp(), ProgrammabilityValidator::printConnection(), saveState(), Segment(), setName(), MachineTestReporter::socketSegmentConnectionError(), and SocketDialog::updateConnected().
Bus* TTAMachine::Segment::parentBus | ( | ) | const |
Referenced by ProgrammabilityValidator::addConnectionToProgram(), TTAMachine::Bus::addSegment(), MachineConnectivityCheck::appendConnectedDestinationBuses(), MachineConnectivityCheck::appendConnectedSourceBuses(), TTAMachine::Socket::attachBus(), attachSocket(), MachineConnectivityCheck::busConnectedToPort(), MachineTester::canConnect(), ProDeSocketEditPolicy::canHandle(), MachineConnectivityCheck::canWriteAllImmediates(), DefaultDecoderGenerator::connectedBuses(), BlocksTranslator::CreateConnection(), SegmentFactory::createEditPart(), VLIWConnectIC::explore(), BlocksConnectIC::explore(), ProgrammabilityValidator::findRegisterGuard(), ProximBusEditPolicy::getCommand(), moveAfter(), moveBefore(), ProgrammabilityValidator::printConnection(), ConnectionSweeper::removeConnection(), TTAMachine::Bus::removeSegment(), setName(), InputPSocketBroker::setupResourceLinks(), OutputPSocketBroker::setupResourceLinks(), DefaultICDecoderEstimator::socketParameters(), MachineTestReporter::socketSegmentConnectionError(), SocketDialog::updateConnected(), DefaultICGenerator::writeInterconnectionNetwork(), and ~Segment().
|
private |
Removes connection from the connection table.
connection | Connection to be removed. |
Definition at line 410 of file Segment.cc.
References connection(), connections_, and ContainerTools::removeValueIfExists().
Referenced by detachSocket().
|
virtual |
Saves the contents of the segment to an ObjectState object.
Implements Serializable.
Definition at line 421 of file Segment.cc.
References destinationSegment_, name(), OSKEY_DESTINATION, OSKEY_NAME, OSNAME_SEGMENT, and ObjectState::setAttribute().
Referenced by TTAMachine::Bus::saveState().
void TTAMachine::Segment::setName | ( | const std::string & | name | ) |
Sets the name of the segment.
name | Name of the segment. |
ComponentAlreadyExists | If a segment with the given name already exists in the segment chain of the parent bus. |
InvalidName | If the given name is not a valid component name. |
Definition at line 148 of file Segment.cc.
References MachineTester::isValidComponentName(), name(), name_, parentBus(), TTAMachine::Bus::segment(), and TTAMachine::Bus::segmentCount().
Segment* TTAMachine::Segment::sourceSegment | ( | ) | const |
Referenced by BusDialog::onSegmentUp().
|
private |
Contains all the connections to sockets.
Definition at line 109 of file Segment.hh.
Referenced by attachSocket(), connection(), detachAllSockets(), isConnectedTo(), and removeConnection().
|
private |
Destination segment.
Definition at line 107 of file Segment.hh.
Referenced by hasDestinationSegment(), moveAfter(), moveBefore(), saveState(), Segment(), and ~Segment().
|
private |
Name of the segment.
Definition at line 101 of file Segment.hh.
Referenced by loadStateWithoutReferences(), and setName().
|
static |
ObjectState attribute key for destination segment name.
Definition at line 91 of file Segment.hh.
Referenced by TTAMachine::Bus::adjustSegmentChain(), and saveState().
|
static |
ObjectState attribute key for segment name.
Definition at line 89 of file Segment.hh.
Referenced by TTAMachine::Bus::adjustSegmentChain(), TTAMachine::Bus::loadState(), loadStateWithoutReferences(), TTAMachine::Bus::loadStateWithoutReferences(), and saveState().
|
static |
ObjectState name for Segment.
Definition at line 87 of file Segment.hh.
Referenced by TTAMachine::Bus::adjustSegmentChain(), loadState(), TTAMachine::Bus::loadState(), loadStateWithoutReferences(), TTAMachine::Bus::loadStateWithoutReferences(), and saveState().
|
private |
The parent bus.
Definition at line 103 of file Segment.hh.
Referenced by loadStateWithoutReferences(), Segment(), and ~Segment().
|
private |
Source segment.
Definition at line 105 of file Segment.hh.
Referenced by hasSourceSegment(), moveAfter(), moveBefore(), Segment(), and ~Segment().