OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
static const std::string OSKEY_SOCKET = "socket"
 ObjectState attribute key for socket name.
 
static const std::string OSKEY_BUS = "bus"
 ObjectState attribute key for bus name.
 
static const std::string OSKEY_SEGMENT = "segment"
 ObjectState attribute key for segment name.
 

Private Attributes

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

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}
Segment * bus_
Bus which is connected to the socket.
Definition Connection.hh:70
Socket * socket() const
Socket * socket_
Socket which is connected to the bus.
Definition Connection.hh:68
Segment * bus() const

◆ ~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}
#define assert(condition)
bool isConnectedTo(const Socket &socket) const
Definition Segment.cc:274
bool isConnectedTo(const Bus &bus) const
Definition Socket.cc:331
void detachBus(Segment &bus)
Definition Socket.cc:213

References assert, bus_, TTAMachine::Socket::detachBus(), TTAMachine::Socket::isConnectedTo(), TTAMachine::Segment::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}
void setAttribute(const std::string &name, const std::string &value)
static const std::string OSKEY_SEGMENT
ObjectState attribute key for segment name.
Definition Connection.hh:64
static const std::string OSKEY_BUS
ObjectState attribute key for bus name.
Definition Connection.hh:62
static const std::string OSKEY_SOCKET
ObjectState attribute key for socket name.
Definition Connection.hh:60
static const std::string OSNAME_CONNECTION
ObjectState name for Connection.
Definition Connection.hh:58

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(), saveState(), ADFSerializer::socketToMachine(), and ADFSerializer::socketToMDF().

◆ 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(), saveState(), ADFSerializer::socketToMachine(), and ADFSerializer::socketToMDF().

◆ 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(), and ADFSerializer::socketToMachine().

◆ OSNAME_CONNECTION

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

◆ 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: