#include <Connector.h>
Public Member Functions | |
ConnectorBase (const char *conname, ConnectionBase &c, int mode) | |
The constructor takes a string for the name, the connection to use, and the transfer mode. | |
virtual | ~ConnectorBase () |
When destructed, this disconnects from its ConnectionBase (if any). | |
virtual void | disconnect ()=0 |
Do special activities to disconnect ourselves from the ConnectionBase. | |
virtual void | update ()=0 |
Update our connection, for example, transfer data or read/write a file. | |
virtual void | interact (const char *=0)=0 |
Allow for interaction with the connection. | |
virtual void | notify (ConnectionBase &c, int event) |
Get notified of something by our ConnectionBase object. | |
const std::string & | name () const |
Return the name of this connection. | |
bool | connected () const |
Are we connected to something? | |
ConnectionBase & | connection () const |
Return the connection we are using. | |
int | transferMode () const |
Return the data transfer mode. |
The other part of this API are the classes ConnectorBase and Connector<T,Tag>.
Connection<Tag> represents the information about how a "connection" is made to some external agency. Examples: files, Paws-based programs, visualization facilities. The parameter "Tag" is a simple tag class used to partially specialize Connection. This same tag is used in Connector.
Connector<T,Tag> represents the information about how to map data from a single instance of a type T to some Connection<Tag> object. For example, if data must be serialized into a buffer and an API routine for the "Tag" connection type called, Connector<T,Tag> will do that, for a given instance of T.
There can be several Connector<T,Tag> objects associated with a given Connection<Tag>. Each object maintains the "channel" for a data object to the connection. The connection object stores a list of connectors and provides an API for "updating" and "interacting" with the external agency.
ConnectorBase is a non-templated base class for all Connector<T,Tag> objects, used to store common information and provide a non-templated base class for heterogenous lists of connectors. It provides:
New connector's are added via a "connect" method in ConnectionBase. You can create your own Connector<T,Tag> instance, and add that in via connect(), or you can call a specialized (and generally templated) connect() method in the Connection<Tag> class. Most Connection classes provide the specialized connect in order to make it nicer to add in new connectors without having to instantiate a Connector<T,Tag> directly in user code.
When you update the connections, you ask each connector to do an update. Updates are done in the order they were connected. Each connector has a transfer mode, one of the following:
The transfer mode is established when the connector is added. An update causes new values to be imported or exported based on the current state of the data and the external agency. For a visualization connection, an update would result in new data being sent to the renderer and hopefully a new image drawn in the visualization program's display windows(s). You can update all connectors attached to a connection, or just one (by providing a pointer to the ConnectorBase of the connection you want to update).
When a connector is disconnected, it is told via a call to its virtual "notify" method that a disconnect has occurred. This lets the connector note that it will no longer be able to update, even though it may not yet have been deleted.
ConnectorBase::ConnectorBase | ( | const char * | conname, | |
ConnectionBase & | c, | |||
int | mode | |||
) | [inline] |
The constructor takes a string for the name, the connection to use, and the transfer mode.
References ConnectionBase::in, ConnectionBase::inout, ConnectionBase::out, and PAssert.
virtual ConnectorBase::~ConnectorBase | ( | ) | [inline, virtual] |
When destructed, this disconnects from its ConnectionBase (if any).
By this point, we may no longer have a connection, so make sure by checking the pointer.
References connected(), connection(), and ConnectionBase::disconnect().
virtual void ConnectorBase::disconnect | ( | ) | [pure virtual] |
Do special activities to disconnect ourselves from the ConnectionBase.
Implemented in Connector< Array< Dim, T, EngineTag >, Lux >, Connector< ConnectPair< DynamicArray< T1, E >, DynamicArray< T2, E > >, Lux >, Connector< Array< Dim, T, EngineTag >, Paws >, Connector< T, Paws >, and Connector< std::string, Paws >.
Referenced by notify().
virtual void ConnectorBase::update | ( | ) | [pure virtual] |
Update our connection, for example, transfer data or read/write a file.
This must be provided by derived classes.
Implemented in Connector< Array< Dim, T, EngineTag >, Lux >, Connector< ConnectPair< DynamicArray< T1, E >, DynamicArray< T2, E > >, Lux >, Connector< Array< Dim, T, EngineTag >, Paws >, Connector< T, Paws >, and Connector< std::string, Paws >.
virtual void ConnectorBase::interact | ( | const char * | = 0 |
) | [pure virtual] |
Allow for interaction with the connection.
An optional string can be provided to tell how to do the interaction.
Implemented in Connector< Array< Dim, T, EngineTag >, Lux >, Connector< ConnectPair< DynamicArray< T1, E >, DynamicArray< T2, E > >, Lux >, Connector< Array< Dim, T, EngineTag >, Paws >, Connector< T, Paws >, and Connector< std::string, Paws >.
virtual void ConnectorBase::notify | ( | ConnectionBase & | c, | |
int | event | |||
) | [inline, virtual] |
Get notified of something by our ConnectionBase object.
If the event code is 0, it means the ConnectionBase is going away so we should no longer use it. Subclasses may need to be able to handle other event codes, so don't complain if we see one we don't know about.
References disconnect(), ConnectionBase::disconnectEvent, and PAssert.
const std::string& ConnectorBase::name | ( | ) | const [inline] |
Return the name of this connection.
bool ConnectorBase::connected | ( | ) | const [inline] |
ConnectionBase& ConnectorBase::connection | ( | ) | const [inline] |
Return the connection we are using.
References connected(), and PAssert.
Referenced by ~ConnectorBase().
int ConnectorBase::transferMode | ( | ) | const [inline] |
Return the data transfer mode.