~ubuntu-branches/ubuntu/intrepid/tcm/intrepid

« back to all changes in this revision

Viewing changes to src/sd/bv/eventset.h

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _EVENTSET_H
 
2
#define _EVENTSET_H
 
3
 
 
4
#include "bool.h"
 
5
#include "llist.h"
 
6
#include "lstring.h"
 
7
#include <string.h>
 
8
 
 
9
#define MAX_EVENTS 256
 
10
 
 
11
class RelevantSet;
 
12
 
 
13
class EventSet {
 
14
        private:
 
15
                static List<string> EventNames;
 
16
 
 
17
                int current;
 
18
                unsigned char EventFlag   [(MAX_EVENTS + 7) / 8];
 
19
 
 
20
                friend class RelevantSet;
 
21
        public:
 
22
                EventSet();
 
23
                ~EventSet() { };
 
24
                unsigned add(const string &event);
 
25
                void sub(string event);
 
26
                void clear();
 
27
                bool HasEvent(string event) const;
 
28
                unsigned count() const;
 
29
                bool empty() const;
 
30
                const string &operator[](int index) const;
 
31
                bool operator==(const EventSet &comp) const {
 
32
                        return memcmp(&EventFlag, &comp.EventFlag, (MAX_EVENTS + 7) / 8) == 0;
 
33
                };
 
34
                bool operator< (const EventSet &comp) const {
 
35
                        return memcmp(&EventFlag, &comp.EventFlag, (MAX_EVENTS + 7) / 8) < 0;
 
36
                };
 
37
                bool operator> (const EventSet &comp) const {
 
38
                        return comp < *this;
 
39
                };
 
40
                bool operator<=(const EventSet &comp) const {
 
41
                        return ! (comp < *this);
 
42
                };
 
43
                bool operator>=(const EventSet &comp) const {
 
44
                        return ! (*this < comp);
 
45
                };
 
46
                bool operator!=(const EventSet &comp) const {
 
47
                        return ! (*this == comp);
 
48
                };
 
49
 
 
50
                bool first();
 
51
                bool last();
 
52
                const string &cur() {
 
53
                        return current < 0 ? string::EMPTY : EventNames[current];
 
54
                };
 
55
                bool next();
 
56
                bool prev();
 
57
                void print();
 
58
                string GetEvents(const char *prefix = (const char *) NULL)
 
59
                        const;
 
60
                string GetGuards() const;
 
61
};
 
62
 
 
63
#endif
 
64
 
 
65
 
 
66