Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

FileSystemCommPort Class Reference

#include <FileSystemCommPort.h>

Inheritance diagram for FileSystemCommPort:

List of all members.


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.


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 std::basic_filebuf
< std::ios::char_type > & 
getReadStreambuf ()
 Returns a std::basic_streambuf, which is expected to implement the actual work.
virtual std::basic_filebuf
< 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)
 Displays message on stderr and if fatal is set, calls closeFD().

Protected Attributes

std::basic_filebuf
< std::ios::char_type > 
rbuf
std::basic_filebuf
< std::ios::char_type > 
wbuf
std::string curloc
std::ios_base::openmode curmode
unsigned int opened

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

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

Definition at line 15 of file FileSystemCommPort.h.

virtual ~FileSystemCommPort (  )  [inline, 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 
) [inline, explicit, protected]

Definition at line 50 of file FileSystemCommPort.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.

Reimplemented in SerialCommPort.

Definition at line 30 of file FileSystemCommPort.h.

Referenced by plistValueChanged().

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

virtual std::basic_filebuf<std::ios::char_type>& 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 33 of file FileSystemCommPort.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 34 of file FileSystemCommPort.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 35 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 5 of file FileSystemCommPort.cc.

Referenced by SerialCommPort::open(), and plistValueChanged().

bool close (  )  [virtual]

closes rbuf and wbuf

Implements CommPort.

Reimplemented in SerialCommPort.

Definition at line 28 of file FileSystemCommPort.cc.

Referenced by SerialCommPort::close(), connectionError(), and 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 40 of file FileSystemCommPort.cc.

Referenced by SerialCommPort::plistValueChanged().

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 FileSystemCommPort.h.

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


Member Data Documentation

plist::Primitive<std::string> path

path of file system object being accessed

Definition at line 46 of file FileSystemCommPort.h.

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

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

Definition at line 47 of file FileSystemCommPort.h.

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

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

Definition at line 68 of file FileSystemCommPort.h.

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

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

Definition at line 69 of file FileSystemCommPort.h.

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

std::string curloc [protected]

Definition at line 70 of file FileSystemCommPort.h.

Referenced by open(), and plistValueChanged().

std::ios_base::openmode curmode [protected]

Definition at line 71 of file FileSystemCommPort.h.

Referenced by open(), and plistValueChanged().

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 75 of file FileSystemCommPort.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:20 2007 by Doxygen 1.5.4