#pragma once #include #include #include #include #include #include #include "Noise.h" #include "TypeRegistry.h" class Chunk; class JExpressionMemory; class JExpressionMemory : public virtual Framework::ReferenceCounter { private: Framework::RCTrie noises; Framework::Trie floatVariables; Framework::Trie boolVariables; Chunk* currentChunk; Framework::Critical cs; public: JExpressionMemory(); ~JExpressionMemory(); void lock(); void unlock(); float getNoise(Framework::Text name, float x, float y, float z) const; void setNoise(Framework::Text name, Noise* noise); void setCurrentChunk(Chunk* chunk); float getFloatVariable(Framework::Text name) const; void setFloatVariable(Framework::Text name, float value); bool getBoolVariable(Framework::Text name) const; void setBoolVariable(Framework::Text name, bool value); Chunk* zCurrentChunk(); }; class JFloatExpression : public virtual Framework::ReferenceCounter { private: public: JFloatExpression(); virtual float getValue(JExpressionMemory* zMemory) = 0; }; class JBoolExpression : public virtual Framework::ReferenceCounter { private: public: JBoolExpression(); virtual bool getValue(JExpressionMemory* zMemory) = 0; }; class JVariableFloatExpression : public JFloatExpression { private: Framework::Text name; public: JVariableFloatExpression(); float getValue(JExpressionMemory* zMemory) override; void setName(Framework::Text name); Framework::Text getName() const; }; class JVariableFloatExpressionFactory : public SubTypeFactory { public: JVariableFloatExpressionFactory(); JVariableFloatExpression* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( JVariableFloatExpression* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; }; class JVariableBoolExpression : public JBoolExpression { private: Framework::Text name; public: JVariableBoolExpression(); bool getValue(JExpressionMemory* zMemory) override; void setName(Framework::Text name); Framework::Text getName() const; }; class JVariableBoolExpressionFactory : public SubTypeFactory { public: JVariableBoolExpressionFactory(); JVariableBoolExpression* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( JVariableBoolExpression* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; }; class JConstantFloatExpression : public JFloatExpression { private: float value; public: JConstantFloatExpression(); float getValue(JExpressionMemory* zMemory) override; void setValue(float value); float getValue() const; }; class JConstantFloatExpressionFactory : public SubTypeFactory { public: JConstantFloatExpressionFactory(); JConstantFloatExpression* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( JConstantFloatExpression* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; }; class JConstantBoolExpression : public JBoolExpression { private: bool value; public: JConstantBoolExpression(); bool getValue(JExpressionMemory* zMemory) override; void setValue(bool value); bool getValue() const; }; class JConstantBoolExpressionFactory : public SubTypeFactory { public: JConstantBoolExpressionFactory(); JConstantBoolExpression* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( JConstantBoolExpression* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; }; class JNoiseFloatExpression : public JFloatExpression { private: Framework::Text name; JFloatExpression* x; JFloatExpression* y; JFloatExpression* z; public: JNoiseFloatExpression(); ~JNoiseFloatExpression(); float getValue(JExpressionMemory* zMemory) override; void setName(Framework::Text name); Framework::Text getName() const; void setX(JFloatExpression* x); JFloatExpression* zX() const; void setY(JFloatExpression* y); JFloatExpression* zY() const; void setZ(JFloatExpression* z); JFloatExpression* zZ() const; }; class JNoiseFloatExpressionFactory : public SubTypeFactory { public: JNoiseFloatExpressionFactory(); JNoiseFloatExpression* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( JNoiseFloatExpression* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; }; class JOperatorFloatExpression : public JFloatExpression { private: Framework::Text op; std::function accumulator; Framework::RCArray values; public: JOperatorFloatExpression(); float getValue(JExpressionMemory* zMemory) override; void setOperator( Framework::Text op, std::function accumulator); Framework::Text getOperator(); void addValue(JFloatExpression* value); const Framework::RCArray& getValues() const; }; class JOperatorFloatExpressionFactory : public SubTypeFactory { public: JOperatorFloatExpressionFactory(); JOperatorFloatExpression* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( JOperatorFloatExpression* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; }; class JBoolOperatorBoolExpression : public JBoolExpression { private: Framework::Text op; std::function accumulator; Framework::RCArray values; public: JBoolOperatorBoolExpression(); bool getValue(JExpressionMemory* zMemory) override; void setOperator( Framework::Text op, std::function accumulator); Framework::Text getOperator(); void addValue(JBoolExpression* value); const Framework::RCArray& getValues() const; }; class JBoolOperatorBoolExpressionFactory : public SubTypeFactory { public: JBoolOperatorBoolExpressionFactory(); JBoolOperatorBoolExpression* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( JBoolOperatorBoolExpression* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; }; class JFloatOperatorBoolExpression : public JBoolExpression { private: Framework::Text op; std::function accumulator; Framework::RCArray values; public: JFloatOperatorBoolExpression(); bool getValue(JExpressionMemory* zMemory) override; void setOperator( Framework::Text op, std::function accumulator); Framework::Text getOperator(); void addValue(JFloatExpression* value); const Framework::RCArray& getValues() const; }; class JFloatOperatorBoolExpressionFactory : public SubTypeFactory { public: JFloatOperatorBoolExpressionFactory(); JFloatOperatorBoolExpression* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( JFloatOperatorBoolExpression* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; }; class JBlockTypeBoolExpression : public JBoolExpression { private: int typeId; JFloatExpression* x; JFloatExpression* y; JFloatExpression* z; public: JBlockTypeBoolExpression(); ~JBlockTypeBoolExpression(); bool getValue(JExpressionMemory* zMemory) override; void setTypeId(int typeId); int getTypeId() const; void setX(JFloatExpression* x); JFloatExpression* zX() const; void setY(JFloatExpression* y); JFloatExpression* zY() const; void setZ(JFloatExpression* z); JFloatExpression* zZ() const; }; class JBlockTypeBoolExpressionFactory : public SubTypeFactory { public: JBlockTypeBoolExpressionFactory(); JBlockTypeBoolExpression* fromJson( Framework::JSON::JSONObject* zJson) const override; Framework::JSON::JSONObject* toJsonObject( JBlockTypeBoolExpression* zObject) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; const char* getTypeToken() const override; };