ARC SDK
DataHandle.h
1 // -*- indent-tabs-mode: nil -*-
2 
3 #ifndef __ARC_DATAHANDLE_H__
4 #define __ARC_DATAHANDLE_H__
5 
6 #include <arc/data/DataPoint.h>
7 
8 namespace Arc {
9 
10  class URL;
11  class UserConfig;
12 
14 
33  class DataHandle {
34  public:
36  DataHandle(const URL& url, const UserConfig& usercfg)
37  : p(getLoader().load(url, usercfg)) {}
40  if (p)
41  delete p;
42  }
45  return p;
46  }
48  const DataPoint* operator->() const {
49  return p;
50  }
53  return *p;
54  }
56  const DataPoint& operator*() const {
57  return *p;
58  }
60  bool operator!() const {
61  return !p;
62  }
64  operator bool() const {
65  return !!p;
66  }
68 
72  static DataPoint* GetPoint(const URL& url, const UserConfig& usercfg) {
73  return getLoader().load(url, usercfg);
74  }
75  private:
77  DataPoint *p;
79  static DataPointLoader& getLoader();
81  DataHandle(void);
84  DataHandle(const DataHandle&);
85  DataHandle& operator=(const DataHandle&);
86  };
87 
88 } // namespace Arc
89 
90 #endif // __ARC_DATAHANDLE_H__
Arc namespace contains all core ARC classes.
Definition: ArcConfig.h:11
User configuration class
Definition: UserConfig.h:196
DataPoint * operator->()
Returns a pointer to a DataPoint object.
Definition: DataHandle.h:44
This class is a wrapper around the DataPoint class.
Definition: DataHandle.h:33
DataPoint & operator*()
Returns a reference to a DataPoint object.
Definition: DataHandle.h:52
const DataPoint * operator->() const
Returns a const pointer to a DataPoint object.
Definition: DataHandle.h:48
static DataPoint * GetPoint(const URL &url, const UserConfig &usercfg)
Returns a pointer to new DataPoint object corresponding to URL.
Definition: DataHandle.h:72
A DataPoint represents a data resource and is an abstraction of a URL.
Definition: DataPoint.h:121
DataHandle(const URL &url, const UserConfig &usercfg)
Construct a new DataHandle.
Definition: DataHandle.h:36
~DataHandle()
Destructor.
Definition: DataHandle.h:39
bool operator!() const
Returns true if the DataHandle is not valid.
Definition: DataHandle.h:60
Class to represent general URLs.
Definition: URL.h:88
const DataPoint & operator*() const
Returns a const reference to a DataPoint object.
Definition: DataHandle.h:56