replicode
Main Page
Namespaces
Classes
Files
File List
File Members
r_exec
domain.h
Go to the documentation of this file.
1
// domain.h
2
//
3
// Author: Eric Nivel
4
//
5
// BSD license:
6
// Copyright (c) 2010, Eric Nivel
7
// All rights reserved.
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are met:
10
//
11
// - Redistributions of source code must retain the above copyright
12
// notice, this list of conditions and the following disclaimer.
13
// - Redistributions in binary form must reproduce the above copyright
14
// notice, this list of conditions and the following disclaimer in the
15
// documentation and/or other materials provided with the distribution.
16
// - Neither the name of Eric Nivel nor the
17
// names of their contributors may be used to endorse or promote products
18
// derived from this software without specific prior written permission.
19
//
20
// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
21
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
// DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
24
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31
#ifndef domain_h
32
#define domain_h
33
34
#include "
binding_map.h
"
35
36
37
namespace
r_exec
{
38
/*
39
class Range:
40
public _Object{
41
public:
42
virtual void add(BindingMap *bm,uint64_t i)=0;
43
virtual void remove(BindingMap *bm,uint64_t i)=0;
44
virtual bool contains(BindingMap *bm,uint64_t i) const=0;
45
};
46
47
// Discrete range.
48
// Use for bool, std::string, P<Code>.
49
template<typename T> class DRange:
50
public Range{
51
private:
52
std::unordered_set<T> values;
53
54
void add(T value){
55
values.insert(value);
56
}
57
void remove(T value){
58
values.erase(value);
59
}
60
bool contains(T value) const{
61
return values.find(value)!=values.end();
62
}
63
public:
64
void add(BindingMap *bm,uint64_t i){}
65
void remove(BindingMap *bm,uint64_t i){}
66
bool contains(BindingMap *bm,uint64_t i) const{ return false; }
67
};
68
69
// Continuous range.
70
// Use for numerical intervals (double or uint64_t).
71
template<typename T> class CRange:
72
public Range{
73
private:
74
std::list<std::pair<T,T> > values;
75
76
void add(T value){
77
78
std::list<std::pair<T,T> >::const_iterator i;
79
for(i=values.begin();i!=values.end();++i){
80
81
82
83
}
84
}
85
void remove(T value){
86
87
std::list<std::pair<T,T> >::const_iterator i;
88
for(i=values.begin();i!=values.end();++i){
89
90
91
}
92
}
93
bool contains(T value) const{
94
95
std::list<std::pair<T,T> >::const_iterator i;
96
for(i=values.begin();i!=values.end();++i){
97
98
if((*i).first<=value && (*i).second>=value)
99
return true;
100
}
101
102
return false;
103
}
104
public:
105
void add(BindingMap *bm,uint64_t i){}
106
void remove(BindingMap *bm,uint64_t i){}
107
bool contains(BindingMap *bm,uint64_t i) const{ return false; }
108
};
109
110
// Last hidden reference of a model.
111
class Domain:
112
public Code{
113
private:
114
std::vector<P<Range> > ranges; // same indices as in a BindingMap.
115
public:
116
void add(BindingMap *bm);
117
void remove(BindingMap *bm);
118
bool contains(BindingMap *bm) const;
119
};*/
120
}
121
122
123
#endif
r_exec
Definition:
_context.cpp:34
binding_map.h
Generated on Wed Aug 5 2015 00:08:48 for replicode by
1.8.9.1