ScaleOut C++ Native Client API  5.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
object_policy.h
1 /*
2  Copyright (c) 2013 by ScaleOut Software, Inc.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #pragma once
18 
19 #include <vector>
20 #include <stdint.h>
21 #include "boost/date_time/posix_time/posix_time_duration.hpp"
22 #include "soss_svccli.h"
23 #include "soss_client/soss_key.h"
24 
25 
26 namespace sosscli {
27 
28 // forward declaration (breaks cyclic references):
29 class NamedCache;
30 
36 {
37 public:
38  template<typename T> friend class TypedNamedCache;
39 
40  /* Constants */
41 
43  const static boost::posix_time::time_duration INFINITE_TIMEOUT;
44 
46  const static boost::posix_time::time_duration MAX_TIMEOUT;
47 
49  const static size_t MAX_NUM_PARENTS = SOSSLIB_MAX_PARENTS;
50 
54 
55  /* enums */
56 
59  {
61  Sliding = SOSSLIB_TIMEOUT_SLIDING,
63  Absolute = SOSSLIB_TIMEOUT_ABSOLUTE,
65  ResetOnUpdate = SOSSLIB_TIMEOUT_ABS_ON_READ
66  };
67 
70  {
74  Normal = 1
75  };
76 
77  /* Constructors */
78 
81  ObjectPolicy();
82 
84  ObjectPolicy(NamedCache *named_cache);
85 
87  virtual ~ObjectPolicy() {}
88 
89  /* Accessors */
90 
92  boost::posix_time::time_duration timeout() const { return timeout_; }
95  ObjectPolicy& set_timeout(boost::posix_time::time_duration timeout) { timeout_ = timeout; return *this; }
96 
98  TimeoutType timeout_type() const { return timeout_type_; }
102 
104  PreemptionPriority preemption_priority() const { return preemption_priority_; }
108 
110  bool allow_push_repl() const { return allow_push_repl_; }
113  ObjectPolicy& set_allow_push_repl(bool allow_push_repl) { allow_push_repl_ = allow_push_repl; return *this; }
114 
116  std::vector<SossKey> parents() const { return parents_; }
119  ObjectPolicy& set_parents(std::vector<SossKey> parents) { parents_ = parents; return *this; }
120 
121 protected:
122 
123 private:
124 
127  SOSSLIB_OBJ_PARAMS_EXT &copy_to(SOSSLIB_OBJ_PARAMS_EXT &params) const;
128 
129  boost::posix_time::time_duration timeout_;
130  TimeoutType timeout_type_;
131  PreemptionPriority preemption_priority_;
132  bool allow_push_repl_;
133  std::vector<SossKey> parents_;
134 };
135 
136 }
137