diff --git a/include/user/cologex.h b/include/user/cologex.h index b294a7e..b11114d 100644 --- a/include/user/cologex.h +++ b/include/user/cologex.h @@ -5,39 +5,12 @@ #include #include #include -#include +#include #include namespace smo { namespace cologex { -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 reference; -}; - -class ComparatorExpression -: public logic::UnaryExpression -{ -public: - ComparatorExpression( - logic::Operator &op, std::shared_ptr &comparator - ) - : logic::UnaryExpression( - op, std::static_pointer_cast(comparator)) - {} -}; - class CombinatorialLogicExpression : public MentalEntity, public logic::Expression, public Concept { diff --git a/include/user/comparator.h b/include/user/comparator.h new file mode 100644 index 0000000..84222ff --- /dev/null +++ b/include/user/comparator.h @@ -0,0 +1,82 @@ +#ifndef _USER_COMPARATOR_H +#define _USER_COMPARATOR_H + +#include +#include +#include +#include + +namespace smo { +namespace cologex { + +constexpr uint32_t SMO_COMPARATOR_VENDOR_ID = 0x511110FFu; +constexpr uint32_t SMO_COMPARATOR_TYPE_BODY_SPOT = 0x51100001u; +constexpr uint32_t SMO_COMPARATOR_TYPE_STIM_FEAT = 0x51100002u; +constexpr uint32_t SMO_COMPARATOR_TYPE_SIMULTANEITY_STAMP = 0x51100003u; + +/** Disk-stable comparator type identity: vendorId + typeId (64 bits packed). */ +struct ComparatorTypeId +{ + uint32_t vendorId; + uint32_t typeId; + + constexpr uint64_t pack() const + { + return (static_cast(vendorId) << 32) + | static_cast(typeId); + } + + static constexpr ComparatorTypeId unpack(uint64_t packed) + { + return ComparatorTypeId{ + static_cast(packed >> 32), + static_cast(packed) + }; + } + + constexpr bool operator==(const ComparatorTypeId& other) const + { + return vendorId == other.vendorId && typeId == other.typeId; + } + + constexpr bool operator!=(const ComparatorTypeId& other) const + { + return !(*this == other); + } +}; + +class Comparator +: public MentalEntity, public logic::Operand +{ +public: + explicit Comparator(MentalEntity::Id id) + : MentalEntity(id) + {} + + virtual ~Comparator() = default; + + virtual ComparatorTypeId getTypeId() const = 0; + + /** EXPLANATION: + * The reference for a Comparator is the fixed mentity or range of mentities + * that this comparator is intended to validate a match against. + */ + std::shared_ptr reference; +}; + +class ComparatorExpression +: public logic::UnaryExpression +{ +public: + ComparatorExpression( + logic::Operator &op, std::shared_ptr &comparator + ) + : logic::UnaryExpression( + op, std::static_pointer_cast(comparator)) + {} +}; + +} // namespace cologex +} // namespace smo + +#endif // _USER_COMPARATOR_H