Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

NetworkCommPort Class Reference

#include <NetworkCommPort.h>

Inheritance diagram for NetworkCommPort:

List of all members.


Detailed Description

description of NetworkCommPort

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 13 of file NetworkCommPort.h.


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< bool > server
plist::Primitive< bool > verbose
plist::Primitive< bool > block

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

Protected Attributes

basic_netbuf< std::ios::char_type > sbuf
IPaddr curaddr
Config::transports curtrans
unsigned int opened
TimeET lastAttempt

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  )  [inline, explicit]

Definition at line 15 of file NetworkCommPort.h.

virtual ~NetworkCommPort (  )  [inline, virtual]

destructor, checks that sbuf has already been closed

Definition at line 31 of file NetworkCommPort.h.


Member Function Documentation

virtual std::string getClassName (  )  const [inline, 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 36 of file NetworkCommPort.h.

Referenced by plistValueChanged().

virtual streambuf& getReadStreambuf (  )  [inline, 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 38 of file NetworkCommPort.h.

virtual streambuf& getWriteStreambuf (  )  [inline, 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 39 of file NetworkCommPort.h.

virtual bool isWriteable (  )  [inline, 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 40 of file NetworkCommPort.h.

virtual bool isReadable (  )  [inline, 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 41 of file NetworkCommPort.h.

bool open (  )  [virtual]

activates the sbuf based on the current configuration settings

Implements CommPort.

Definition at line 8 of file NetworkCommPort.cc.

Referenced by plistValueChanged().

bool close (  )  [virtual]

closes sbuf

Implements CommPort.

Definition at line 54 of file NetworkCommPort.cc.

Referenced by connectionError(), and plistValueChanged().

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

Implements PrimitiveListener.

Definition at line 69 of file NetworkCommPort.cc.

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

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

Definition at line 60 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 22 of file NetworkCommPort.cc.

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


Member Data Documentation

plist::Primitive<std::string> host

Definition at line 51 of file NetworkCommPort.h.

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

plist::Primitive<unsigned short> port

Definition at line 52 of file NetworkCommPort.h.

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

Definition at line 54 of file NetworkCommPort.h.

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

Definition at line 55 of file NetworkCommPort.h.

Referenced by NetworkCommPort(), and plistValueChanged().

Definition at line 56 of file NetworkCommPort.h.

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

IPaddr curaddr [protected]

Definition at line 70 of file NetworkCommPort.h.

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

Definition at line 71 of file NetworkCommPort.h.

Referenced by plistValueChanged().

unsigned int opened [protected]

Definition at line 72 of file NetworkCommPort.h.

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

TimeET lastAttempt [protected]

Definition at line 73 of file NetworkCommPort.h.

Referenced by doOpen().

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 76 of file NetworkCommPort.h.

Referenced by getClassName().


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

Tekkotsu Hardware Abstraction Layer 4.0
Generated Thu Nov 22 01:01:22 2007 by Doxygen 1.5.4