Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

CFileEvent Class Reference

#include <CFileEvent.h>

Inheritance diagram for CFileEvent:

CEvent CRegisteredObject CNamedObject CServerConnectionEvent CServerInstance List of all members.

Public Member Functions

 CFileEvent (int fd, int access=readable)
 CFileEvent (const char *pName, int flags=O_RDONLY, int access=readable)
 CFileEvent (const STD(string)&rName, int flags=O_RDONLY, int access=readable)
 CFileEvent (int fd, const char *pObjName, int access=readable)
 CFileEvent (const char *pObjName, const char *pName, int flags=O_RDONLY, int access=readable)
 CFileEvent (const char *pObjName, const STD(string)&rName, int flags=O_RDONLY, int access=readable)
 CFileEvent (int fd, const STD(string)&rObjName, int access=readable)
 CFileEvent (const STD(string)&rObjName, const char *pname, int flags=O_RDONLY, int access=readable)
 CFileEvent (const STD(string)&rObjName, const STD(string)&rName, int flags=O_RDONLY, int access=readable)
 ~CFileEvent ()
int getFd () const
int getCloseOnDestory () const
void MonitorReadable (bool fReadable=true)
void MonitorWritable (bool fWritable=true)
void MonitorExceptions (bool fExcept=true)
virtual void OnReadable (istream &rStream)
virtual void OnWritable (ostream &rStream)
virtual void OnException (iostream &fd)
virtual void OnTimeout (iostream &str)
virtual STD (string) DescribeSelf()

Static Public Attributes

int readable = 1
 Bitmask for readable monitoring.
int writeable = 2
 Bitmask for writable monitoring.
int exceptions = 4
 Bitmask for exception monitoring.

Protected Member Functions

void Exit (int status)
void SetupMonitor (int AccessMask)
CFdMonitorCreateMonitor (const char *pFilename, const char *pMonitor, int flags)

Private Member Functions

 CFileEvent (const CFileEvent &rEvent)
CFileEventoperator= (const CFileEvent &rhs)
int operator== (const CFileEvent &rEvent)

Private Attributes

int m_nFd
 File descriptor.
bool m_fCloseOnDestroy
 true if we opened the file.

Constructor & Destructor Documentation

CFileEvent::CFileEvent int  fd,
int  access = readable
 

Construct an anonymous file event from a file descriptor, The file monitor is a CFdMonitor directly constructed from the fd via new.

Parameters:
fd - File descriptor to open on the file.
access - Bitwise or of access required to file.

Definition at line 411 of file CFileEvent.cpp.

References CNamedObject::AppendClassInfo(), m_fCloseOnDestroy, m_nFd, and SetupMonitor().

CFileEvent::CFileEvent const char *  pName,
int  flags = O_RDONLY,
int  access = readable
 

Construct an anonymous file event from a filename as a const char* A file is opened and created with CreateMonitor.

Parameters:
pName - Name of file to open/create.
flags - open(2) flags.
access - Bitwise access requirements for the file.

Definition at line 428 of file CFileEvent.cpp.

References CNamedObject::AppendClassInfo(), and SetupMonitor().

CFileEvent::CFileEvent const STD(string)&  rName,
int  flags = O_RDONLY,
int  access = readable
 

CFileEvent::CFileEvent int  fd,
const char *  pObjName,
int  access = readable
 

Construct a named file event from a char* object name, and a file descriptor. The CFdMonitor is directly new'd into existence in the operation.

Parameters:
pObjName - Pointer to object name.
fd - File descriptor on already open file to monitor.
access - Bitwise or of the desired access to the file.
Throws:

Definition at line 470 of file CFileEvent.cpp.

References CNamedObject::AppendClassInfo(), and SetupMonitor().

CFileEvent::CFileEvent const char *  pObjName,
const char *  pFilename,
int  flags = O_RDONLY,
int  access = readable
 

Construct a named file event from a char* object name and a char* filename. The CFdMonitor is created by CreateMonitor.

Parameters:
pObjName - Name to give to all the objects.
pFilename - Name of the file to access.
flags - open(2) flags.
access - Bitwise or of the access rights desired to the file.
Throws:

Definition at line 496 of file CFileEvent.cpp.

References CNamedObject::AppendClassInfo(), and SetupMonitor().

CFileEvent::CFileEvent const char *  pObjName,
const STD(string)&  rName,
int  flags = O_RDONLY,
int  access = readable
 

CFileEvent::CFileEvent int  fd,
const STD(string)&  rObjName,
int  access = readable
 

CFileEvent::CFileEvent const STD(string)&  rObjName,
const char *  pname,
int  flags = O_RDONLY,
int  access = readable
 

CFileEvent::CFileEvent const STD(string)&  rObjName,
const STD(string)&  rName,
int  flags = O_RDONLY,
int  access = readable
 

CFileEvent::~CFileEvent  ) 
 

Destructor: In all of the construction methods, the monitor and reactor are dynamically instantiated via new (that's what CreateMonitor will do). We need to get the Monitor and the Reactor and delete them.

Definition at line 607 of file CFileEvent.cpp.

References CEvent::getMonitor(), CEvent::getReactor(), and m_nFd.

CFileEvent::CFileEvent const CFileEvent rEvent  )  [private]
 


Member Function Documentation

CFdMonitor * CFileEvent::CreateMonitor const char *  pFilename,
const char *  pMonitor,
int  flags
[protected]
 

Creates a new monitor given a filename. The file is created/opened for read/write and the fd resulting is used to create a new CFdMonitor (via new).

Parameters:
pFilename - Name of the file to create/open.
pMonitor - Name to give to the monitor.
flags - open(2) flags.
Exceptions:
  • CErrnoException - If the file cannot be created/opened.
  • CDuplicateNameException - If the a monitor with that name already exists.

