Fennel: /home/pub/open/dev/fennel/common/ClosableObject.h Source File (original) (raw)

00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 #ifndef Fennel_ClosableObject_Included 00025 #define Fennel_ClosableObject_Included 00026 00027 FENNEL_BEGIN_NAMESPACE 00028 00036 class FENNEL_COMMON_EXPORT ClosableObject 00037 { 00038 protected: 00042 virtual void closeImpl() = 0; 00043 00044 bool needsClose; 00045 00046 explicit ClosableObject(); 00047 00048 public: 00053 virtual ~ClosableObject(); 00054 00058 bool isClosed() const 00059 { 00060 return !needsClose; 00061 } 00062 00066 void close(); 00067 }; 00068 00073 class FENNEL_COMMON_EXPORT ClosableObjectDestructor 00074 { 00075 public: 00076 void operator()(ClosableObject *pClosableObject) 00077 { 00078 pClosableObject->close(); 00079 delete pClosableObject; 00080 } 00081 }; 00082 00083 FENNEL_END_NAMESPACE 00084 00085 #endif 00086 00087