OpenASIP  2.0
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
TTAMachine::Connection Class Reference

#include <Connection.hh>

Collaboration diagram for TTAMachine::Connection:
Collaboration graph

Public Member Functions

 Connection (Socket &socket, Segment &bus)
 
 ~Connection ()
 
Segmentbus () const
 
Socketsocket () const
 
ObjectStatesaveState () const
 

Static Public Attributes

static const std::string OSNAME_CONNECTION = "connection"
 ObjectState name for Connection. More...
 
static const std::string OSKEY_SOCKET = "socket"
 ObjectState attribute key for socket name. More...
 
static const std::string OSKEY_BUS = "bus"
 ObjectState attribute key for bus name. More...
 
static const std::string OSKEY_SEGMENT = "segment"
 ObjectState attribute key for segment name. More...
 

Private Attributes

Socketsocket_
 Socket which is connected to the bus. More...
 
Segmentbus_
 Bus which is connected to the socket. More...
 

Detailed Description

Joins Bus and Socket objects if they are connected in the machine.

Definition at line 48 of file Connection.hh.

Constructor & Destructor Documentation

◆ Connection()

TTAMachine::Connection::Connection ( Socket socket,
Segment bus 
)

Constructor.

Parameters
socketSocket which is connected to the given segment.
busSegment of a bus which is connected to the socket.

Definition at line 58 of file Connection.cc.

58  :
59  socket_(&socket), bus_(&bus) {
60 }

◆ ~Connection()

TTAMachine::Connection::~Connection ( )

Destructor.

 If Connection object still joins a socket and a segment, they are detached before destructing the Connection object.

Definition at line 68 of file Connection.cc.

68  {
69  if (socket_->isConnectedTo(*bus_)) {
70  assert(bus_->isConnectedTo(*socket_)); // sanity check
71  socket_->detachBus(*bus_); // or bus_->detachSocket(socket_)
72  } else {
73  // this is for when destructor is called by a detach methods
75  }
76 }

References assert, bus_, TTAMachine::Socket::detachBus(), TTAMachine::Segment::isConnectedTo(), TTAMachine::Socket::isConnectedTo(), and socket_.

Here is the call graph for this function:

Member Function Documentation

◆ bus()

Segment* TTAMachine::Connection::bus ( ) const

◆ saveState()

ObjectState * TTAMachine::Connection::saveState ( ) const

Saves its state to an ObjectState instance.

Returns
The newly created ObjectState instance.

Definition at line 85 of file Connection.cc.

85  {
87  state->setAttribute(OSKEY_SOCKET, socket()->name());
88  state->setAttribute(OSKEY_BUS, bus()->parentBus()->name());
89  state->setAttribute(OSKEY_SEGMENT, bus()->name());
90  return state;
91 }

References bus(), OSKEY_BUS, OSKEY_SEGMENT, OSKEY_SOCKET, OSNAME_CONNECTION, ObjectState::setAttribute(), and socket().

Referenced by TTAMachine::Socket::saveState().

Here is the call graph for this function:

◆ socket()

Socket* TTAMachine::Connection::socket ( ) const

Member Data Documentation

◆ bus_

Segment* TTAMachine::Connection::bus_
private

Bus which is connected to the socket.

Definition at line 70 of file Connection.hh.

Referenced by ~Connection().

◆ OSKEY_BUS

const string TTAMachine::Connection::OSKEY_BUS = "bus"
static

ObjectState attribute key for bus name.

Definition at line 62 of file Connection.hh.

Referenced by TTAMachine::Socket::loadState(), and saveState().

◆ OSKEY_SEGMENT

const string TTAMachine::Connection::OSKEY_SEGMENT = "segment"
static

ObjectState attribute key for segment name.

Definition at line 64 of file Connection.hh.

Referenced by TTAMachine::Socket::loadState(), and saveState().

◆ OSKEY_SOCKET

const string TTAMachine::Connection::OSKEY_SOCKET = "socket"
static

ObjectState attribute key for socket name.

Definition at line 60 of file Connection.hh.

Referenced by saveState().

◆ OSNAME_CONNECTION

const string TTAMachine::Connection::OSNAME_CONNECTION = "connection"
static

ObjectState name for Connection.

Definition at line 58 of file Connection.hh.

Referenced by TTAMachine::Socket::loadState(), and saveState().

◆ socket_

Socket* TTAMachine::Connection::socket_
private

Socket which is connected to the bus.

Definition at line 68 of file Connection.hh.

Referenced by ~Connection().


The documentation for this class was generated from the following files:
TTAMachine::Connection::socket
Socket * socket() const
ObjectState
Definition: ObjectState.hh:59
TTAMachine::Connection::bus_
Segment * bus_
Bus which is connected to the socket.
Definition: Connection.hh:70
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::Connection::bus
Segment * bus() const
TTAMachine::Segment::isConnectedTo
bool isConnectedTo(const Socket &socket) const
Definition: Segment.cc:274
TTAMachine::Socket::isConnectedTo
bool isConnectedTo(const Bus &bus) const
Definition: Socket.cc:331
TTAMachine::Socket::detachBus
void detachBus(Segment &bus)
Definition: Socket.cc:213
TTAMachine::Connection::OSKEY_BUS
static const std::string OSKEY_BUS
ObjectState attribute key for bus name.
Definition: Connection.hh:62
TTAMachine::Connection::OSKEY_SEGMENT
static const std::string OSKEY_SEGMENT
ObjectState attribute key for segment name.
Definition: Connection.hh:64
TTAMachine::Connection::socket_
Socket * socket_
Socket which is connected to the bus.
Definition: Connection.hh:68
TTAMachine::Connection::OSKEY_SOCKET
static const std::string OSKEY_SOCKET
ObjectState attribute key for socket name.
Definition: Connection.hh:60
TTAMachine::Connection::OSNAME_CONNECTION
static const std::string OSNAME_CONNECTION
ObjectState name for Connection.
Definition: Connection.hh:58
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100