Logic/Concepts.h: Add combinational logic expr classes
This commit is contained in:
@@ -1,11 +1,50 @@
|
|||||||
#ifndef _CONCEPT_H
|
#ifndef _CONCEPT_H
|
||||||
#define _CONCEPT_H
|
#define _CONCEPT_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
#include <logic.h>
|
||||||
#include <mentalEntity.h>
|
#include <mentalEntity.h>
|
||||||
|
|
||||||
class Concept
|
namespace smo {
|
||||||
: public MentalEntity
|
namespace concepts {
|
||||||
|
|
||||||
|
class Comparator
|
||||||
|
: public MentalEntity, public logic::Operand
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
/** EXPLANATION:
|
||||||
|
* The reference for a Comparator is the fixed mentity or range of mentities
|
||||||
|
* that this comparator is intended to validate a match against.
|
||||||
|
*
|
||||||
|
* There are several mentities against which a comparator can match. At the
|
||||||
|
* time of writing, we're fairly sure that these will be at minimum,
|
||||||
|
* qualia, chronomena and mentena.
|
||||||
|
*/
|
||||||
|
std::shared_ptr<MentalEntity> reference;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ComparatorExpression
|
||||||
|
: public logic::UnaryExpression
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ComparatorExpression(
|
||||||
|
logic::Operator &op, std::shared_ptr<Comparator> &comparator
|
||||||
|
)
|
||||||
|
: logic::UnaryExpression(op, comparator)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CombinatorialLogicExpression
|
||||||
|
: public MentalEntity, public logic::Expression
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef CombinatorialLogicExpression Concept;
|
||||||
|
|
||||||
|
} // namespace concept
|
||||||
|
} // namespace smo
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
#ifndef _LOGIC_H
|
||||||
|
#define _LOGIC_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace smo {
|
||||||
|
namespace logic {
|
||||||
|
|
||||||
|
class ExpressionPart
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class Operator
|
||||||
|
: public ExpressionPart
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class OperatorAnd
|
||||||
|
: public Operator
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class OperatorOr
|
||||||
|
: public Operator
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class OperatorNot
|
||||||
|
: public Operator
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class Operand
|
||||||
|
: public ExpressionPart
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class UnaryExpression
|
||||||
|
: public ExpressionPart
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UnaryExpression(Operator &op, std::shared_ptr<Operand> &operand)
|
||||||
|
: parts(std::make_pair(op, operand))
|
||||||
|
{}
|
||||||
|
public:
|
||||||
|
std::pair<Operator, std::shared_ptr<Operand>> parts;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Expressions can be chained as parts of a larger expression
|
||||||
|
class Expression
|
||||||
|
: public ExpressionPart
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// This will eventually take in some data to be evaluated for a match.
|
||||||
|
virtual bool evaluate(void) = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::vector<std::shared_ptr<ExpressionPart>> parts;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace logic
|
||||||
|
} // namespace smo
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user