ECS_Reader

- read from a file descriptor in ECS::mainloop

SYNOPSIS

#include <ECS/Reader.hh>
class ECS_Reader
{
 public:
	_ECSAIO_PRIVAPI ECS_Reader();
	_ECSAIO_PRIVAPI virtual ~ECS_Reader();
	virtual ostream& print(ostream& os) const;
	_ECSAIO_PRIVAPI void monitorFd(int fd);
	_ECSAIO_PRIVAPI void ceaseMonitoringFd(int fd);
	_ECSAIO_PRIVAPI virtual void handleException(int fd);
	_ECSAIO_PRIVAPI virtual void handleReadable(int fd) = 0;
};

CLASS TYPE

Abstract Base

AUDIENCE

ECS Application Developers

DESCRIPTION

This class exists so that the interface developer can register a file descriptor to be monitored in ECS::mainloop().

This is intended to support a single process which performs both input and output from the correlation engine. This configuration is not recommended and should only be used where the application demands it.

It is expected that the developer will create an application specific subclass of this class. The class will set up a socket or other input stream and will call monitorFd with the file descriptor of the input source. When ECS::mainloop() detects that the file is readable it will make a callback to the virtual handleReadable() method.

It is anticipated that the developer will provide an implementation of handleEvent which will read event data from the file descriptor, construct and ECS_Event and forward it to an engine.

This class could also be used to monitor a stream of control input to an output process or annotation server.

Constructors and Destructors

_ECSAIO_PRIVAPI ECS_Reader();
The default constructor _ECSAIO_PRIVAPI virtual ~ECS_Reader();
The destructor

Utility

virtual ostream& print(ostream& os) const;
Prints a textual representation of the class to the output stream specified via os.
_ECSAIO_PRIVAPI void monitorFd(int fd);
Registers a file descriptor to be monitored in ECS::mainloop(). If the file descriptor becomes readable, or has a exception mainloop will perform a callback to handleReadable() and handleException() respectively.
_ECSAIO_PRIVAPI void ceaseMonitoringFd(int fd);
Stops future ECS::mainloop() invocation from monitoring the specific file descriptor. Only has an effect if the file descriptor was previously specified to be monitored by this class.
_ECSAIO_PRIVAPI virtual void handleException(int fd);
This is the default implementation, which is close the fd and remove it from future monitoring. It is expected that subclasses will provide an implementation better suited to the individual case.
_ECSAIO_PRIVAPI virtual void handleReadable(int fd) = 0;
This method must be implemented by subclasses. It is expected to implement appropriate handling when the file descriptor identified by fd selects readable.

NOTES

None

SEE ALSO

None

LIBRARY

ECS

VERSION

1.6

DATE RELEASED

1998/02/25

AUTHOR(S)

Hewlett-Packard Company

COPYRIGHT

Copyright (c) 1997 Hewlett-Packard Company. All Rights Reserved.