Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

NetworkCommPort Class Reference

Interfaces to a machine over the internet, TCP/IP or UDP/IP. More...

#include <NetworkCommPort.h>

Inheritance diagram for NetworkCommPort:

Detailed Description

Interfaces to a machine over the internet, TCP/IP or UDP/IP.

You probably want to use UDP if you're sending high-frequency, full-state updates, and use TCP if you're sending low-frequency or partial-state updates.

Definition at line 14 of file NetworkCommPort.h.

List of all members.

Public Member Functions

 NetworkCommPort (const std::string &name)
virtual ~NetworkCommPort ()
 destructor, checks that sbuf has already been closed
virtual std::string getClassName () const
 Returns the name of the class (aka its type).
virtual streambufgetReadStreambuf ()
 Returns a std::basic_streambuf, which is expected to implement the actual work.
virtual streambufgetWriteStreambuf ()
 Returns a std::basic_streambuf, which is expected to implement the actual work.
virtual bool isWriteable ()
 Allows you to check whether the reference from getWriteStreambuf() is currently functional (if checking is supported!).
virtual bool isReadable ()
 Allows you to check whether the reference from getReadStreambuf() is currently functional (if checking is supported!).
virtual bool open ()
 activates the sbuf based on the current configuration settings
virtual bool close ()
 closes sbuf
virtual void plistValueChanged (const plist::PrimitiveBase &pl)

Public Attributes

plist::Primitive< std::string > host
plist::Primitive< unsigned short > port
plist::NamedEnumeration
< Config::transports
transport
plist::Primitive< boolserver
plist::Primitive< boolverbose
plist::Primitive< boolblock

Protected Member Functions

virtual void connectionError (const std::string &msg, bool fatal)
 Displays message on stderr and if fatal is set, calls closeFD().
virtual bool doOpen (bool dispError)
 attempts to make a connection, checking that the previous attempt wasn't too recent
virtual void keepOpen ()

Protected Attributes

basic_netbuf< std::ios::char_type > sbuf
IPaddr curaddr
Config::transports curtrans
unsigned int openedCnt
CallbackThread recon

Static Protected Attributes

static const std::string autoRegisterNetworkCommPort = CommPort::getRegistry().registerType<NetworkCommPort>("NetworkCommPort")
 holds the class name, set via registration with the CommPort registry

Constructor & Destructor Documentation

NetworkCommPort ( const std::string &  name  )  [explicit]

Definition at line 16 of file NetworkCommPort.h.

virtual ~NetworkCommPort (  )  [virtual]

destructor, checks that sbuf has already been closed

Definition at line 32 of file NetworkCommPort.h.


Member Function Documentation

bool close (  )  [virtual]

closes sbuf

Implements CommPort.

Definition at line 91 of file NetworkCommPort.cc.

Referenced by connectionError(), and plistValueChanged().

virtual void connectionError ( const std::string &  msg,
bool  fatal 
) [protected, virtual]

Displays message on stderr and if fatal is set, calls closeFD().

Definition at line 61 of file NetworkCommPort.h.

Referenced by doOpen(), and ~NetworkCommPort().

bool doOpen ( bool  dispError  )  [protected, virtual]

attempts to make a connection, checking that the previous attempt wasn't too recent

Definition at line 47 of file NetworkCommPort.cc.

Referenced by isReadable(), keepOpen(), and open().

virtual std::string getClassName (  )  const [virtual]

Returns the name of the class (aka its type).

Suggested implementation is to declare a static string member, set it to the result of calling the registry's registerType, and then return that member here

Implements CommPort.

Definition at line 37 of file NetworkCommPort.h.

Referenced by plistValueChanged().

virtual streambuf& getReadStreambuf (  )  [virtual]

Returns a std::basic_streambuf, which is expected to implement the actual work.

You can pass this to an istream to use the nice C++ style input and output, or you can call the streambuf functions directly. However, if you're going the latter route, probably easier to just call CommPort's own read() and write().

Depending on implementation, the streambuf this returns might be a different instance than getWriteStreambuf. If they are the same instance, then you could use an iostream instead of separate istream and ostream.

Implements CommPort.

Definition at line 39 of file NetworkCommPort.h.

virtual streambuf& getWriteStreambuf (  )  [virtual]

Returns a std::basic_streambuf, which is expected to implement the actual work.

You can pass this to an ostream to use the nice C++ style input and output, or you can call the streambuf functions directly. However, if you're going the latter route, probably easier to just call CommPort's own read() and write().

Depending on implementation, the streambuf this returns might be a different instance than getReadStreambuf. If they are the same instance, then you could use an iostream instead of separate istream and ostream.

Implements CommPort.

Definition at line 40 of file NetworkCommPort.h.

Referenced by Subscription< T >::closing(), Subscription< T >::doUnfreeze(), ImageSubscription::opened(), DepthSubscription::opened(), SensorSubscription::opened(), ImageSubscription::plistValueChanged(), DepthSubscription::plistValueChanged(), and Subscription< T >::requestFrame().

bool isReadable (  )  [virtual]

Allows you to check whether the reference from getReadStreambuf() is currently functional (if checking is supported!).

For streambufs which don't have a way to check this, always returns true.

Reimplemented from CommPort.

Definition at line 8 of file NetworkCommPort.cc.

Referenced by isWriteable().

virtual bool isWriteable (  )  [virtual]

Allows you to check whether the reference from getWriteStreambuf() is currently functional (if checking is supported!).

For streambufs which don't have a way to check this, always returns true.

Reimplemented from CommPort.

Definition at line 41 of file NetworkCommPort.h.

Referenced by Subscription< T >::doUnfreeze(), ImageSubscription::plistValueChanged(), DepthSubscription::plistValueChanged(), and Subscription< T >::requestFrame().

void keepOpen (  )  [protected, virtual]

Definition at line 83 of file NetworkCommPort.cc.

bool open (  )  [virtual]

activates the sbuf based on the current configuration settings

Implements CommPort.

Definition at line 26 of file NetworkCommPort.cc.

Referenced by plistValueChanged().

void plistValueChanged ( const plist::PrimitiveBase pl  )  [virtual]

Member Data Documentation

const std::string autoRegisterNetworkCommPort = CommPort::getRegistry().registerType<NetworkCommPort>("NetworkCommPort") [static, protected]

holds the class name, set via registration with the CommPort registry

Definition at line 79 of file NetworkCommPort.h.

Referenced by getClassName().

IPaddr curaddr [protected]

Definition at line 73 of file NetworkCommPort.h.

Referenced by doOpen(), open(), and plistValueChanged().

Definition at line 74 of file NetworkCommPort.h.

Referenced by plistValueChanged().

unsigned int openedCnt [protected]

Definition at line 75 of file NetworkCommPort.h.

Referenced by close(), isReadable(), open(), and ~NetworkCommPort().

CallbackThread recon [protected]

Definition at line 76 of file NetworkCommPort.h.

Referenced by close(), isReadable(), open(), and plistValueChanged().

Definition at line 56 of file NetworkCommPort.h.

Referenced by NetworkCommPort(), and plistValueChanged().


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

Tekkotsu Hardware Abstraction Layer 5.1CVS
Generated Mon May 9 05:01:41 2016 by Doxygen 1.6.3