CVC3
2.4.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
include
cdo.h
Go to the documentation of this file.
1
/*****************************************************************************/
2
/*!
3
* \file cdo.h
4
*
5
* Author: Clark Barrett
6
*
7
* Created: Wed Feb 12 17:27:43 2003
8
*
9
* <hr>
10
*
11
* License to use, copy, modify, sell and/or distribute this software
12
* and its documentation for any purpose is hereby granted without
13
* royalty, subject to the terms and conditions defined in the \ref
14
* LICENSE file provided with this distribution.
15
*
16
* <hr>
17
*
18
*/
19
/*****************************************************************************/
20
21
#ifndef _cvc3__include__cdo_h_
22
#define _cvc3__include__cdo_h_
23
24
#include "
context.h
"
25
26
namespace
CVC3 {
27
28
///////////////////////////////////////////////////////////////////////////////
29
// //
30
// Class: CDO (Context Dependent Object) //
31
// Author: Clark Barrett //
32
// Created: Wed Feb 12 17:28:25 2003 //
33
// Description: Generic templated class for an object which must be saved //
34
// and restored as contexts are pushed and popped. Requires //
35
// that operator= be defined for the data class. //
36
// //
37
///////////////////////////////////////////////////////////////////////////////
38
template
<
class
T>
39
class
CDO
:
public
ContextObj
{
40
T
d_data
;
41
42
virtual
ContextObj
*
makeCopy
(
ContextMemoryManager
* cmm)
43
{
return
new
(cmm)
CDO<T>
(*
this
); }
44
virtual
void
restoreData
(
ContextObj
* data) {
45
d_data
= ((
CDO<T>
*)data)->d_data;
46
}
47
virtual
void
setNull
(
void
) {
d_data
= T(); }
48
49
// Disable copy constructor and operator=
50
// If you need these, use smartcdo instead
51
CDO
(
const
CDO<T>
& cdo):
ContextObj
(cdo),
d_data
(cdo.
d_data
) { }
52
CDO<T>
&
operator=
(
const
CDO<T>
& cdo) {}
53
54
public
:
55
CDO
(
Context
* context) :
ContextObj
(context)
56
{
IF_DEBUG
(setName(
"CDO"
);) }
57
CDO
(
Context
* context,
const
T& data,
int
scope = -1)
58
:
ContextObj
(context) {
59
IF_DEBUG
(setName(
"CDO"
)); ;
60
set
(data, scope);
61
}
62
~CDO
() {}
63
void
set
(
const
T& data,
int
scope=-1) {
makeCurrent
(scope);
d_data
= data; }
64
const
T&
get
()
const
{
return
d_data
; }
65
operator
T() {
return
get
(); }
66
CDO<T>
&
operator=
(
const
T& data) {
set
(data);
return
*
this
; }
67
68
};
69
70
}
71
72
#endif
context.h
CVC3::CDO::operator=
CDO< T > & operator=(const T &data)
Definition:
cdo.h:66
CVC3::CDO
Definition:
cdo.h:39
CVC3::ContextObj
Definition:
context.h:200
CVC3::CDO::set
void set(const T &data, int scope=-1)
Definition:
cdo.h:63
CVC3::CDO::CDO
CDO(const CDO< T > &cdo)
Definition:
cdo.h:51
CVC3::ContextObj::makeCurrent
void makeCurrent(int scope=-1)
Definition:
context.h:274
CVC3::CDO::CDO
CDO(Context *context)
Definition:
cdo.h:55
CVC3::CDO::CDO
CDO(Context *context, const T &data, int scope=-1)
Definition:
cdo.h:57
CVC3::ContextObj::ContextObj
ContextObj(const ContextObj &co)
Copy constructor (defined mainly for debugging purposes)
Definition:
context.h:220
CVC3::CDO::makeCopy
virtual ContextObj * makeCopy(ContextMemoryManager *cmm)
Make a copy of the current object so it can be restored to its current state.
Definition:
cdo.h:42
CVC3::CDO::restoreData
virtual void restoreData(ContextObj *data)
Restore the current object from the given data.
Definition:
cdo.h:44
CVC3::ContextMemoryManager
ContextMemoryManager.
Definition:
memory_manager_context.h:44
IF_DEBUG
#define IF_DEBUG(code)
Definition:
debug.h:406
CVC3::CDO::d_data
T d_data
Definition:
cdo.h:40
CVC3::Context
Definition:
context.h:306
CVC3::CDO::setNull
virtual void setNull(void)
Set the current object to be invalid.
Definition:
cdo.h:47
CVC3::CDO::operator=
CDO< T > & operator=(const CDO< T > &cdo)
Definition:
cdo.h:52
CVC3::CDO::~CDO
~CDO()
Definition:
cdo.h:62
Generated on Mon Sep 15 2014 15:00:50 for CVC3 by
1.8.7