diff options
author | JackLivio <jack@livio.io> | 2018-08-01 14:06:34 -0400 |
---|---|---|
committer | JackLivio <jack@livio.io> | 2018-08-01 14:06:34 -0400 |
commit | ea4a1731986b7f420c31f978edc7219edde448be (patch) | |
tree | 15fb0a6a4543c58f04cd3bc180b1e6e7834cc8ed /src/components/smart_objects/include/smart_objects/object_schema_item.h | |
parent | 9727cd2cd185d2ea3ea028aab89cb419d1ad4a87 (diff) | |
download | sdl_core-ea4a1731986b7f420c31f978edc7219edde448be.tar.gz |
Add support for mandatory and removed versioning
Diffstat (limited to 'src/components/smart_objects/include/smart_objects/object_schema_item.h')
-rw-r--r-- | src/components/smart_objects/include/smart_objects/object_schema_item.h | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h index 4c0def558b..df5a34a25a 100644 --- a/src/components/smart_objects/include/smart_objects/object_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h @@ -37,6 +37,8 @@ #include <set> #include "utils/macro.h" +#include "utils/semantic_version.h" +#include <boost/optional.hpp> #include "smart_objects/schema_item.h" #include "smart_objects/schema_item_parameter.h" @@ -62,7 +64,20 @@ class CObjectSchemaItem : public ISchemaItem { * @param IsMandatory true if member is mandatory, false * otherwise. Defaults to true. **/ - SMember(const ISchemaItemPtr SchemaItem, const bool IsMandatory = true); + //SMember(const ISchemaItemPtr SchemaItem, const bool IsMandatory = true); + + SMember(const ISchemaItemPtr SchemaItem, + const bool IsMandatory = true, + const std::string& Since = "", + const std::string& Until = "", + const bool IsDeprecated = false, + const bool IsRemoved = false); + /** + * @brief Checks the version a parameter was removed (until) + * If the mobile's msg version is greater than or + **/ + bool CheckHistoryFieldVersion(const utils::SemanticVersion& MessageVersion) const; + /** * @brief Member schema item. **/ @@ -71,6 +86,11 @@ class CObjectSchemaItem : public ISchemaItem { * @brief true if member is mandatory, false otherwise. **/ bool mIsMandatory; + boost::optional<utils::SemanticVersion> mSince; + boost::optional<utils::SemanticVersion> mUntil; + bool mIsDeprecated; + bool mIsRemoved; + }; typedef std::map<std::string, SMember> Members; /** @@ -98,13 +118,22 @@ class CObjectSchemaItem : public ISchemaItem { Errors::eType validate(const SmartObject& Object, rpc::ValidationReport* report__) OVERRIDE; /** + * @brief Validate smart object. + * @param Object Object to validate. + * @param report__ object for reporting errors during validation + * @param MessageVersion to check mobile RPC version against RPC Spec History + * @return NsSmartObjects::Errors::eType + **/ + Errors::eType validate(const SmartObject& Object, + rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion) OVERRIDE; + /** * @brief Apply schema. * @param Object Object to apply schema. * @param RemoveFakeParameters contains true if need to remove fake parameters * from smart object otherwise contains false. **/ void applySchema(SmartObject& Object, - const bool RemoveFakeParameters) OVERRIDE; + const bool RemoveFakeParameters, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion()) OVERRIDE; /** * @brief Unapply schema. * @param Object Object to unapply schema. @@ -136,7 +165,14 @@ class CObjectSchemaItem : public ISchemaItem { * @brief Removes fake parameters from object. * @param Object Object to remove fake parameters. **/ - void RemoveFakeParams(SmartObject& Object); + void RemoveFakeParams(SmartObject& Object, const utils::SemanticVersion& MessageVersion); + + /** + * @brief Checks mandatory and version fields to see + * if a member is required. + * @param Object Object to remove fake parameters. + **/ + bool IsMandatory(const SMember& member); /** * @brief Map of member name to SMember structure describing the object |