tobicore  7.0.0
 All Classes Functions Variables Typedefs Enumerator Friends Groups Pages
TPInterface Class Reference

TOBI platform generic interface. More...

#include <tobiplatform/TPInterface.hpp>

+ Inheritance diagram for TPInterface:
+ Collaboration diagram for TPInterface:

Public Types

enum  { AsServer = 0, AsClient }
 Plugging mode. More...
enum  {
  Unsuccessful = 0, Successful, ErrorSocket, ErrorEndpoint,
  ErrorBound, ErrorGeneric, ErrorNotSupported, ErrorProtocol,
  ErrorTimeout
}
 Status/error codes. More...

Public Member Functions

 TPInterface (void)
 Constructor.
virtual ~TPInterface (void)
 Destructor.
int Plug (const std::string &ip, const std::string &port, int mode=TPInterface::AsServer)
 Plug.
void Unplug (void)
 Unplug.
bool IsPlugged (void)

Protected Member Functions

virtual int ConfAsServer (const std::string &ip, const std::string &port)
virtual int ConfAsClient (const std::string &ip, const std::string &port)

Protected Attributes

TPSocket_socket
 Socket for TCP communication.
TPSocket_endpoint
 Reference to communication endpoint.
TPSocket_com
 Reference to _socket or _endpoint.
TPStreamer _stream
 Data streamer.
std::string _cache

Detailed Description

TOBI platform generic interface.

This class provides all the methods to develop a TCP/IP TOBI platform component. It uses a TPSocket object to abstract communication as server or as client. For this reason, a TPInterface can be "plugged" to another. The TOBI platform iC and iD pluggable classes (TPiC and TPiD) derive directly from this class.

See Also
TPiC, TPiD

Definition at line 38 of file TPInterface.hpp.

Member Enumeration Documentation

anonymous enum

Plugging mode.

Enumerator:
AsServer 

Configure/plug as TCP server.

AsClient 

Configure/plug as TCP client.

Definition at line 76 of file TPInterface.hpp.

anonymous enum

Status/error codes.

Enumerator:
Unsuccessful 

Generic unsuccessful operation.

Successful 

Generic uccessful operation.

ErrorSocket 

Cannot bind, listen or connect socket.

ErrorEndpoint 

Cannot communicate with endpoint.

ErrorBound 

Socket already bound/connected.

ErrorGeneric 

Generic configuration error.

ErrorNotSupported 

Operattion/request not supported.

ErrorProtocol 

Protocol related error.

ErrorTimeout 

Timeout error.

Definition at line 86 of file TPInterface.hpp.

Member Function Documentation

int TPInterface::Plug ( const std::string &  ip,
const std::string &  port,
int  mode = TPInterface::AsServer 
)

Plug.

This method allows to bind a TCP socket or to connect to a remote one.

  • ip IP to bind or remote IP to connect to.
  • port Port to bind or remote port to connect to.
  • mode Behavior, AsClient or AsServer
    Returns
    Status or error code
Examples:
tpicclient.cpp, tpicserver.cpp, and tpidclient.cpp.

Definition at line 33 of file TPInterface.cpp.

void TPInterface::Unplug ( void  )

Unplug.

Unbinds or disconnect.

Examples:
tpicclient.cpp, tpicserver.cpp, and tpidclient.cpp.

Definition at line 45 of file TPInterface.cpp.

+ Here is the call graph for this function:


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