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

Last change on this file since 5350 was 5267, checked in by nmedfort, 3 years ago

Code clean-up. Removed Pablo Call, SetIthBit? and Prototype.

File size: 1.5 KB
Line 
1/*
2 *  Copyright (c) 2014 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        , Any
22        , Assertion
23        , CC
24        , Diff
25        , End
26        , Intersect
27        , Name
28        , Permute
29        , Rep
30        , Seq
31        , Start
32        , SymDiff
33        , Union
34    };
35    inline ClassTypeId getClassTypeId() const {
36        return mClassTypeId;
37    }
38    typedef std::initializer_list<RE *> InitializerList;
39protected:
40    inline RE(const ClassTypeId id)
41    : mClassTypeId(id) {
42
43    }
44    void* operator new (std::size_t size) noexcept {
45        return mAllocator.allocate<uint8_t>(size);
46    }
47    const ClassTypeId mClassTypeId;
48
49    static Allocator mAllocator;
50};
51
52class Vector : public RE, public std::vector<RE*, RE::VectorAllocator> {
53public:
54    virtual ~Vector() {}
55protected:
56    inline Vector(const ClassTypeId id)
57    : RE(id)
58    , std::vector<RE*, RE::VectorAllocator>(mAllocator)
59    {
60
61    }
62    inline Vector(const ClassTypeId id, const iterator begin, const iterator end)
63    : RE(id)
64    , std::vector<RE*, RE::VectorAllocator>(begin, end, mAllocator) {
65
66    }
67};
68
69}
70
71#endif // RE_H
72
73
Note: See TracBrowser for help on using the repository browser.