Definition at line 735 of file CFileEvent.cpp.

References m_nFd.

void CFileEvent::Exit int  status  )  [protected]
 

Exits the thread now (the object must still be destroyed at some point). The global mutex is released unconditionally, a DAQStatus object is created with the given status value and DAQThread::Exit is called.

Parameters:
status - An integer status value (often chosen from errno.h).

Definition at line 713 of file CFileEvent.cpp.

References CApplicationSerializer::getInstance(), and CThreadRecursiveMutex::UnLockCompletely().

int CFileEvent::getCloseOnDestory  )  const [inline]
 

Definition at line 412 of file CFileEvent.h.

int CFileEvent::getFd  )  const [inline]
 

Definition at line 411 of file CFileEvent.h.

Referenced by CFileEvent::CFileEventReactor::OnTimeout().

void CFileEvent::MonitorExceptions bool  fExcept = true  ) 
 

Select if the monitor should watch exceptions on the fd. This is delegated to the monitor's MonitorExceptions member function.

Parameters:
fExcept - true to watch for exceptions, false to disable.

Definition at line 643 of file CFileEvent.cpp.

References CEvent::getMonitor().

Referenced by SetupMonitor().

void CFileEvent::MonitorReadable bool  fReadable = true  ) 
 

Select if the monitor should watch readability. This is delegated to the monitor's MonitorReadable member function.

Parameters:
fReadable - true to watch readability false to disable that.

Definition at line 623 of file CFileEvent.cpp.

References CEvent::getMonitor().

Referenced by SetupMonitor(), and CServerInstance::Shutdown().

void CFileEvent::MonitorWritable bool  fWritable = true  ) 
 

Select if the monitor should watch writability. This is delegated to the Monitor's MonitorWritable member function.

Parameters:
fWritable - true to watch writability false to disable

Definition at line 633 of file CFileEvent.cpp.

References CEvent::getMonitor().

Referenced by SetupMonitor().

void CFileEvent::OnException iostream &  rStream  )  [virtual]
 

Called when the file descriptor has some exception condition. Normally, if an application is interested in this, the programmer will create a subclass of a CFileEvent which implements this member function in a non null way. Default action is an implemented no-op. This requires the programmer to only provide implementations for the members s/he needs. The alternative (pure virtual member), requires a programmer to implement (even if only as a no-op), all members.

Parameters:
rStream - Stream open on the file.

Definition at line 690 of file CFileEvent.cpp.

Referenced by CFileEvent::CFileEventReactor::OnException().

void CFileEvent::OnReadable istream &  str  )  [virtual]
 

Called when a file descriptor becomes readable. Normally, if an application is interested in this, the programmer will create a subclass of CFileEvent which implements this member function in a non-null way. Default action is an implemented No-op. By implementing (rather than making this a pure virtual member), the programmer needs only to provide the members s/he's interested in.

Parameters:
str - Stream open on the file.

Reimplemented in CServerInstance.

Definition at line 661 of file CFileEvent.cpp.

Referenced by CFileEvent::CFileEventReactor::OnReadable().

void CFileEvent::OnTimeout iostream &  rStream  )  [virtual]
 

Calle dwhen a wait times out, and the caller has idicated that they want to pay attention to timeouts.

Parameters:
str - reference to stream open on file.

Definition at line 699 of file CFileEvent.cpp.

Referenced by CFileEvent::CFileEventReactor::OnTimeout().

void CFileEvent::OnWritable ostream &  rStream  )  [virtual]
 

Called when the file descriptor becomes writable. Normally, if an application is interested in this, the programmer will create a subclass of a CFileEvent which implements this member function in a non null way. Default action is an implemented no-op. This requires the programmer to only provide implementations for the members s/he needs. The alternative (pure virtual member), requires a programmer to implement (even if only as a no-op), all members.

Parameters:
rStream - Stream open on the file.

Definition at line 675 of file CFileEvent.cpp.

Referenced by CFileEvent::CFileEventReactor::OnWritable().

CFileEvent& CFileEvent::operator= const CFileEvent rhs  )  [private]
 

int CFileEvent::operator== const CFileEvent rEvent  )  [private]
 

void CFileEvent::SetupMonitor int  AccessMask  )  [protected]
 

Set up the acessibility of the monitor. This means that the access mask is translated into an initial set of calls to MonitorReadable, MonitorWritable.

Parameters:
AccessMask - Bitwise or of the access requested.
Legitimate bits in AccessMask are:

Definition at line 769 of file CFileEvent.cpp.

References MonitorExceptions(), MonitorReadable(), and MonitorWritable().

Referenced by CFileEvent().

virtual CFileEvent::STD string   )  [virtual]
 

The name of the object

Reimplemented from CEvent.

Reimplemented in CServerConnectionEvent, and CServerInstance.


Member Data Documentation

int CFileEvent::exceptions = 4 [static]
 

Bitmask for exception monitoring.

Definition at line 311 of file CFileEvent.cpp.

bool CFileEvent::m_fCloseOnDestroy [private]
 

true if we opened the file.

Definition at line 365 of file CFileEvent.h.

Referenced by CFileEvent().

int CFileEvent::m_nFd [private]
 

File descriptor.

Definition at line 364 of file CFileEvent.h.

Referenced by CFileEvent(), CreateMonitor(), and ~CFileEvent().

int CFileEvent::readable = 1 [static]
 

Bitmask for readable monitoring.

Definition at line 309 of file CFileEvent.cpp.

int CFileEvent::writeable = 2 [static]
 

Bitmask for writable monitoring.

Definition at line 310 of file CFileEvent.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Jan 6 16:58:44 2005 for Spectrodaq External Event Framework by  doxygen 1.3.9.1