mx::StreamFile Class Reference
[I/O Kit]

Abstraction of a binary file, usable both for reading and writing (binary) streams. More...

#include <StreamFile.h>

Inheritance diagram for mx::StreamFile:

mxmObject mx::IComponent mx::IStreamSourceFile mx::IStreamReceiver mx::IInterface mx::IStreamSource mx::ISupportsFileSpecification mx::ISupportsShuttingDown mx::IErrorState mx::IRequiresActivation mx::IInterface mx::IErrorState mx::IInterface mx::IInterface mx::IInterface List of all members.

Public Member Functions

mxm::smart< mxmStringListenumerateInterfaces ()
 (Re)implemented.
mxm::smart< mxmStringListenumerateCapabilities (const mxmString &interface)
 (Re)implemented.
void setFilename (const mxmString &filename)
 [Config Phase] (Re)implemented.
void setFileDescriptor (int fd)
 [Config Phase] (Re)implemented.
void setWriteMode (bool enabled)
 [Config Phase] Specifies whether the file should be opened for reading or for writing,
void setTimedBlockModeEnabled (bool enabled, long timeout=1000)
 Toggles/configures the timed block mode, see above.
int fetchStreamBytes (mxm::u8 *buffer, int num)
 (Re)implemented.
bool stillUp (void)
 (Re)implemented.
void receiveStreamBytes (const mxm::u8 *bytes, int byte_num)
 (Re)implemented.
bool errorState ()
 (Re)implemented.
void setErrorState ()
 (Re)implemented.
void shutdown ()
 (Re)implemented.
bool activate ()
 (Re)implemented.

Static Public Member Functions

static IComponentInvokernewInvoker ()
 Generates an invoker singleton for the StreamFile component.

Private Member Functions

void closeFile ()
 Helper - just closes file, must be called only once!

Static Private Member Functions

static mxm::smart< mxmStringList_enumerateInterfaces ()
 These static methods provide interface and capability ids for registration with the framework (for both the component and its invoker).
static mxm::smart< mxmStringList_enumerateCapabilities (const mxmString &interface)

Private Attributes

mxmString Filename
int FileDescriptor
bool WriteMode
bool Online
int FD
bool StillUp
bool ErrorEncountered
bool HasBeenShutDown
bool CloseFileUponDestruction
bool TimedBlockMode
long BlockTimeout

Classes

class  Invoker

Detailed Description

Abstraction of a binary file, usable both for reading and writing (binary) streams.

If invoked by specifying a filename to the constructor, the respective file is automatically opened. It is also automatically closed again when the stream file is deleted later.

If, on the other hand, the stream file is invoked by specifying a POSIX file descriptor to the constructor, the file descriptor is used instead. Note that in this case the corresponing file is not closed upon stream file destruction.

The stream file sports a so-called Timed Block Mode that can be toggled at any time using the setTimedBlockModeEnabled() method. If enabled, a UNIX select() call is issued prior to read attempts on the encapsuled file descriptor using the specified timeout. This causes the fetchBytes() implementation to block in the kernel if no data is available, but at most for that many milliseconds as was specified to setTimedBlockModeEnabled(). If such a blocking times out before any new data come in over the file descriptor, fetchBytes() returns with a return value of 0.

As usual, with Microsoft happily adding non-POSIX flags to POSIX interfaces, we have to provide a modified implementation for the WINDOWS platform.

Shut-down mode was retrofitted: potential file gets closed, then the object won't do anything any more except for indicating error state.

Author:
[khe] Kai Hergenroether


Member Function Documentation

void mx::StreamFile::setWriteMode bool  enabled  ) 
 

[Config Phase] Specifies whether the file should be opened for reading or for writing,

Default is read mode.


The documentation for this class was generated from the following files:
Generated on Fri Jun 29 17:21:06 2007 for MxPEG SDK by  doxygen 1.4.6