diff options
| -rw-r--r-- | slicer/slicer/modelParts.cpp | 6 | ||||
| -rw-r--r-- | slicer/slicer/modelParts.h | 10 | 
2 files changed, 14 insertions, 2 deletions
diff --git a/slicer/slicer/modelParts.cpp b/slicer/slicer/modelParts.cpp index 3c839e8..d0747e4 100644 --- a/slicer/slicer/modelParts.cpp +++ b/slicer/slicer/modelParts.cpp @@ -111,6 +111,12 @@ namespace Slicer {  		return ref ? ref->Child() : ModelPartPtr(NULL);  	} +	bool +	ModelPart::IsOptional() const +	{ +		return false; +	} +  	template<> DLL_PUBLIC std::string Slicer::ModelPartForRoot<std::string>::rootName = "String";  	template<> DLL_PUBLIC std::string Slicer::ModelPartForRoot<bool>::rootName = "Boolean";  	template<> DLL_PUBLIC std::string Slicer::ModelPartForRoot<Ice::Float>::rootName = "Float"; diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h index 6903de6..863a72b 100644 --- a/slicer/slicer/modelParts.h +++ b/slicer/slicer/modelParts.h @@ -195,6 +195,7 @@ namespace Slicer {  			virtual void GetValue(ValueTargetPtr);  			virtual bool HasValue() const = 0;  			virtual const Metadata & GetMetadata() const; +			virtual bool IsOptional() const;  			static const std::string & ToExchangeTypeName(const std::string &);  			static const std::string & ToModelTypeName(const std::string &); @@ -326,12 +327,15 @@ namespace Slicer {  				modelPart->GetValue(s);  			} -			virtual bool HasValue() const override { return OptionalMember; } +			virtual bool HasValue() const override { return OptionalMember && modelPart->HasValue(); }  			virtual ModelPartType GetType() const  			{  				return T::type;  			} + +			virtual bool IsOptional() const override { return true; }; +  			virtual const Metadata & GetMetadata() const override { return modelPart->GetMetadata(); }  		private: @@ -544,13 +548,15 @@ namespace Slicer {  				return *ModelObject;  			} -			virtual bool HasValue() const override { return ModelObject; } +			virtual bool HasValue() const override { return ModelObject && mp->HasValue(); }  			virtual ModelPartType GetType() const override  			{  				return mp->GetType();  			} +			virtual bool IsOptional() const override { return mp->IsOptional(); } +  		private:  			T * ModelObject;  			bool owned;  | 
