SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
Requirement.h
1 
26 #pragma once
27 
28 #include <vector>
29 #include <map>
30 #include <memory>
31 #include "json/json.h"
32 
33 namespace Json
34 {
36 
40  {
41  private:
42  std::vector<std::string> errors_;
43  std::vector<std::string> notices_;
44 
45  protected:
47 
53  void PushError(const std::string& error) { errors_.push_back(error); }
54 
56 
62  void PushNotice(const std::string& notice) { notices_.push_back(notice); }
63 
64  public:
66 
70  virtual void Parse(Value json, const std::string& path) = 0;
71 
73 
77  virtual void Validate(const Value& json, const std::string& path) = 0;
78 
80  virtual void Reset() = 0;
81 
83 
86  bool HasErrors() { return errors_.size() != 0; };
87 
89 
92  std::vector<std::string> GetErrors() { return errors_; };
93 
95  virtual void ClearErrors() { errors_.clear(); }
96 
98 
101  virtual bool HasNotices() {return notices_.size() != 0; };
102 
104 
107  std::vector<std::string> GetNotices() {return notices_; };
108 
110  virtual void ClearNotices() { notices_.clear(); }
111 
113  virtual ~Requirement() {}
114  };
115 
117  using RequireList = std::vector<std::unique_ptr<Requirement>>;
118 }
Requirements on input files.
Definition: Requirement.h:40
void PushNotice(const std::string &notice)
Add message to list of notices.
Definition: Requirement.h:62
std::vector< std::string > notices_
List of messages.
Definition: Requirement.h:43
virtual void Reset()=0
Reset validator.
std::vector< std::string > GetNotices()
Get list of notices.
Definition: Requirement.h:107
std::vector< std::string > errors_
List of error messages.
Definition: Requirement.h:42
std::vector< std::string > GetErrors()
Get list of error messages.
Definition: Requirement.h:92
virtual ~Requirement()
Destructor.
Definition: Requirement.h:113
virtual void ClearNotices()
Clear list of notice messages.
Definition: Requirement.h:110
virtual void Validate(const Value &json, const std::string &path)=0
Validate that JSON value meets requirements.
virtual void ClearErrors()
Clear list of error messages.
Definition: Requirement.h:95
virtual bool HasNotices()
Check if notices have been queued.
Definition: Requirement.h:101
void PushError(const std::string &error)
Add error to list of error messages.
Definition: Requirement.h:53
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
virtual void Parse(Value json, const std::string &path)=0
Parse JSON value.
std::vector< std::unique_ptr< Requirement > > RequireList
List of Requirements.
Definition: Requirement.h:117