sempr-tk / sempr

SEMPR - Semantic Environment Mapping, Processing and Reasoning
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

RDFPropertyMap refactoring #31

Open niniemann opened 6 years ago

niniemann commented 6 years ago

Okay, so there is more than just the problems stated in #30 . Right now I wanted to actually remove one property from a RDFPropertyMap, but only implemented a workaround in b2ee78e91ccaaffb3074505d3b8f2595fdc6d7fc because this touches something deep internally: Every map entry stores the index to where the actual RDF triple in the RDFEntity lies. So if I want to remove one entry I'd need to update all the other ones.

I'd like to rework this a bit, and provide an alternative implementation/strategy to the RDFPropertyMap. The RDFPropertyMap right now is totally dynamic in size as well as in the types of its entries. A static variant of it would be nice: Maybe fixed in size? But at least with somewhat fixed entries. A templated version of the RDFValueProxy, and maybe without the key but with indices instead, so that one could e.g. use it as

class MyEntity : public Entity {
    using Ptr = std::shared_ptr<MyEntity>;
    RDFTripleArray rdf_;
    RDFValue<int> age_;
    RDFValue<std::string> name_;
    RDFValue<MyEntity::Ptr> someRelation_;

public:
    MyEntity() : age_(rdf_, 0), name_(rdf_, 1), someRelation_(rdf_, 2)
    { }
};

Or the like. Just some idea.

Woops: These are 2 things.

  1. Fix RDFPropertyMap to correctly remove entries.
  2. Implement a more static alternative.