Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

FileSystemCommPort Class Reference

Provides CommPort interface to file system devices, such as serial ports. More...

#include <FileSystemCommPort.h>

Inheritance diagram for FileSystemCommPort:

Detailed Description

Provides CommPort interface to file system devices, such as serial ports.

Pass a path to use a file system device, or see NetworkCommPort for a network interface

Definition at line 12 of file FileSystemCommPort.h.

List of all members.

Public Member Functions

 FileSystemCommPort (const std::string &name)
 constructor (see also sub-class constructor in protected section)
virtual ~FileSystemCommPort ()
 destructor, checks that the file descriptor has already been closed
virtual std::string getClassName () const
 Returns the name of the class (aka its type).
virtual basic_netbuf
< std::ios::char_type > & 
getReadStreambuf ()
 Returns a std::basic_streambuf, which is expected to implement the actual work.
virtual basic_netbuf
< std::ios::char_type > & 
getWriteStreambuf ()
 Returns a std::basic_streambuf, which is expected to implement the actual work.
virtual bool isReadable ()
 Allows you to check whether the reference from getReadStreambuf() is currently functional (if checking is supported!).
virtual bool isWriteable ()
 Allows you to check whether the reference from getWriteStreambuf() is currently functional (if checking is supported!).
virtual bool open ()
 tries to have rbuf and/or wbuf open path, subject to mode
virtual bool close ()
 closes rbuf and wbuf
virtual void plistValueChanged (const plist::PrimitiveBase &pl)
 watches path, triggers a close() and re-open() if it changes

Public Attributes

plist::Primitive< std::string > path
 path of file system object being accessed
plist::Primitive< int > mode
 mode bitmask to pass to the open() call (see std::ios_base::openmode)

Protected Member Functions

 FileSystemCommPort (const std::string &classname, const std::string &instancename)
virtual void connectionError (const std::string &msg, bool fatal, const char *sysmsg, bool useClassName=true)
 Displays message on stderr and if fatal is set, calls closeFD().

Protected Attributes

basic_netbuf< std::ios::char_type > rbuf
basic_netbuf< std::ios::char_type > wbuf
std::string curloc
std::ios_base::openmode curmode
unsigned int openedCnt

Static Protected Attributes

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

Constructor & Destructor Documentation

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

constructor (see also sub-class constructor in protected section)

Definition at line 15 of file FileSystemCommPort.h.

virtual ~FileSystemCommPort (  )  [virtual]

destructor, checks that the file descriptor has already been closed

Definition at line 25 of file FileSystemCommPort.h.

FileSystemCommPort ( const std::string &  classname,
const std::string &  instancename 
) [explicit, protected]

Definition at line 51 of file FileSystemCommPort.h.


Member Function Documentation

bool close (  )  [virtual]

closes rbuf and wbuf

Implements CommPort.

Reimplemented in SerialCommPort.

Definition at line 43 of file FileSystemCommPort.cc.

Referenced by connectionError(), and plistValueChanged().

virtual void connectionError ( const std::string &  msg,
bool  fatal,
const char *  sysmsg,
bool  useClassName = true 
) [protected, virtual]

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

Need the useClassName parameter because we can't trust autoRegisterFileSystemCommPort to still be valid during static destruction, so that's false when called from destructor

Definition at line 63 of file FileSystemCommPort.h.

Referenced by open(), and ~FileSystemCommPort().

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.

Reimplemented in SerialCommPort.

Definition at line 31 of file FileSystemCommPort.h.

Referenced by connectionError(), and plistValueChanged().

virtual basic_netbuf<std::ios::char_type>& 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 33 of file FileSystemCommPort.h.

virtual basic_netbuf<std::ios::char_type>& 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 34 of file FileSystemCommPort.h.

virtual 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 35 of file FileSystemCommPort.h.

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 36 of file FileSystemCommPort.h.

bool open (  )  [virtual]

tries to have rbuf and/or wbuf open path, subject to mode

Implements CommPort.

Reimplemented in SerialCommPort.

Definition at line 6 of file FileSystemCommPort.cc.

Referenced by plistValueChanged().

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

watches path, triggers a close() and re-open() if it changes

Implements PrimitiveListener.

Reimplemented in SerialCommPort.

Definition at line 56 of file FileSystemCommPort.cc.


Member Data Documentation

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

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

Definition at line 85 of file FileSystemCommPort.h.

Referenced by getClassName().

std::string curloc [protected]

Definition at line 80 of file FileSystemCommPort.h.

Referenced by open(), and plistValueChanged().

std::ios_base::openmode curmode [protected]

Definition at line 81 of file FileSystemCommPort.h.

Referenced by open(), and plistValueChanged().

mode bitmask to pass to the open() call (see std::ios_base::openmode)

Definition at line 48 of file FileSystemCommPort.h.

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

plist::Primitive<std::string> path

path of file system object being accessed

Definition at line 47 of file FileSystemCommPort.h.

Referenced by close(), FileSystemCommPort(), SerialCommPort::open(), open(), plistValueChanged(), and SerialCommPort::setupSerial().

basic_netbuf<std::ios::char_type> rbuf [protected]

Definition at line 78 of file FileSystemCommPort.h.

Referenced by close(), connectionError(), getReadStreambuf(), isReadable(), and open().

basic_netbuf<std::ios::char_type> wbuf [protected]

Definition at line 79 of file FileSystemCommPort.h.

Referenced by close(), connectionError(), getWriteStreambuf(), isWriteable(), and open().


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