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

Last change on this file since 6195 was 6195, checked in by cameron, 6 months ago

Restructuring step: liminate RE:::Vector

File size: 1.1 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    typedef std::initializer_list<RE *> InitializerList;
40
41protected:
42    inline RE(const ClassTypeId id)
43    : mClassTypeId(id) {
44
45    }
46    void* operator new (std::size_t size) noexcept {
47        return mAllocator.allocate<uint8_t>(size);
48    }
49    const ClassTypeId mClassTypeId;
50    static Allocator mAllocator;
51};
52
53}
54
55#endif // RE_H
56
57
Note: See TracBrowser for help on using the repository browser.