Ignore:
Timestamp:
Nov 28, 2017, 1:45:19 AM (21 months ago)
Author:
nmedfort
Message:

Bug fix for segment pipeline parallel mode + memory management improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.h

    r5684 r5748  
    5959    }
    6060   
    61     BinaryPropertyObject(UCD::property_t p, UnicodeSet s)
     61    BinaryPropertyObject(UCD::property_t p, const UnicodeSet && set)
    6262    : PropertyObject(p, ClassTypeId::BinaryProperty)
    6363    , mNoUninitialized(true)
    64     , mY(s) {
     64    , mY(std::move(set)) {
    6565       
    6666    }
     
    7171private:
    7272    bool mNoUninitialized;
    73     UnicodeSet mY;
     73    const UnicodeSet mY;
    7474    UnicodeSet mN;
    7575    std::string mPropertyValueGrepString;
     
    8787    EnumeratedPropertyObject(UCD::property_t p,
    8888                             const unsigned independent_enums,
    89                              const std::vector<std::string> & enum_names,
    90                              const std::vector<std::string> & names,
    91                              std::unordered_map<std::string, int> & aliases,
     89                             const std::vector<std::string> && enum_names,
     90                             const std::vector<std::string> && names,
     91                             std::unordered_map<std::string, int> && aliases,
    9292                             std::vector<const UnicodeSet *> && sets)
    9393    : PropertyObject(p, ClassTypeId::EnumeratedProperty)
    9494    , independent_enum_count(independent_enums)
    95     , property_value_enum_names(enum_names)
    96     , property_value_full_names(names)
    97     , property_value_aliases(aliases)
     95    , property_value_enum_names(std::move(enum_names))
     96    , property_value_full_names(std::move(names))
     97    , property_value_aliases(std::move(aliases))
    9898    , uninitialized(true)
    99     , property_value_sets(sets) {
     99    , property_value_sets(std::move(sets)) {
    100100
    101101    }
     
    120120private:
    121121    const unsigned independent_enum_count;
    122     const std::vector<std::string> & property_value_enum_names;  // never changes
    123     const std::vector<std::string> & property_value_full_names;  // never changes
    124     std::unordered_map<std::string, int> & property_value_aliases;
     122    const std::vector<std::string> property_value_enum_names;
     123    const std::vector<std::string> property_value_full_names;
     124    std::unordered_map<std::string, int> property_value_aliases;
    125125    std::string mPropertyValueGrepString;
    126126    bool uninitialized; // full names must be added dynamically.
     
    140140    ExtensionPropertyObject(UCD::property_t p,
    141141                            UCD::property_t base,
    142                             std::vector<const UnicodeSet *> && sets)
     142                            const std::vector<const UnicodeSet *> && sets)
    143143    : PropertyObject(p, ClassTypeId::ExtensionProperty)
    144144    , base_property(base)
     
    172172    }
    173173   
    174     NumericPropertyObject(UCD::property_t p, UnicodeSet NaN_Set, const char * string_buffer, unsigned bufsize, const std::vector<UCD::codepoint_t> & cps)
     174    NumericPropertyObject(UCD::property_t p, const UnicodeSet && NaN_Set, const char * string_buffer, unsigned bufsize, const std::vector<UCD::codepoint_t> && cps)
    175175    : PropertyObject(p, ClassTypeId::NumericProperty)
    176     , mNaNCodepointSet(NaN_Set)
     176    , mNaNCodepointSet(std::move(NaN_Set))
     177    , mStringBuffer(string_buffer)
     178    , mBufSize(bufsize)
     179    , mExplicitCps(std::move(cps))
     180    {
     181       
     182    }
     183    const UnicodeSet GetCodepointSet(const std::string & numeric_spec) override;
     184    const UnicodeSet GetCodepointSetMatchingPattern(re::RE * pattern) override;
     185
     186private:
     187    const UnicodeSet mNaNCodepointSet;  // codepoints for which the property value is NaN (not a number).
     188    const char * mStringBuffer;  // buffer holding all string values for other codepoints, in sorted order.
     189    unsigned mBufSize;
     190    const std::vector<UCD::codepoint_t> mExplicitCps;
     191};
     192
     193class StringPropertyObject : public PropertyObject {
     194public:
     195    static inline bool classof(const PropertyObject * p) {
     196        return p->getClassTypeId() == ClassTypeId::StringProperty;
     197    }
     198    static inline bool classof(const void *) {
     199        return false;
     200    }
     201    StringPropertyObject(UCD::property_t p, const UnicodeSet && nullSet, const UnicodeSet && mapsToSelf, const char * string_buffer, unsigned bufsize, const std::vector<UCD::codepoint_t> && cps)
     202    : PropertyObject(p, ClassTypeId::StringProperty)
     203    , mNullCodepointSet(std::move(nullSet))
     204    , mSelfCodepointSet(std::move(mapsToSelf))
     205    , mStringBuffer(string_buffer)
     206    , mBufSize(bufsize)
     207    , mExplicitCps(cps)
     208    {
     209
     210    }
     211    const UnicodeSet GetCodepointSet(const std::string & value_spec) override;
     212    const UnicodeSet GetCodepointSetMatchingPattern(re::RE * pattern) override;
     213    const UnicodeSet GetReflexiveSet() override;
     214   
     215private:
     216    const UnicodeSet mNullCodepointSet;  // codepoints for which the property value is the null string.
     217    const UnicodeSet mSelfCodepointSet;  // codepoints for which the property value is the codepoint itself.
     218    const char * mStringBuffer;  // buffer holding all string values for other codepoints, in sorted order.
     219    unsigned mBufSize;
     220    const std::vector<UCD::codepoint_t> mExplicitCps;
     221
     222};
     223   
     224class StringOverridePropertyObject : public PropertyObject {
     225public:
     226    static inline bool classof(const PropertyObject * p) {
     227        return p->getClassTypeId() == ClassTypeId::StringOverrideProperty;
     228    }
     229    static inline bool classof(const void *) {
     230        return false;
     231    }
     232    StringOverridePropertyObject(UCD::property_t p, PropertyObject & baseObj, const UnicodeSet && overriddenSet, const char * string_buffer, unsigned bufsize, const std::vector<UCD::codepoint_t> && cps)
     233    : PropertyObject(p, ClassTypeId::StringOverrideProperty)
     234    , mBaseObject(baseObj)
     235    , mOverriddenSet(std::move(overriddenSet))
    177236    , mStringBuffer(string_buffer)
    178237    , mBufSize(bufsize)
     
    181240       
    182241    }
    183     const UnicodeSet GetCodepointSet(const std::string & numeric_spec) override;
    184     const UnicodeSet GetCodepointSetMatchingPattern(re::RE * pattern) override;
    185 
    186 private:
    187     UnicodeSet mNaNCodepointSet;  // codepoints for which the property value is NaN (not a number).
    188     const char * mStringBuffer;  // buffer holding all string values for other codepoints, in sorted order.
    189     unsigned mBufSize;
    190     const std::vector<UCD::codepoint_t> & mExplicitCps;
    191 };
    192 
    193 class StringPropertyObject : public PropertyObject {
    194 public:
    195     static inline bool classof(const PropertyObject * p) {
    196         return p->getClassTypeId() == ClassTypeId::StringProperty;
    197     }
    198     static inline bool classof(const void *) {
    199         return false;
    200     }
    201     StringPropertyObject(UCD::property_t p, UnicodeSet nullSet, UnicodeSet mapsToSelf, const char * string_buffer, unsigned bufsize, const std::vector<UCD::codepoint_t> & cps)
    202     : PropertyObject(p, ClassTypeId::StringProperty)
    203     , mNullCodepointSet(nullSet)
    204     , mSelfCodepointSet(mapsToSelf)
    205     , mStringBuffer(string_buffer)
    206     , mBufSize(bufsize)
    207     , mExplicitCps(cps)
    208     {
    209 
    210     }
    211242    const UnicodeSet GetCodepointSet(const std::string & value_spec) override;
    212243    const UnicodeSet GetCodepointSetMatchingPattern(re::RE * pattern) override;
     
    214245   
    215246private:
    216     UnicodeSet mNullCodepointSet;  // codepoints for which the property value is the null string.
    217     UnicodeSet mSelfCodepointSet;  // codepoints for which the property value is the codepoint itself.
    218     const char * mStringBuffer;  // buffer holding all string values for other codepoints, in sorted order.
    219     unsigned mBufSize;
    220     const std::vector<UCD::codepoint_t> & mExplicitCps;
    221 
    222 };
    223    
    224 class StringOverridePropertyObject : public PropertyObject {
    225 public:
    226     static inline bool classof(const PropertyObject * p) {
    227         return p->getClassTypeId() == ClassTypeId::StringOverrideProperty;
    228     }
    229     static inline bool classof(const void *) {
    230         return false;
    231     }
    232     StringOverridePropertyObject(UCD::property_t p, PropertyObject & baseObj, UnicodeSet explicitly_defined, const char * string_buffer, unsigned bufsize, const std::vector<UCD::codepoint_t> & cps)
    233     : PropertyObject(p, ClassTypeId::StringOverrideProperty)
    234     , mBaseObject(baseObj)
    235     , mOverriddenSet(explicitly_defined)
    236     , mStringBuffer(string_buffer)
    237     , mBufSize(bufsize)
    238     , mExplicitCps(cps)
    239     {
    240        
    241     }
    242     const UnicodeSet GetCodepointSet(const std::string & value_spec) override;
    243     const UnicodeSet GetCodepointSetMatchingPattern(re::RE * pattern) override;
    244     const UnicodeSet GetReflexiveSet() override;
    245    
    246 private:
    247247    PropertyObject & mBaseObject;  // the base object that provides default values for this property unless overridden.
    248     UnicodeSet mOverriddenSet;   // codepoints for which the baseObject value is overridden.
     248    const UnicodeSet mOverriddenSet;   // codepoints for which the baseObject value is overridden.
    249249    const char * mStringBuffer;  // buffer holding all string values for overridden codepoints, in sorted order.
    250250    unsigned mBufSize;
    251     const std::vector<UCD::codepoint_t> & mExplicitCps;
     251    const std::vector<codepoint_t> mExplicitCps;
    252252   
    253253};
Note: See TracChangeset for help on using the changeset viewer.