/********** More general specification-related types and operations **********/
-#define NewSet new set<Method>
+#define NewMethodSet new set<Method>
#define CAT(a, b) CAT_HELPER(a, b) /* Concatenate two symbols for macros! */
#define CAT_HELPER(a, b) a ## b
/*
#define Subset(s, subset, condition) \
MethodSet original = s; \
- MethodSet subset = NewSet; \
+ MethodSet subset = NewMethodSet; \
ForEach (_M, original) { \
if ((condition)) \
subset->insert(_M); \
return res;
}
+/**
+ A general set operation that takes a condition and returns if there exists
+ any item for which the boolean guard holds.
+*/
+template <class T>
+inline bool HasItem(set<T> *original, std::function<bool(T)> condition) {
+ ForEach (_M, original) {
+ if (condition(_M))
+ return true;
+ }
+ return false;
+}
+
+
+
/**
A general sublist operation that takes a condition and returns all the item
for which the boolean guard holds in the same order as in the old list.
MethodSet res;
va_start (ap, count);
- res = NewSet;
+ res = NewMethodSet;
for (int i = 0; i < count; i++) {
Method item = va_arg (ap, Method);
res->insert(item);
is2->insert(5);
- MethodSet ms = NewSet;
+ MethodSet ms = NewMethodSet;
Method m = new MethodCall;
m->interfaceName = "Store";
StateStruct *ss = new StateStruct;
ms->insert(m);
MakeSet(int, ms, newis, STATE(x));
- cout << "Size=" << Size(newis) << " | val= " << Belong(newis, 2) << endl;
+ //cout << "Size=" << Size(newis) << " | val= " << Belong(newis, 2) << endl;
+ cout << "HasItem=" << HasItem(ms, Guard(STATE(x) == 2)) << endl;
ForEach (i, newis) {
- cout << "elem: " << i << endl;
+ //cout << "elem: " << i << endl;
}