Plugs of various types. More...
#include <sockets.h>
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 T & | operator+= (const T value) |
| Assignment by addition. | |
| const T & | operator-= (const T value) |
| Assignment by subtraction. | |
| const T & | operator*= (const T value) |
| Assignment by multiplication. | |
| const T & | operator/= (const T value) |
| Assignment by division. | |
| T * | GetPointer () |
| Get a pointer to the socket data. | |
| bool | IsConnected () |
| Are we connected. | |
| bool | Connect (const char *name) void Invalidate() |
| Connect to a socket. | |
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:
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
Are we connected.
Returns true if the plug is connected to a valid socket
Assignment by multiplication.
Assignment by addition.
Assignment by subtraction.
Assignment by division.
Assignment from another plug.
1.7.0