pvAccessCPP
utils/pv/destroyable.h
00001 /* destroyable.h */
00002 /*
00003  * Copyright information and license terms for this software can be
00004  * found in the file LICENSE that is included with the distribution
00005  */
00009 #ifndef DESTROYABLE_H
00010 #define DESTROYABLE_H
00011 
00012 #include <compilerDependencies.h>
00013 
00014 #include <pv/sharedPtr.h>
00015 
00016 #include <shareLib.h>
00017 
00018 namespace epics { namespace pvAccess {
00019 
00020 
00024         class epicsShareClass Destroyable {
00025         public:
00026             POINTER_DEFINITIONS(Destroyable);
00030             virtual void destroy() = 0;
00031             
00032         protected:
00033             virtual ~Destroyable() {}
00034         public:
00035 
00047             class cleaner {
00048                 Destroyable::shared_pointer ptr;
00049             public:
00050                 cleaner(const Destroyable::shared_pointer& ptr) :ptr(ptr) {}
00051                 void operator()(Destroyable*) {
00052                     Destroyable::shared_pointer P;
00053                     P.swap(ptr);
00054                     P->destroy();
00055                 }
00056             };
00057         };
00058 
00059 }}
00060 namespace epics { namespace pvData {
00061     typedef ::epics::pvAccess::Destroyable Destroyable EPICS_DEPRECATED;
00062 }}
00063 #endif  /* DESTROYABLE_H */
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator