SheafSystem  0.0.0.0
any.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 any
19 //
20 
21 
22 #ifndef ANY_H
23 #define ANY_H
24 
25 #ifndef SHEAF_DLL_SPEC_H
26 #include "SheafSystem/sheaf_dll_spec.h"
27 #endif
28 
29 #ifndef SHEAF_H
30 #include "SheafSystem/sheaf.h"
31 #endif
32 
33 namespace sheaf
34 {
35 
39 class SHEAF_DLL_SPEC any
40 {
41 
42 public:
43 
44  // GENERIC OBJECT INTERFACE
45 
49  virtual bool is_ancestor_of(const any* other) const;
50 
54  bool is_same_type(const any* other) const;
55 
60  virtual any* clone() const;
61 
65  virtual ~any();
66 
67 
68  // CONTROLLABLE INVARIANT INTERFACE
69 
74  virtual bool invariant() const;
75 
79  inline bool invariant_check() const
80  {
81  return _disable_invariance_check_request_depth == 0;
82  };
83 
87  inline void enable_invariant_check() const
88  {
89  --_disable_invariance_check_request_depth;
90  };
91 
97  inline void disable_invariant_check() const
98  {
99  ++_disable_invariance_check_request_depth;
100  };
101 
107  {
108  return _disable_invariance_check_request_depth;
109  };
110 
111 protected:
112 
116  any();
117 
118 
119 private:
120 
125  mutable int _disable_invariance_check_request_depth;
126 };
127 
128 } // namespace sheaf
129 
130 #endif // ifndef ANY_H
131 
Abstract base class with useful features for all objects.
Definition: any.h:39
int disable_invariance_check_request_depth() const
Number of times disable_invariant_check has been called without matching call to enable_invariant_che...
Definition: any.h:106
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
Namespace for the sheaves component of the sheaf system.
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87