Public Member Functions

PlugT< T > Class Template Reference

Plugs of various types. More...

#include <sockets.h>

List of all members.

Public Member Functions

 operator T () const
 Get the connected socket value.
void operator= (const PlugT &ptr)
 Assignment from another plug.
void operator= (const T value)
 Assignment.
const Toperator+= (const T value)
 Assignment by addition.
const Toperator-= (const T value)
 Assignment by subtraction.
const Toperator*= (const T value)
 Assignment by multiplication.
const Toperator/= (const T value)
 Assignment by division.
TGetPointer ()
 Get a pointer to the socket data.
bool IsConnected ()
 Are we connected.
bool Connect (const char *name) void Invalidate()
 Connect to a socket.

Detailed Description

template<class T>
class PlugT< T >

Plugs of various types.

Plugs encapsulate acquiring and using sockets exposed by other modules. They can be read just like their data type. To connect a Plug to another module's socket use this syntax in your module's Init() function:

 FooPlug.Connect("socket name");

To access the data, simply read it like any normal variable. Say you have a PlugF called FooPlug, this code would work fine:

float f = FooPlug;

NOTE: It is a very good idea to check IsValid() after connecting. The socket may not exist or may be of the wrong data type!

 FooPlug.Connect("socket name");
 if(!FooPlug.IsValid())
 {
   Show an error message or reduce functionality so you don't need this value.
 }

If you read a Plug that is not valid the returned value is indeterminate.

Writing to a plug that is not valid has no effect

Plugs are type safe so for examaple a PlugF will only connect to a SocketF or ParameterF.

Currently defined are:


Member Function Documentation

template<class T >
bool PlugT< T >::Connect ( const char *  name  ) 

Connect to a socket.

If the socket exists and is of the correct type then Connect to it. Returns true if the connection was successful.Disconnect and invalidate this plug

template<class T >
T* PlugT< T >::GetPointer (  )  [inline]

Get a pointer to the socket data.

template<class T >
bool PlugT< T >::IsConnected (  )  [inline]

Are we connected.

Returns true if the plug is connected to a valid socket

template<class T >
PlugT< T >::operator T (  )  const [inline]

Get the connected socket value.

template<class T >
const T& PlugT< T >::operator*= ( const T  value  )  [inline]

Assignment by multiplication.

template<class T >
const T& PlugT< T >::operator+= ( const T  value  )  [inline]

Assignment by addition.

template<class T >
const T& PlugT< T >::operator-= ( const T  value  )  [inline]

Assignment by subtraction.

template<class T >
const T& PlugT< T >::operator/= ( const T  value  )  [inline]

Assignment by division.

template<class T >
void PlugT< T >::operator= ( const PlugT< T > &  ptr  )  [inline]

Assignment from another plug.

template<class T >
void PlugT< T >::operator= ( const T  value  )  [inline]

Assignment.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines