1 /*****************************************************************************/
2 /*!
3  *\file cdflags.h
4  *\brief Context Dependent Vector of Flags
5  *
6  * Author: Clark Barrett
7  *
8  * Created: Thu Jan 26 16:37:46 2006
9  *
10  * <hr>
11  *
12  * License to use, copy, modify, sell and/or distribute this software
13  * and its documentation for any purpose is hereby granted without
14  * royalty, subject to the terms and conditions defined in the \ref
15  * LICENSE file provided with this distribution.
16  *
17  * <hr>
18  *
19  */
20 /*****************************************************************************/
21 
22 #ifndef _cvc3__include__cdflags_h_
23 #define _cvc3__include__cdflags_h_
24 
25 #include "context.h"
26 #include "os.h"
27 
28 namespace CVC3 {
29 
30 ///////////////////////////////////////////////////////////////////////////////
31 //                                                                           //
32 // Class: CDFlags (Context Dependent Vector of Flags)			     //
33 // Author: Clark Barrett                                                     //
34 // Created: Thu Jan 26 16:37:46 2006					     //
35 //                                                                           //
36 ///////////////////////////////////////////////////////////////////////////////
37 class CVC_DLL CDFlags :public ContextObj {
38   unsigned d_flags;
39 
makeCopy(ContextMemoryManager * cmm)40   virtual ContextObj* makeCopy(ContextMemoryManager* cmm)
41     { return new(cmm) CDFlags(*this); }
restoreData(ContextObj * data)42   virtual void restoreData(ContextObj* data)
43     { d_flags = ((CDFlags*)data)->d_flags; }
setNull(void)44   virtual void setNull(void) { FatalAssert(false, "Should never be called"); }
45 
46   void update(unsigned mask, int scope, bool setMask);
47 
48   // Disable copy constructor and operator=
49   // If you need these, use smartcdo instead
CDFlags(const CDFlags & cdflags)50   CDFlags(const CDFlags& cdflags): ContextObj(cdflags), d_flags(cdflags.d_flags) { }
51   CDFlags& operator=(const CDFlags& cdflags) { return *this; }
52 
53 public:
CDFlags(Context * context)54   CDFlags(Context* context) : ContextObj(context), d_flags(0)
55     { IF_DEBUG(setName("CDFlags");) }
~CDFlags()56   ~CDFlags() {}
57   void set(unsigned mask, int scope=-1) { update(mask, scope, true); }
58   void clear(unsigned mask, int scope=-1) { update(mask, scope, false); }
get(unsigned mask)59   bool get(unsigned mask) const { return (d_flags & mask) != 0; }
60 };
61 
62 }
63 
64 #endif
65