summaryrefslogtreecommitdiff
path: root/src/components/smart_objects
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-08-04 16:52:56 -0400
committerJackLivio <jack@livio.io>2018-08-04 16:52:56 -0400
commitfd7f61fae6e83a81449399080ae18efde16d6ccc (patch)
tree2f51a461eae95577ffe74a34d7ced2d48ba43a63 /src/components/smart_objects
parentf32ad14bf6f0e435433e899fa1381f5990f5c77d (diff)
downloadsdl_core-fd7f61fae6e83a81449399080ae18efde16d6ccc.tar.gz
Add enum history support to generator
Diffstat (limited to 'src/components/smart_objects')
-rw-r--r--src/components/smart_objects/include/smart_objects/enum_schema_item.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
index 787960659f..f6b7bdff92 100644
--- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
@@ -42,10 +42,40 @@
#include "smart_objects/default_shema_item.h"
#include "utils/semantic_version.h"
+#include <boost/optional.hpp>
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
+//Element Signature for enums. Fields represent "since", "until", and "removed"
+//typedef boost::optional<std::string> OptionalString;
+//typedef boost::optional<bool> OptionalBool;
+//typedef std::tuple<OptionalString, OptionalString, OptionalBool> ElementSignature;
+
+struct ElementSignature {
+ boost::optional<utils::SemanticVersion> mSince;
+ boost::optional<utils::SemanticVersion> mUntil;
+ bool mRemoved;
+
+ ElementSignature(std::string since="", std::string until="", bool removed=false) {
+ utils::SemanticVersion since_struct(since);
+ utils::SemanticVersion until_struct(until);
+
+ if(since_struct.isValid()) {
+ mSince = since_struct;
+ }
+
+ if(until_struct.isValid()) {
+ mUntil = until_struct;
+ }
+
+ mRemoved = removed;
+ }
+};
+
+//typedef std::map<OptionalString, OptionalString, OptionalBool> ElementSignature;
+
+
template <typename EnumType>
class EnumConversionHelper;
/**
@@ -65,6 +95,18 @@ class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
const std::set<EnumType>& AllowedElements,
const TSchemaItemParameter<EnumType>& DefaultValue =
TSchemaItemParameter<EnumType>());
+
+ /**
+ * @brief Create a new schema item.
+ * @param AllowedElements Set of allowed enumeration elements.
+ * @param DefaultValue Default value.
+ * @return Shared pointer to a new schema item.
+ **/
+ static std::shared_ptr<TEnumSchemaItem> createWithSignatures(
+ const std::set<EnumType>& AllowedElements,
+ const std::set<ElementSignature>& ElementSignatures,
+ const TSchemaItemParameter<EnumType>& DefaultValue =
+ TSchemaItemParameter<EnumType>());
/**
* @deprecated
* @brief Validate smart object.
@@ -115,12 +157,17 @@ class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
**/
TEnumSchemaItem(const std::set<EnumType>& AllowedElements,
const TSchemaItemParameter<EnumType>& DefaultValue);
+
+ TEnumSchemaItem(const std::set<EnumType>& AllowedElements,
+ const TSchemaItemParameter<EnumType>& DefaultValue,
+ const std::set<ElementSignature>& ElementSignatures);
SmartType getSmartType() const OVERRIDE;
EnumType getDefaultValue() const OVERRIDE;
/**
* @brief Set of allowed enumeration elements.
**/
const std::set<EnumType> mAllowedElements;
+ const std::set<ElementSignature> mElementSignatures;
/**
* @brief Default value.
**/
@@ -227,6 +274,15 @@ std::shared_ptr<TEnumSchemaItem<EnumType> > TEnumSchemaItem<EnumType>::create(
}
template <typename EnumType>
+std::shared_ptr<TEnumSchemaItem<EnumType> > TEnumSchemaItem<EnumType>::createWithSignatures(
+ const std::set<EnumType>& AllowedElements,
+ const std::set<ElementSignature>& ElementSignatures,
+ const TSchemaItemParameter<EnumType>& DefaultValue ) {
+ return std::shared_ptr<TEnumSchemaItem<EnumType> >(
+ new TEnumSchemaItem<EnumType>(AllowedElements, DefaultValue, ElementSignatures));
+}
+
+template <typename EnumType>
Errors::eType TEnumSchemaItem<EnumType>::validate(const SmartObject& Object) {
rpc::ValidationReport report("RPC");
return validate(Object, &report);
@@ -303,6 +359,15 @@ TEnumSchemaItem<EnumType>::TEnumSchemaItem(
: CDefaultSchemaItem<EnumType>(DefaultValue)
, mAllowedElements(AllowedElements) {}
+template <typename EnumType>
+TEnumSchemaItem<EnumType>::TEnumSchemaItem(
+ const std::set<EnumType>& AllowedElements,
+ const TSchemaItemParameter<EnumType>& DefaultValue,
+ const std::set<ElementSignature>& ElementSignatures)
+ : CDefaultSchemaItem<EnumType>(DefaultValue)
+ , mAllowedElements(AllowedElements)
+ , mElementSignatures(mElementSignatures) {}
+
} // namespace NsSmartObjects
} // namespace NsSmartDeviceLink
#endif // SRC_COMPONENTS_SMART_OBJECTS_INCLUDE_SMART_OBJECTS_ENUM_SCHEMA_ITEM_H_