Back to index

nordugrid-arc-nox  1.1.0~rc6
DataHandle.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifndef __ARC_DATAHANDLE_H__
00004 #define __ARC_DATAHANDLE_H__
00005 
00006 #include <arc/data/DataPoint.h>
00007 
00008 namespace Arc {
00009 
00010   class URL;
00011   class UserConfig;
00012 
00014 
00017   class DataHandle {
00018   public:
00019     DataHandle(const URL& url, const UserConfig& usercfg)
00020       : p(loader.load(url, usercfg)) {}
00021     ~DataHandle() {
00022       if (p)
00023         delete p;
00024     }
00025     DataPoint* operator->() {
00026       return p;
00027     }
00028     const DataPoint* operator->() const {
00029       return p;
00030     }
00031     DataPoint& operator*() {
00032       return *p;
00033     }
00034     const DataPoint& operator*() const {
00035       return *p;
00036     }
00037     bool operator!() const {
00038       return !p;
00039     }
00040     operator bool() const {
00041       return !!p;
00042     }
00043   private:
00044     DataPoint *p;
00045     static DataPointLoader loader;
00046   };
00047 
00048 } // namespace Arc
00049 
00050 #endif // __ARC_DATAHANDLE_H__