CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PayloadProxy.h
Go to the documentation of this file.
1 #ifndef CondCore_IOVService_PayloadProxy_h
2 #define CondCore_IOVService_PayloadProxy_h
3 
6 
7 namespace cond {
8 
9  /* get iov by name (key, tag, ...)
10 
11  */
12  class CondGetter {
13  public:
14  virtual ~CondGetter(){}
15  virtual IOVProxy get(std::string name) const=0;
16 
17  };
18 
19  /* implementation detail:
20  implements the not templated part...
21 
22  */
24  public:
25 
26  struct ObjId {
28  unsigned int oid1;
29  unsigned int oid2;
30  };
31  typedef std::vector<ObjId> ObjIds;
32  struct Stats {
33  int nProxy;
34  int nRefresh;
35  int nArefresh;
38  int nMake;
39  int nLoad;
41  };
42 
43  // local stat
45 
46  // errorPolicy=true will throw on load, false will set interval and token to invalid
48  bool errorPolicy);
49 
50  // errorPolicy=true will throw on load, false will set interval and token to invalid
52  const std::string & token,
53  bool errorPolicy);
54 
55  void loadIov( const std::string iovToken );
56  void loadTag( const std::string tag );
57 
58  virtual ~BasePayloadProxy();
59 
60  virtual void invalidateCache()=0;
61 
62  // current cached object token
63  std::string const & token() const { return m_token;}
64 
65  // load Element valid at time
67 
68  // load nth Element (to be used in simple iterators...)
70 
71  // find ad return interval (does not load)
73 
74  // load element if interval is valid
75  void make();
76 
77  bool isValid() const;
78 
79  TimeType timetype() const { return m_iov.timetype();}
80 
81  IOVProxy const & iov() const { return m_iov;}
82 
83  virtual void loadMore(CondGetter const &){}
84 
85  // reload the iov return true if size has changed
86  bool refresh();
87  bool refresh( cond::DbSession& newSession );
88 
89 
90  private:
91  virtual bool load(cond::DbSession& session, std::string const & token) =0;
92 
93 
94  protected:
95  bool m_doThrow;
99 
100  protected:
101  // current loaded payload
103 
104  };
105 
106 
107  /* proxy to the payload valid at a given time...
108 
109  */
110  template<typename DataT>
112  public:
113 
115  bool errorPolicy,
116  const char * source=0) :
117  BasePayloadProxy(session, errorPolicy) {}
118 
120  const std::string & token,
121  bool errorPolicy,
122  const char * source=0) :
123  BasePayloadProxy(session, token, errorPolicy) {}
124 
125  virtual ~PayloadProxy(){}
126 
127  // dereference (does not load)
128  const DataT & operator()() const {
129  return (*m_data);
130  }
131 
132  virtual void invalidateCache() {
133  m_data.clear();
134  m_token.clear(); // in base....
135  }
136 
137 
138  protected:
139  virtual bool load(cond::DbSession& session, std::string const & itoken) {
140  return m_data.load(session,itoken);
141  }
142 
143  private:
145  };
146 
147 }
148 #endif // CondCore_IOVService_PayloadProxy_h
IOVElementProxy m_element
Definition: PayloadProxy.h:97
TimeType timetype() const
Definition: PayloadProxy.h:79
void loadIov(const std::string iovToken)
Definition: PayloadProxy.cc:43
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
virtual ~PayloadProxy()
Definition: PayloadProxy.h:125
cond::ValidityInterval loadFor(cond::Time_t time)
Definition: PayloadProxy.cc:59
TimeType
Definition: Time.h:21
unsigned long long Time_t
Definition: Time.h:16
PayloadProxy(cond::DbSession &session, bool errorPolicy, const char *source=0)
Definition: PayloadProxy.h:114
cond::PayloadRef< DataT > m_data
Definition: PayloadProxy.h:144
virtual void loadMore(CondGetter const &)
Definition: PayloadProxy.h:83
virtual bool load(cond::DbSession &session, std::string const &itoken)
Definition: PayloadProxy.h:139
cond::ValidityInterval setIntervalFor(cond::Time_t time)
virtual void invalidateCache()=0
std::vector< ObjId > ObjIds
Definition: PayloadProxy.h:31
virtual bool load(cond::DbSession &session, std::string const &token)=0
void loadTag(const std::string tag)
Definition: PayloadProxy.cc:50
const DataT & operator()() const
Definition: PayloadProxy.h:128
virtual ~CondGetter()
Definition: PayloadProxy.h:14
TimeType timetype() const
Definition: IOVProxy.cc:281
BasePayloadProxy(cond::DbSession &session, bool errorPolicy)
Definition: PayloadProxy.cc:22
IOVProxy const & iov() const
Definition: PayloadProxy.h:81
static std::string const source
Definition: EdmProvDump.cc:43
PayloadProxy(cond::DbSession &session, const std::string &token, bool errorPolicy, const char *source=0)
Definition: PayloadProxy.h:119
virtual void invalidateCache()
Definition: PayloadProxy.h:132
std::string const & token() const
Definition: PayloadProxy.h:63