Outsourced SAS value parsing.
This commit is contained in:
44
include/plasp/sas/AssignedVariable.h
Normal file
44
include/plasp/sas/AssignedVariable.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef __SAS__ASSIGNED_VARIABLE_H
|
||||
#define __SAS__ASSIGNED_VARIABLE_H
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
#include <plasp/sas/Value.h>
|
||||
#include <plasp/sas/Variable.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace sas
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AssignedVariable
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AssignedVariable
|
||||
{
|
||||
public:
|
||||
static AssignedVariable fromSAS(std::istream &istream, const std::vector<Variable> &variables);
|
||||
static AssignedVariable fromSAS(std::istream &istream, const Variable &variable);
|
||||
|
||||
public:
|
||||
AssignedVariable(const Variable &variable, const Value &value);
|
||||
|
||||
const Variable &variable() const;
|
||||
const Value &value() const;
|
||||
|
||||
private:
|
||||
AssignedVariable();
|
||||
|
||||
const Variable *m_variable;
|
||||
const Value *m_value;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -42,11 +42,6 @@ class Description
|
||||
private:
|
||||
Description();
|
||||
|
||||
const Variable &parseVariable(std::istream &istream) const;
|
||||
const Value &parseValue(std::istream &istream, const Variable &variable) const;
|
||||
AssignedVariable parseAssignedVariable(std::istream &istream) const;
|
||||
VariableTransition parseVariableTransition(std::istream &istream) const;
|
||||
|
||||
void parseVersionSection(std::istream &istream) const;
|
||||
void parseMetricSection(std::istream &istream);
|
||||
void parseVariablesSection(std::istream &istream);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef __SAS__MUTEX_GROUP_H
|
||||
#define __SAS__MUTEX_GROUP_H
|
||||
|
||||
#include <plasp/sas/Variable.h>
|
||||
#include <plasp/sas/AssignedVariable.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
@@ -14,13 +14,21 @@ namespace sas
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO: make consistent with initial state/goal
|
||||
struct MutexGroup
|
||||
class MutexGroup
|
||||
{
|
||||
using Fact = AssignedVariable;
|
||||
using Facts = std::vector<Fact>;
|
||||
public:
|
||||
using Fact = AssignedVariable;
|
||||
using Facts = std::vector<Fact>;
|
||||
|
||||
Facts facts;
|
||||
static MutexGroup fromSAS(std::istream &istream, const std::vector<Variable> &variables);
|
||||
|
||||
public:
|
||||
const Facts &facts() const;
|
||||
|
||||
private:
|
||||
MutexGroup() = default;
|
||||
|
||||
Facts m_facts;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -10,6 +10,9 @@ namespace plasp
|
||||
namespace sas
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
class Variable;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Value
|
||||
@@ -28,6 +31,7 @@ struct Value
|
||||
static const Value Any;
|
||||
|
||||
static Value fromSAS(std::istream &istream);
|
||||
static const Value &referenceFromSAS(std::istream &istream, const Variable &variable);
|
||||
|
||||
public:
|
||||
void printAsSAS(std::ostream &ostream) const;
|
||||
|
@@ -22,6 +22,7 @@ class Variable
|
||||
{
|
||||
public:
|
||||
static Variable fromSAS(std::istream &istream);
|
||||
static const Variable &referenceFromSAS(std::istream &istream, const std::vector<Variable> &variables);
|
||||
|
||||
public:
|
||||
const std::string &name() const;
|
||||
@@ -38,23 +39,6 @@ class Variable
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct AssignedVariable
|
||||
{
|
||||
const Variable &variable;
|
||||
const Value &value;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct VariableTransition
|
||||
{
|
||||
const Variable &variable;
|
||||
const Value &valueBefore;
|
||||
const Value &valueAfter;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
43
include/plasp/sas/VariableTransition.h
Normal file
43
include/plasp/sas/VariableTransition.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef __SAS__VARIABLE_TRANSITION_H
|
||||
#define __SAS__VARIABLE_TRANSITION_H
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
#include <plasp/sas/Value.h>
|
||||
#include <plasp/sas/Variable.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace sas
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VariableTransition
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariableTransition
|
||||
{
|
||||
public:
|
||||
static VariableTransition fromSAS(std::istream &istream, const std::vector<Variable> &variables);
|
||||
|
||||
public:
|
||||
const Variable &variable() const;
|
||||
const Value &valueBefore() const;
|
||||
const Value &valueAfter() const;
|
||||
|
||||
private:
|
||||
VariableTransition();
|
||||
|
||||
const Variable *m_variable;
|
||||
const Value *m_valueBefore;
|
||||
const Value *m_valueAfter;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user