X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frest%2Fmodel%2FModelBase.h;fp=src%2Frest%2Fmodel%2FModelBase.h;h=0000000000000000000000000000000000000000;hb=e64778dac480d66d93449efd3e9767cea4f980f9;hp=159b772ded1203e49e70ae7369e2167a8d325007;hpb=56044b79a2282e50a8c271b36289b1724cb40cd8;p=ric-plt%2Fxapp-frame-cpp.git diff --git a/src/rest/model/ModelBase.h b/src/rest/model/ModelBase.h deleted file mode 100644 index 159b772..0000000 --- a/src/rest/model/ModelBase.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef XAPP_MODEL_ModelBase_H -#define XAPP_MODEL_ModelBase_H -#include -#include -#include -#include -#include - -using nlohmann::json_schema::json_validator; -using json = nlohmann::json; - -namespace xapp { -namespace model { - -std::invalid_argument invalid_parameter("Invalid Json Input"); - -template -bool _validate(const ModelType model) { - json _json = model; - json_validator validator; - validator.set_root_schema(model.validator_schema); - - try { - validator.validate(_json); - } catch (const std::exception& e) { - std::cerr << "Struct Validation failed, here is why: " << e.what() << "\n"; - throw; - } - return true; -} - -struct ModelBase { - json validator_schema = R"( - { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ModelBase" - })"_json; - - bool validate_() { - return _validate(std::move(*this)); - } - - void validate_json(const json& _json) { - json_validator validator; - validator.set_root_schema(get_validator_schema()); - try { - validator.validate(_json); - } catch (const std::exception& e) { - throw; - } - return; - } - - virtual json get_validator_schema() const { return validator_schema; } -}; - -void from_json(const json& j, ModelBase& ref) { - return; -} -void to_json(json& j, const ModelBase& ref) { - return; -} - -} /*model*/ -} /*xapp*/ -#endif /*XAPP_MODEL_ModelBase_H*/