source: icGREP/icgrep-devel/icgrep/re/re_re.h @ 6225

Last change on this file since 6225 was 6225, checked in by cameron, 4 months ago

PrintStats? for REs

File size: 1.2 KB
Line 
1/*
2 *  Copyright (c) 2018 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef RE_H
8#define RE_H
9
10#include <util/slab_allocator.h>
11#include <vector>
12
13namespace re {
14
15class RE {
16public:
17    using Allocator = SlabAllocator<RE *>;
18    using VectorAllocator = ProxyAllocator<RE *>;
19    enum class ClassTypeId : unsigned {
20        Alt
21        , Assertion
22        , CC
23        , Range
24        , Diff
25        , End
26        , Intersect
27        , Name
28        , Group
29        , Rep
30        , Seq
31        , Start
32    };
33    inline ClassTypeId getClassTypeId() const {
34        return mClassTypeId;
35    }
36    inline static void Reset() {
37        mAllocator.Reset();
38    }
39    inline static void PrintStats() {
40        mAllocator.PrintStats();
41    }
42    typedef std::initializer_list<RE *> InitializerList;
43
44protected:
45    inline RE(const ClassTypeId id)
46    : mClassTypeId(id) {
47
48    }
49    void* operator new (std::size_t size) noexcept {
50        return mAllocator.allocate<uint8_t>(size);
51    }
52    const ClassTypeId mClassTypeId;
53    static Allocator mAllocator;
54};
55
56}
57
58#endif // RE_H
59
60
Note: See TracBrowser for help on using the repository browser.