diff options
| author | randomdan <randomdan@localhost> | 2014-07-04 10:26:58 +0000 |
|---|---|---|
| committer | randomdan <randomdan@localhost> | 2014-07-04 10:26:58 +0000 |
| commit | fe8a20a09f732f6bc2ff38a97ea528b11eeeac57 (patch) | |
| tree | 5e3d92a9151ee7a56c3a353430d1a7c61c696444 /slicer/slicer | |
| parent | Fix handling of Byte data type (treat as integer) (diff) | |
| download | slicer-fe8a20a09f732f6bc2ff38a97ea528b11eeeac57.tar.bz2 slicer-fe8a20a09f732f6bc2ff38a97ea528b11eeeac57.tar.xz slicer-fe8a20a09f732f6bc2ff38a97ea528b11eeeac57.zip | |
Adds core support for model part approximate type (complex, simple, sequence, etc)
Adds support for JSON
Diffstat (limited to 'slicer/slicer')
| -rw-r--r-- | slicer/slicer/modelParts.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h index 28ab86d..ca1573a 100644 --- a/slicer/slicer/modelParts.h +++ b/slicer/slicer/modelParts.h @@ -60,6 +60,13 @@ namespace Slicer { typedef boost::function<ModelPartPtr(void *)> ClassRef; typedef std::map<std::string, ClassRef> ClassRefMap; ClassRefMap * & classRefMap(); + enum ModelPartType { + mpt_Null, + mpt_Simple, + mpt_Complex, + mpt_Sequence, + mpt_Dictionary, + }; class ModelPart : public IceUtil::Shared { public: @@ -69,6 +76,7 @@ namespace Slicer { virtual ModelPartPtr GetChild(const std::string & memberName) = 0; virtual ModelPartPtr GetSubclassModelPart(const std::string &); virtual TypeId GetTypeId() const; + virtual ModelPartType GetType() const = 0; virtual void Create(); virtual void Complete(); virtual void SetValue(ValueSourcePtr); @@ -94,6 +102,7 @@ namespace Slicer { virtual void SetValue(ValueSourcePtr s) override { s->set(Member); } virtual void GetValue(ValueTargetPtr s) override { s->get(Member); } virtual bool HasValue() const override { return true; } + virtual ModelPartType GetType() const { return mpt_Simple; } private: T & Member; @@ -160,6 +169,14 @@ namespace Slicer { virtual bool HasValue() const override { return OptionalMember; } + virtual ModelPartType GetType() const + { + if (HasValue()) { + return modelPart->GetType(); + } + return mpt_Null; + } + private: IceUtil::Optional< typename T::element_type > & OptionalMember; ModelPartPtr modelPart; @@ -217,6 +234,8 @@ namespace Slicer { return NULL; } + virtual ModelPartType GetType() const { return mpt_Complex; } + virtual T * GetModel() = 0; typedef std::vector<HookPtr> Hooks; @@ -359,6 +378,8 @@ namespace Slicer { virtual bool HasValue() const override { return true; } + virtual ModelPartType GetType() const { return mpt_Sequence; } + private: ModelPartPtr elementModelPart(typename T::value_type &) const; @@ -435,6 +456,8 @@ namespace Slicer { virtual bool HasValue() const override { return true; } + virtual ModelPartType GetType() const { return mpt_Dictionary; } + private: T & dictionary; static std::string pairName; |
