torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::generic::Connectable Class Referenceabstract

An object that is connectable to a Net. More...

#include <Connectable.hpp>

+ Inheritance diagram for torc::generic::Connectable:

Public Types

typedef std::list
< NetSharedPtr >::iterator 
Connection
 
typedef
boost::signals2::signal< void(const
NetSharedPtr &)> 
Connected
 
typedef
boost::signals2::signal< void(const
NetSharedPtr &)> 
Disconnected
 

Public Member Functions

ConnectedsignalNetConnected ()
 
DisconnectedsignalNetDisconnected ()
 
virtual void getConnectedNets (std::vector< NetSharedPtr > &outNets, bool inSkipChildConnections=false) const throw (Error)
 
virtual Connection connect (const NetSharedPtr &inNet)=0 throw (Error)
 
virtual void disconnect (const Connection &inConnection)=0 throw (Error)
 
void disconnect (const std::string &inName) throw (Error)
 
void disconnect (const NetSharedPtr &net) throw (Error)
 
virtual void disconnect () throw (Error)
 

Protected Member Functions

virtual void onConnect () throw (Error)
 
virtual void onDisconnect () throw (Error)
 
 Connectable ()
 
virtual ~Connectable () throw ()
 

Private Member Functions

 Connectable (const Connectable &rhs)
 
Connectableoperator= (const Connectable &rhs)
 

Private Attributes

std::list< NetSharedPtrmConnectedNets
 
Connected mSigNetConnected
 
Disconnected mSigNetDisconnected
 

Detailed Description

An object that is connectable to a Net.

The Connectable class can act as a base for objects that can connect to a Net. This interface provides event functionality for connection and disconnection. It also provides polymorphic methods to implement connectivity beween different components in a design.

Definition at line 44 of file Connectable.hpp.

Member Typedef Documentation

typedef boost::signals2::signal<void(const NetSharedPtr&)> torc::generic::Connectable::Connected

A signal to indicate that a new connection has been made

Definition at line 57 of file Connectable.hpp.

A connection between a net and this object

Definition at line 52 of file Connectable.hpp.

typedef boost::signals2::signal<void(const NetSharedPtr&)> torc::generic::Connectable::Disconnected

A signal to indicate that a connection has been removed

Definition at line 62 of file Connectable.hpp.

Constructor & Destructor Documentation

torc::generic::Connectable::Connectable ( )
protected

Definition at line 151 of file Connectable.cpp.

torc::generic::Connectable::~Connectable ( )
throw (
)
protectedvirtual

Definition at line 153 of file Connectable.cpp.

153  {
154  mConnectedNets.clear();
155 }
std::list< NetSharedPtr > mConnectedNets
torc::generic::Connectable::Connectable ( const Connectable rhs)
private

Member Function Documentation

Connectable::Connection torc::generic::Connectable::connect ( const NetSharedPtr inNet)
throw (Error
)
pure virtual

Connect a Net to this object.

Note
This metod can be overridden by derived classes. However, the method must call the on_connected() method after this. The sigConnected_ signal must also be invoked in the overriding method.
Parameters
[in]inNetA pointer to the Net object that needs to be Connected
Returns
A connection that has been established. This can be used later for disconnection.

Connect a Net to this object.

Note
This metod can be overridden by derived classes. However, the method must call the on_connected() method after this. The sigConnected_ signal must also be invoked in the overriding method.
Parameters
[in]inNetA pointer to the Net object that eeds to be Connected
Returns
A connection that has been established. This can be used later for disconnection.

Implemented in torc::generic::VectorPortReference, torc::generic::PortBundleReference, torc::generic::VectorNet, torc::generic::PortBundle, torc::generic::NetBundle, torc::generic::VectorPort, torc::generic::ScalarPort, torc::generic::ScalarNet, torc::generic::ScalarPortReference, torc::generic::PortList, torc::generic::VectorNetBit, torc::generic::VectorPortBit, and torc::generic::VectorPortBitReference.

Definition at line 60 of file Connectable.cpp.

60  {
61  Connection connection = mConnectedNets.insert(mConnectedNets.end(), inNet);
62  try {
63  onConnect();
64  } catch(Error& e) {
65  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
66  throw;
67  }
68  signalNetConnected()(inNet);
69  return connection;
70 }
Connected & signalNetConnected()
std::list< NetSharedPtr >::iterator Connection
Definition: Connectable.hpp:52
std::list< NetSharedPtr > mConnectedNets

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::generic::Connectable::disconnect ( const Connection inConnection)
throw (Error
)
pure virtual

Disconnect a Net from this object.

Note
This metod can be overridden by derived classes. However, the method must call the on_connected() method after this. The sigConnected_ signal must also be invoked in the overriding method.
Parameters
[in]inConnectionA connection as returned by the connect() method
Exceptions
ErrorProvided connection is invalid

Implemented in torc::generic::VectorPortReference, torc::generic::PortBundleReference, torc::generic::PortBundle, torc::generic::VectorNet, torc::generic::VectorPort, torc::generic::NetBundle, torc::generic::ScalarPort, torc::generic::ScalarNet, torc::generic::ScalarPortReference, torc::generic::PortList, torc::generic::VectorNetBit, torc::generic::VectorPortBit, and torc::generic::VectorPortBitReference.

Definition at line 83 of file Connectable.cpp.

