SheafSystem  0.0.0.0
read_write_monitor_handle.h
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Interface for class read_write_monitor_handle
19 
20 #ifndef READ_WRITE_MONITOR_HANDLE_H
21 #define READ_WRITE_MONITOR_HANDLE_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef ANY_H
28 #include "SheafSystem/any.h"
29 #endif
30 
31 // class read_write_monitor;
32 
33 #ifndef READ_WRITE_MONITOR_H
34 #include "SheafSystem/read_write_monitor.h"
35 #endif
36 
37 namespace sheaf
38 {
39 
43 class SHEAF_DLL_SPEC read_write_monitor_handle : public any
44 {
45 
46 public:
47 
51  virtual bool is_ancestor_of(const any* xother) const;
52 
53 
57  virtual read_write_monitor_handle* clone() const;
58 
62  virtual ~read_write_monitor_handle();
63 
64  // ===========================================================
66  // ===========================================================
68 
69 public:
70 
79  static bool access_control_disabled();
80 
81  // ///
82  // /// Disables access control.
83  // /// Disabled (true) is equivalent to having read-write access
84  // /// at all times, irrespective of any access control requests.
85  // /// Synonym for read_write_monitor::disable_access_control().
86  // /// Should only be invoked once at beginning of a program, before any
87  // /// other SheafSystem calls. Once disabled, access control can not be re-enabled.
88  // ///
89  // static void disable_access_control();
90 
97  static void enable_access_control();
98 
99 protected:
100 
101 private:
102 
104 
105 public:
106 
107  // ===========================================================
108  // PER-THREAD STATE ACCESS CONTROL FACET
109  // ===========================================================
110 
114  virtual bool is_attached() const;
115 
120  bool state_is_read_only_accessible() const;
121 
126  bool state_is_not_read_only_accessible() const;
127 
132  bool state_is_read_accessible() const;
133 
138  bool state_is_not_read_accessible() const;
139 
145  bool state_is_auto_read_accessible(bool xauto_access) const;
146 
151  bool state_is_read_write_accessible() const;
152 
157  bool state_is_not_read_write_accessible() const;
158 
165  bool state_is_auto_read_write_accessible(bool xauto_access) const;
166 
171  int access_request_depth() const;
172 
176  virtual void get_read_access() const;
177 
184  virtual void get_read_write_access(bool xrelease_read_only_access = false);
185 
190  virtual void release_access(bool xall = false) const;
191 
192  // ===========================================================
193  // MODE LOCK CONTROL FACET
194  // ===========================================================
195 
199  bool state_is_mode_locked() const;
200 
204  int mode_lock_ct() const;
205 
209  void get_mode_lock() const;
210 
214  void release_mode_lock();
215 
216  // ===========================================================
217  // NOTIFICATION FACET
218  // ===========================================================
219 
224  bool state_is_modified() const;
225 
229  void clear_state_is_modified();
230 
231 protected:
232 
236  virtual read_write_monitor* state_obj() const = 0;
237 
241  inline bool access_guards_disabled() const
242  {
243  return state_obj()->access_guards_disabled();
244  };
245 
250  inline void disable_access_guards()
251  {
252  state_obj()->disable_access_guards();
253  };
254 
258  inline void enable_access_guards()
259  {
260  state_obj()->enable_access_guards();
261  };
262 };
263 
264 } // namespace sheaf
265 
266 #endif // ifndef READ_WRITE_MONITOR_HANDLE_H
void enable_access_guards()
Re-enables access guards.
The monitor concurrency control interface. Class READ_WRITE_MONITOR implements the monitor concurrenc...
void disable_access_guards()
Disables access guards; intended for use only within constructors of monitored objects, where no other client can possibly have access (yet).
bool access_guards_disabled() const
True if thread of control is still in constructor.
A handle for a hidden read_write_monitor state.
Abstract base class with useful features for all objects.
Definition: any.h:39
Namespace for the sheaves component of the sheaf system.