Menu

[r3]: / libtop_engine / psearch_node.h  Maximize  Restore  History

Download this file

266 lines (192 with data), 7.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#ifndef PSEARCH_NODE_H_
#define PSEARCH_NODE_H_
#include "psearch_core.h"
namespace psearch {
/////////////////////////////////////////////////////////////////////////////////////////
// class Node
//
// The set of patterns attribute to Node correspond to the patterns for which
// this node is included in their neccessairy and sufficient criteria (nsc.)
/////////////////////////////////////////////////////////////////////////////////////////
class Node: public PSBase
{
public:
inline Node(PSearchDB * db_p, index_type index):
PSBase(db_p, index),
m_rules(),
m_patterns(),
m_skip_pattern_activation(false)
{};
inline node_index_type
get_node_index()const
{
return this;
};
//////////////////////////////////////////////////////////////////////////////////////
// relationship with Rule
/////////////////////////////////////////////////////////////////////////////////////
// returns true if this node is included in the pattern's c1 set.
inline bool
is_c1_to_rule(rule_index_type pindex)const
{
return m_rules.find(pindex) != m_rules.end();
};
inline rule_const_iterator_type
get_rules_begin()const
{
return m_rules.begin();
};
inline rule_const_iterator_type
get_rules_end()const
{
return m_rules.end();
};
inline rule_set_const_iterator
get_rules_iterator()const
{
return rule_set_const_iterator(get_rules_begin(), get_rules_end());
};
inline size_t
get_nbr_rules()const
{
return m_rules.size();
};
//////////////////////////////////////////////////////////////////////////////////////
// relationship with Pattern
/////////////////////////////////////////////////////////////////////////////////////
inline bool
is_skip_pattern_activation() const
{
return m_skip_pattern_activation;
};
// returns true if this node is included in the pattern's c1 set.
inline bool
is_c1_to_pattern(pattern_index_type pindex)const
{
return m_patterns.find(pindex) != m_patterns.end();
};
inline pattern_const_iterator_type
get_patterns_begin()const
{
return m_patterns.begin();
};
inline pattern_const_iterator_type
get_patterns_end()const
{
return m_patterns.end();
};
inline pattern_set_const_iterator
get_patterns_iterator()const
{
return pattern_set_const_iterator(get_patterns_begin(), get_patterns_end());
};
inline size_t
get_nbr_patterns()const
{
return m_patterns.size();
};
///////////////////////////////////////////////////////////////////////////////////////
// relationship to Category
//////////////////////////////////////////////////////////////////////////////////////
inline bool
has_category(category_index_type category_index)const
{
return m_categories.find(category_index) != m_categories.end();
};
inline category_const_iterator_type
get_categories_begin()const
{
return m_categories.begin();
};
inline category_const_iterator_type
get_categories_end()const
{
return m_categories.end();
};
inline category_set_const_iterator
get_categories_iterator()const
{
return category_set_const_iterator(get_categories_begin(), get_categories_end());
};
inline size_t
get_nbr_categories()const
{
return m_categories.size();
};
protected:
inline void
set_skip_pattern_activation(bool b)
{
m_skip_pattern_activation = b;
};
//////////////////////////////////////////////////////////////
// rule
//////////////////////////////////////////////////////////////
inline void
add_rule(rule_index_type rule_index)
{
if(!rule_index) return;
m_rules.insert(rule_index);
};
inline void
remove_rule(rule_index_type rule_index)
{
m_rules.erase(rule_index);
};
inline void
remove_all_rules()
{
m_rules.clear();
};
//////////////////////////////////////////////////////////////
// pattern
//////////////////////////////////////////////////////////////
inline void
add_pattern(pattern_index_type pattern_index)
{
if(!pattern_index) return;
m_patterns.insert(pattern_index);
};
inline void
remove_pattern(pattern_index_type pattern_index)
{
m_patterns.erase(pattern_index);
};
inline void
remove_all_patterns()
{
m_patterns.clear();
};
inline void
add_category(category_index_type category_index)
{
if(!category_index) return;
m_categories.insert(category_index);
};
inline void
remove_category(category_index_type category_index)
{
m_categories.erase(category_index);
};
inline void
remove_all_categories()
{
m_categories.clear();
};
private:
friend class PSearchDB;
friend class Rule;
friend std::ostream& operator<<(std::ostream& out, Node const& node);
friend std::ostream& operator<<(std::ostream& out, node_index_type node_index);
rule_set_type m_rules;
pattern_set_type m_patterns;
category_set_type m_categories;
bool m_skip_pattern_activation;
};
inline std::ostream& operator<<(std::ostream& out, node_index_type node_index)
{
out << *node_index;
return out;
};
}; /* psearch namespace */
#endif /*PSEARCH_NODE_H_*/
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.