83  {
84  if(inConnection == mConnectedNets.end()) {
85  return;
86  }
87 
88  NetSharedPtr net = *inConnection;
89  mConnectedNets.erase(inConnection);
90  try {
91  onDisconnect();
92  } catch(Error& e) {
93  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
94  throw;
95  }
96  signalNetDisconnected()(net);
97  return;
98 }
Disconnected & signalNetDisconnected()
std::list< NetSharedPtr > mConnectedNets
boost::shared_ptr< Net > NetSharedPtr

+ Here is the call graph for this function:

void torc::generic::Connectable::disconnect ( const std::string &  inName)
throw (Error
)

Disconnect the named Net from this object.

Note
This metod can be overridden by derived classes. However, the method must call the on_connected() method after this. The sigConnected_ signal must also be invoked in the overriding method.
Parameters
[in]inNameName of the net to be Disconnected
Exceptions
ErrorProvided net was not found

Disconnect the named Net from this object.

Note
This metod can be overridden by derived classes. However, the method must call the on_connected() method after this. The sigConnected_ signal must also be invoked in the overriding method.
Parameters
[in]inNnameName of the net to be Disconnected
Exceptions
ErrorProvided net was not found

Definition at line 111 of file Connectable.cpp.

111  {
112  disconnect(std::find_if(mConnectedNets.begin(), mConnectedNets.end(),
113  boost::bind<bool>(std::equal_to<std::string>(),
114  boost::bind(boost::mem_fn(&Net::getName), _1), inName)));
115 }
std::list< NetSharedPtr > mConnectedNets
virtual const std::string getName() const
Definition: Nameable.hpp:89

+ Here is the call graph for this function:

void torc::generic::Connectable::disconnect ( const NetSharedPtr inNet)
throw (Error
)

Disconnect the given Net from this object.

Note
This metod can be overridden by derived classes. However, the method must call the on_disconnected() method after this. The sigDisconnected_ signal must also be invoked in the overriding method.
Parameters
[in]netPointer to a net
Exceptions
ErrorProvided net was not found

Disconnect the given Net from this object.

Note
This metod can be overridden by derived classes. However, the method must call the on_disconnected() method after this. The sigDisconnected_ signal must also be invoked in the overriding method.
Parameters
[in]inNetPointer to a net
Exceptions
ErrorProvided net was not found

Definition at line 128 of file Connectable.cpp.

128  {
129  disconnect(std::find(mConnectedNets.begin(), mConnectedNets.end(), inNet));
130 }
std::list< NetSharedPtr > mConnectedNets
void torc::generic::Connectable::disconnect ( )
throw (Error
)
virtual

Disconnect all connections to this port.

Reimplemented in torc::generic::Net, torc::generic::VectorNet, and torc::generic::NetBundle.

Definition at line 132 of file Connectable.cpp.

132  {
133  log("Disconnecting all\n");
134  std::vector<NetSharedPtr> nets;
135  getConnectedNets(nets, true);
136  for(std::vector<NetSharedPtr>::iterator it = nets.begin(); it != nets.end(); ++it) {
137  disconnect(*it);
138  }
139 }
void log(const char *fmt,...)
Definition: Log.cpp:89
virtual void getConnectedNets(std::vector< NetSharedPtr > &outNets, bool inSkipChildConnections=false) const
Definition: Connectable.cpp:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::generic::Connectable::getConnectedNets ( std::vector< NetSharedPtr > &  outNets,
bool  inSkipChildConnections = false 
) const
throw (Error
)
virtual

Get the vector of Nets that are Connected to the current object. The connected elements are appended to the given vector

Parameters
[out]outNetsA vector of Connected nets

Get the vector of Nets that are Connected to the current object. The connected elements are appended to the given vector

Returns
A vector of Connected nets

Reimplemented in torc::generic::VectorPortReference, torc::generic::VectorNet, torc::generic::VectorPort, torc::generic::VectorNetBit, torc::generic::VectorPortBit, and torc::generic::VectorPortBitReference.

Definition at line 45 of file Connectable.cpp.

46  {
47  outNets.insert(outNets.end(), mConnectedNets.begin(), mConnectedNets.end());
48 }
std::list< NetSharedPtr > mConnectedNets

+ Here is the caller graph for this function:

void torc::generic::Connectable::onConnect ( )
throw (Error
)
protectedvirtual

A polymorphic function that is called after a net is Connected to this object

Definition at line 144 of file Connectable.cpp.

144 {}
void torc::generic::Connectable::onDisconnect ( )
throw (Error
)
protectedvirtual

A polymorphic function that is called after a net is Disconnected from this object

Definition at line 149 of file Connectable.cpp.

149 {}
Connectable& torc::generic::Connectable::operator= ( const Connectable rhs)
private
Connectable::Connected & torc::generic::Connectable::signalNetConnected ( )
inline

A signal to indicate that a new connection has been made

Definition at line 167 of file Connectable.hpp.

167  {
168  return mSigNetConnected;
169 }
Connectable::Disconnected & torc::generic::Connectable::signalNetDisconnected ( )
inline

A signal to indicate that a new connection has been made

Definition at line 174 of file Connectable.hpp.

174  {
175  return mSigNetDisconnected;
176 }
Disconnected mSigNetDisconnected

Field Documentation

std::list<NetSharedPtr> torc::generic::Connectable::mConnectedNets
private

Definition at line 159 of file Connectable.hpp.

Connected torc::generic::Connectable::mSigNetConnected
private

Definition at line 160 of file Connectable.hpp.

Disconnected torc::generic::Connectable::mSigNetDisconnected
private

Definition at line 161 of file Connectable.hpp.


The documentation for this class was generated from the following files: