SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
Public Member Functions | Private Attributes | List of all members
Json::DependencyRequirement Class Reference

Requires dependencies to be met. More...

#include <DependencyRequirement.h>

Inheritance diagram for Json::DependencyRequirement:
Inheritance graph
[legend]

Public Member Functions

 DependencyRequirement ()
 Constructor.
 
virtual void Reset () override
 Reset Requirement. More...
 
virtual void Parse (Value json, const std::string &) override
 Parse JSON input value. More...
 
virtual void Validate (const Value &json, const std::string &path) override
 Validate that Requirement is met. More...
 
 ~DependencyRequirement ()
 Destructor.
 
- Public Member Functions inherited from Json::Requirement
bool HasErrors ()
 Check if errors have occured. More...
 
std::vector< std::string > GetErrors ()
 Get list of error messages. More...
 
virtual void ClearErrors ()
 Clear list of error messages.
 
virtual bool HasNotices ()
 Check if notices have been queued. More...
 
std::vector< std::string > GetNotices ()
 Get list of notices. More...
 
virtual void ClearNotices ()
 Clear list of notice messages.
 
virtual ~Requirement ()
 Destructor.
 

Private Attributes

std::map< std::string, std::vector< std::string > > deps_
 Set of dependencies.
 

Additional Inherited Members

- Protected Member Functions inherited from Json::Requirement
void PushError (const std::string &error)
 Add error to list of error messages. More...
 
void PushNotice (const std::string &notice)
 Add message to list of notices. More...
 

Detailed Description

Requires dependencies to be met.

Definition at line 36 of file DependencyRequirement.h.

Member Function Documentation

◆ Parse()

virtual void Json::DependencyRequirement::Parse ( Value  json,
const std::string &   
)
inlineoverridevirtual

Parse JSON input value.

Parameters
jsonJSON input value.

Implements Json::Requirement.

Definition at line 61 of file DependencyRequirement.h.

62  {
63  Reset();
64 
65  auto names = json.getMemberNames();
66  int i = 0;
67  for(auto& value : json)
68  {
69  if(value.isArray())
70  {
71  deps_[names[i]] = {};
72  for(auto& dep : value)
73  {
74  deps_[names[i]].push_back(dep.asString());
75  }
76  }
77  ++i;
78  }
79  }
virtual void Reset() override
Reset Requirement.
std::map< std::string, std::vector< std::string > > deps_
Set of dependencies.

References deps_, and Reset().

Here is the call graph for this function:

◆ Reset()

virtual void Json::DependencyRequirement::Reset ( )
inlineoverridevirtual

Reset Requirement.

Clear set of dependencies.

Implements Json::Requirement.

Definition at line 50 of file DependencyRequirement.h.

51  {
52  deps_.clear();
53  ClearErrors();
54  ClearNotices();
55  }
virtual void ClearNotices()
Clear list of notice messages.
Definition: Requirement.h:110
virtual void ClearErrors()
Clear list of error messages.
Definition: Requirement.h:95

References Json::Requirement::ClearErrors(), Json::Requirement::ClearNotices(), and deps_.

Referenced by Parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Validate()

virtual void Json::DependencyRequirement::Validate ( const Value &  json,
const std::string &  path 
)
inlineoverridevirtual

Validate that Requirement is met.

Parameters
jsonJSON value to be validated.
pathPath for JSON path specification.

Implements Json::Requirement.

Definition at line 86 of file DependencyRequirement.h.

87  {
88  if(!json.isObject())
89  {
90  PushError(path + ": Dependency specified for non-object");
91  return;
92  }
93 
94  for(auto& dep : deps_)
95  {
96  auto& name = dep.first;
97  if(json.isMember(name))
98  for(const auto& val : dep.second)
99  if(!json.isMember(val))
100  PushError(path + ": \"" + name + "\" depends on \"" + val + "\"");
101  }
102  }
void PushError(const std::string &error)
Add error to list of error messages.
Definition: Requirement.h:53

References deps_, and Json::Requirement::PushError().

Here is the call graph for this function:

The documentation for this class was generated from the following file: