Cross-Platform C++

ot::io
class ResourceDescriptor  (abstract)

#include "ot/io/ResourceDescriptor.h"

ot::ManagedObject ot::io::FileDescriptor ot::net::SocketDescriptor An abstract base class used to connect OpenTop with operating system resources such as open files and network sockets. A ResourceDescriptor represents an open handle. It derives from ManagedObject and uses the standard OpenTop reference-counting scheme. By using ResourceDescriptors, OpenTop is able to share handles between multiple objects, preventing the underlying resource from being closed until all references to the ResourceDescriptor have been destroyed. This is often more efficient and flexible than duplicating operating system handles for the same purpose.

ResourceDescriptor declares a private copy constructor and assignment operator to prevent the copying of instance objects.




Constructor/Destructor Summary
ResourceDescriptor(bool bAutoClose)
         Constructs a ResourceDescriptor, specifying whether the related operating system resource should be closed when this ResourceDescriptor is destroyed.
~ResourceDescriptor()=0
         Destructor.

Method Summary
 bool getAutoClose() const
         Returns a boolean value to indicate whether the underlying resource will be closed when the reference count for this ResourceDescriptor reaches zero.
 void setAutoClose(bool bAutoClose)
         Sets the value of the auto close indicator.
 virtual String toString() const=0
         Returns a string representation of this ResourceDescriptor.

Methods inherited from class ot::ManagedObject
addRef, getRefCount, onFinalRelease, operator=, release

Constructor/Destructor Detail

ResourceDescriptor

 ResourceDescriptor(bool bAutoClose)
Constructs a ResourceDescriptor, specifying whether the related operating system resource should be closed when this ResourceDescriptor is destroyed.

Parameters:
bAutoClose - true if the resource should be closed when this ResourceDescriptor is destroyed; false otherwise

~ResourceDescriptor

virtual ~ResourceDescriptor()=0
Destructor. This method does nothing but derived classes are expected to call getAutoClose() and close the related resource if it returns true.

To indicate that they have performed the required task, all derived class destructors should call setAutoClose(false) before exiting.


Method Detail

getAutoClose

bool getAutoClose() const
Returns a boolean value to indicate whether the underlying resource will be closed when the reference count for this ResourceDescriptor reaches zero.

Returns:
true if the resource will be closed automatically; false otherwise

setAutoClose

void setAutoClose(bool bAutoClose)
Sets the value of the auto close indicator.

See also:
getAutoClose()

toString

virtual String toString() const=0
Returns a string representation of this ResourceDescriptor. OpenTop uses the string representation to identify the resource descriptor when tracing via the Tracer class.

Since:
1.3


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements