Browse Source

Refactor data bindings: Move model handle to 'DataModelHandle.h'. Move DataModel, DataView, and DataController to private headers.

Michael Ragazzon 5 years ago
parent
commit
57e40eb0f3

+ 5 - 3
CMake/FileList.cmake

@@ -4,8 +4,11 @@ set(Core_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/Clock.h
     ${PROJECT_SOURCE_DIR}/Source/Core/Clock.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ComputeProperty.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ComputeProperty.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ContextInstancerDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ContextInstancerDefault.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/DataController.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DataControllerDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DataControllerDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DataExpression.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DataExpression.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/DataModel.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/DataView.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DataViewDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DataViewDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DecoratorGradient.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DecoratorGradient.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DecoratorNinePatch.h
     ${PROJECT_SOURCE_DIR}/Source/Core/DecoratorNinePatch.h
@@ -129,12 +132,10 @@ set(Core_PUB_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ContextInstancer.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ContextInstancer.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ConvolutionFilter.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ConvolutionFilter.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Core.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Core.h
-    ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataController.h
-    ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataModel.h
+    ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataModelHandle.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataTypeRegister.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataTypeRegister.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataTypes.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataTypes.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataVariable.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataVariable.h
-    ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataView.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Debug.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Debug.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Decorator.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Decorator.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DecoratorInstancer.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DecoratorInstancer.h
@@ -239,6 +240,7 @@ set(Core_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/DataControllerDefault.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataControllerDefault.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataExpression.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataExpression.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataModel.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataModel.cpp
+    ${PROJECT_SOURCE_DIR}/Source/Core/DataModelHandle.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataTypeRegister.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataTypeRegister.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataVariable.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataVariable.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataView.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/DataView.cpp

+ 1 - 3
Include/RmlUi/Core.h

@@ -40,12 +40,10 @@
 #include "Core/Context.h"
 #include "Core/Context.h"
 #include "Core/ContextInstancer.h"
 #include "Core/ContextInstancer.h"
 #include "Core/ConvolutionFilter.h"
 #include "Core/ConvolutionFilter.h"
-#include "Core/DataController.h"
-#include "Core/DataModel.h"
+#include "Core/DataModelHandle.h"
 #include "Core/DataTypeRegister.h"
 #include "Core/DataTypeRegister.h"
 #include "Core/DataTypes.h"
 #include "Core/DataTypes.h"
 #include "Core/DataVariable.h"
 #include "Core/DataVariable.h"
-#include "Core/DataView.h"
 #include "Core/Decorator.h"
 #include "Core/Decorator.h"
 #include "Core/DecoratorInstancer.h"
 #include "Core/DecoratorInstancer.h"
 #include "Core/Element.h"
 #include "Core/Element.h"

+ 18 - 83
Include/RmlUi/Core/DataModel.h → Include/RmlUi/Core/DataModelHandle.h

@@ -26,8 +26,8 @@
  *
  *
  */
  */
 
 
-#ifndef RMLUI_CORE_DATAMODEL_H
-#define RMLUI_CORE_DATAMODEL_H
+#ifndef RMLUI_CORE_DATAMODELHANDLE_H
+#define RMLUI_CORE_DATAMODELHANDLE_H
 
 
 #include "Header.h"
 #include "Header.h"
 #include "Types.h"
 #include "Types.h"
@@ -37,77 +37,15 @@
 
 
 namespace Rml {
 namespace Rml {
 
 
-class DataViews;
-class DataControllers;
-class Element;
-
-
-class RMLUICORE_API DataModel : NonCopyMoveable {
-public:
-	DataModel(const TransformFuncRegister* transform_register = nullptr);
-	~DataModel();
-
-	void AddView(DataViewPtr view);
-	void AddController(DataControllerPtr controller);
-
-	bool BindVariable(const String& name, DataVariable variable);
-	bool BindFunc(const String& name, DataGetFunc get_func, DataSetFunc set_func);
-
-	bool BindEventCallback(const String& name, DataEventFunc event_func);
-
-	bool InsertAlias(Element* element, const String& alias_name, DataAddress replace_with_address);
-	bool EraseAliases(Element* element);
-
-	DataAddress ResolveAddress(const String& address_str, Element* element) const;
-	const DataEventFunc* GetEventCallback(const String& name);
-
-	DataVariable GetVariable(const DataAddress& address) const;
-	bool GetVariableInto(const DataAddress& address, Variant& out_value) const;
-
-	void DirtyVariable(const String& variable_name);
-	bool IsVariableDirty(const String& variable_name) const;
-
-	bool CallTransform(const String& name, Variant& inout_result, const VariantList& arguments) const;
-
-	// Elements declaring 'data-model' need to be attached.
-	void AttachModelRootElement(Element* element);
-	ElementList GetAttachedModelRootElements() const;
-
-	void OnElementRemove(Element* element);
-
-	bool Update(bool clear_dirty_variables);
-
-private:
-	UniquePtr<DataViews> views;
-	UniquePtr<DataControllers> controllers;
-
-	UnorderedMap<String, DataVariable> variables;
-	DirtyVariables dirty_variables;
-
-	UnorderedMap<String, UniquePtr<FuncDefinition>> function_variable_definitions;
-	UnorderedMap<String, DataEventFunc> event_callbacks;
-
-	using ScopedAliases = UnorderedMap<Element*, SmallUnorderedMap<String, DataAddress>>;
-	ScopedAliases aliases;
-
-	const TransformFuncRegister* transform_register;
-
-	SmallUnorderedSet<Element*> attached_elements;
-};
-
+class DataModel;
 
 
 
 
 class RMLUICORE_API DataModelHandle {
 class RMLUICORE_API DataModelHandle {
 public:
 public:
-	DataModelHandle(DataModel* model = nullptr) : model(model)
-	{}
+	DataModelHandle(DataModel* model = nullptr);
 
 
-	bool IsVariableDirty(const String& variable_name) {
-		return model->IsVariableDirty(variable_name);
-	}
-	void DirtyVariable(const String& variable_name) {
-		model->DirtyVariable(variable_name);
-	}
+	bool IsVariableDirty(const String& variable_name);
+	void DirtyVariable(const String& variable_name);
 
 
 	explicit operator bool() { return model; }
 	explicit operator bool() { return model; }
 
 
@@ -121,32 +59,26 @@ public:
 	template<typename T>
 	template<typename T>
 	using DataEventMemberFunc = void(T::*)(DataModelHandle, Event&, const VariantList&);
 	using DataEventMemberFunc = void(T::*)(DataModelHandle, Event&, const VariantList&);
 
 
-	DataModelConstructor() : model(nullptr), type_register(nullptr) {}
-	DataModelConstructor(DataModel* model, DataTypeRegister* type_register) : model(model), type_register(type_register) {
-		RMLUI_ASSERT(model && type_register);
-	}
+	DataModelConstructor();
+	DataModelConstructor(DataModel* model, DataTypeRegister* type_register);
 
 
 	// Return a handle to the data model being constructed, which can later be used to synchronize variables and update the model.
 	// Return a handle to the data model being constructed, which can later be used to synchronize variables and update the model.
-	DataModelHandle GetModelHandle() const {
-		return DataModelHandle(model);
-	}
+	DataModelHandle GetModelHandle() const;
 
 
 	// Bind a data variable.
 	// Bind a data variable.
 	// @note For non-scalar types make sure they first have been registered with the appropriate 'Register...()' functions.
 	// @note For non-scalar types make sure they first have been registered with the appropriate 'Register...()' functions.
-	template<typename T> bool Bind(const String& name, T* ptr) {
+	template<typename T>
+	bool Bind(const String& name, T* ptr) {
 		RMLUI_ASSERTMSG(ptr, "Invalid pointer to data variable");
 		RMLUI_ASSERTMSG(ptr, "Invalid pointer to data variable");
-		return model->BindVariable(name, DataVariable(type_register->GetOrAddScalar<T>(), ptr));
+		return BindVariable(name, DataVariable(type_register->GetOrAddScalar<T>(), ptr));
 	}
 	}
 
 
 	// Bind a get/set function pair.
 	// Bind a get/set function pair.
-	bool BindFunc(const String& name, DataGetFunc get_func, DataSetFunc set_func = {}) {
-		return model->BindFunc(name, std::move(get_func), std::move(set_func));
-	}
+	bool BindFunc(const String& name, DataGetFunc get_func, DataSetFunc set_func = {});
 
 
 	// Bind an event callback.
 	// Bind an event callback.
-	bool BindEventCallback(const String& name, DataEventFunc event_func) {
-		return model->BindEventCallback(name, std::move(event_func));
-	}
+	bool BindEventCallback(const String& name, DataEventFunc event_func);
+
 	// Convenience wrapper around BindEventCallback for member functions.
 	// Convenience wrapper around BindEventCallback for member functions.
 	template<typename T>
 	template<typename T>
 	bool BindEventCallback(const String& name, DataEventMemberFunc<T> member_func, T* object_pointer) {
 	bool BindEventCallback(const String& name, DataEventMemberFunc<T> member_func, T* object_pointer) {
@@ -182,9 +114,12 @@ public:
 	explicit operator bool() { return model && type_register; }
 	explicit operator bool() { return model && type_register; }
 
 
 private:
 private:
+	bool BindVariable(const String& name, DataVariable data_variable);
+
 	DataModel* model;
 	DataModel* model;
 	DataTypeRegister* type_register;
 	DataTypeRegister* type_register;
 };
 };
 
 
 } // namespace Rml
 } // namespace Rml
+
 #endif
 #endif

+ 1 - 1
Samples/invaders/src/HighScores.cpp

@@ -29,7 +29,7 @@
 #include "HighScores.h"
 #include "HighScores.h"
 #include <RmlUi/Core/TypeConverter.h>
 #include <RmlUi/Core/TypeConverter.h>
 #include <RmlUi/Core/Context.h>
 #include <RmlUi/Core/Context.h>
-#include <RmlUi/Core/DataModel.h>
+#include <RmlUi/Core/DataModelHandle.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <algorithm>
 #include <algorithm>
 
 

+ 1 - 1
Samples/invaders/src/HighScores.h

@@ -30,7 +30,7 @@
 #define RMLUI_INVADERS_HIGHSCORES_H
 #define RMLUI_INVADERS_HIGHSCORES_H
 
 
 #include <RmlUi/Core/Types.h>
 #include <RmlUi/Core/Types.h>
-#include <RmlUi/Core/DataModel.h>
+#include <RmlUi/Core/DataModelHandle.h>
 
 
 class HighScores
 class HighScores
 {
 {

+ 2 - 1
Source/Core/Context.cpp

@@ -29,6 +29,7 @@
 #include "../../Include/RmlUi/Core/Context.h"
 #include "../../Include/RmlUi/Core/Context.h"
 #include "../../Include/RmlUi/Core/ContextInstancer.h"
 #include "../../Include/RmlUi/Core/ContextInstancer.h"
 #include "../../Include/RmlUi/Core/Core.h"
 #include "../../Include/RmlUi/Core/Core.h"
+#include "../../Include/RmlUi/Core/DataModelHandle.h"
 #include "../../Include/RmlUi/Core/ElementDocument.h"
 #include "../../Include/RmlUi/Core/ElementDocument.h"
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include "../../Include/RmlUi/Core/Factory.h"
 #include "../../Include/RmlUi/Core/Factory.h"
@@ -36,8 +37,8 @@
 #include "../../Include/RmlUi/Core/RenderInterface.h"
 #include "../../Include/RmlUi/Core/RenderInterface.h"
 #include "../../Include/RmlUi/Core/StreamMemory.h"
 #include "../../Include/RmlUi/Core/StreamMemory.h"
 #include "../../Include/RmlUi/Core/SystemInterface.h"
 #include "../../Include/RmlUi/Core/SystemInterface.h"
-#include "../../Include/RmlUi/Core/DataModel.h"
 #include "../../Include/RmlUi/Core/StreamMemory.h"
 #include "../../Include/RmlUi/Core/StreamMemory.h"
+#include "DataModel.h"
 #include "EventDispatcher.h"
 #include "EventDispatcher.h"
 #include "PluginRegistry.h"
 #include "PluginRegistry.h"
 #include "StreamFile.h"
 #include "StreamFile.h"

+ 1 - 2
Source/Core/DataController.cpp

@@ -26,8 +26,7 @@
  *
  *
  */
  */
 
 
-#include "../../Include/RmlUi/Core/DataController.h"
-#include "../../Include/RmlUi/Core/DataModel.h"
+#include "DataController.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "EventSpecification.h"
 #include "EventSpecification.h"
 
 

+ 6 - 6
Include/RmlUi/Core/DataController.h → Source/Core/DataController.h

@@ -29,9 +29,9 @@
 #ifndef RMLUI_CORE_DATACONTROLLER_H
 #ifndef RMLUI_CORE_DATACONTROLLER_H
 #define RMLUI_CORE_DATACONTROLLER_H
 #define RMLUI_CORE_DATACONTROLLER_H
 
 
-#include "Header.h"
-#include "Types.h"
-#include "Traits.h"
+#include "../../Include/RmlUi/Core/Header.h"
+#include "../../Include/RmlUi/Core/Types.h"
+#include "../../Include/RmlUi/Core/Traits.h"
 
 
 namespace Rml {
 namespace Rml {
 
 
@@ -39,7 +39,7 @@ class Element;
 class DataModel;
 class DataModel;
 
 
 
 
-class RMLUICORE_API DataControllerInstancer : public NonCopyMoveable {
+class DataControllerInstancer : public NonCopyMoveable {
 public:
 public:
     DataControllerInstancer() {}
     DataControllerInstancer() {}
     virtual ~DataControllerInstancer() {}
     virtual ~DataControllerInstancer() {}
@@ -74,7 +74,7 @@ public:
 
 
  */
  */
 
 
-class RMLUICORE_API DataController : public Releasable {
+class DataController : public Releasable {
 public:
 public:
 	virtual ~DataController();
 	virtual ~DataController();
 
 
@@ -100,7 +100,7 @@ private:
 };
 };
 
 
 
 
-class RMLUICORE_API DataControllers : NonCopyMoveable {
+class DataControllers : NonCopyMoveable {
 public:
 public:
     DataControllers();
     DataControllers();
     ~DataControllers();
     ~DataControllers();

+ 2 - 2
Source/Core/DataControllerDefault.cpp

@@ -27,10 +27,10 @@
  */
  */
 
 
 #include "DataControllerDefault.h"
 #include "DataControllerDefault.h"
-#include "../../Include/RmlUi/Core/DataController.h"
-#include "../../Include/RmlUi/Core/DataModel.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/Element.h"
+#include "DataController.h"
 #include "DataExpression.h"
 #include "DataExpression.h"
+#include "DataModel.h"
 #include "EventSpecification.h"
 #include "EventSpecification.h"
 
 
 namespace Rml {
 namespace Rml {

+ 1 - 1
Source/Core/DataControllerDefault.h

@@ -33,7 +33,7 @@
 #include "../../Include/RmlUi/Core/Types.h"
 #include "../../Include/RmlUi/Core/Types.h"
 #include "../../Include/RmlUi/Core/EventListener.h"
 #include "../../Include/RmlUi/Core/EventListener.h"
 #include "../../Include/RmlUi/Core/DataVariable.h"
 #include "../../Include/RmlUi/Core/DataVariable.h"
-#include "../../Include/RmlUi/Core/DataController.h"
+#include "DataController.h"
 
 
 namespace Rml {
 namespace Rml {
 
 

+ 2 - 1
Source/Core/DataExpression.cpp

@@ -27,9 +27,10 @@
  */
  */
 
 
 #include "DataExpression.h"
 #include "DataExpression.h"
-#include "../../Include/RmlUi/Core/DataModel.h"
+#include "../../Include/RmlUi/Core/DataModelHandle.h"
 #include "../../Include/RmlUi/Core/Event.h"
 #include "../../Include/RmlUi/Core/Event.h"
 #include "../../Include/RmlUi/Core/Variant.h"
 #include "../../Include/RmlUi/Core/Variant.h"
+#include "DataModel.h"
 #include <stack>
 #include <stack>
 
 
 #ifdef _MSC_VER
 #ifdef _MSC_VER

+ 4 - 3
Source/Core/DataModel.cpp

@@ -26,10 +26,11 @@
  *
  *
  */
  */
 
 
-#include "../../Include/RmlUi/Core/DataModel.h"
-#include "../../Include/RmlUi/Core/DataController.h"
-#include "../../Include/RmlUi/Core/DataView.h"
+#include "DataModel.h"
+#include "../../Include/RmlUi/Core/DataTypeRegister.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/Element.h"
+#include "DataController.h"
+#include "DataView.h"
 
 
 namespace Rml {
 namespace Rml {
 
 

+ 100 - 0
Source/Core/DataModel.h

@@ -0,0 +1,100 @@
+/*
+ * This source file is part of RmlUi, the HTML/CSS Interface Middleware
+ *
+ * For the latest information, see http://github.com/mikke89/RmlUi
+ *
+ * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
+ * Copyright (c) 2019 The RmlUi Team, and contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#ifndef RMLUI_CORE_DATAMODEL_H
+#define RMLUI_CORE_DATAMODEL_H
+
+#include "../../Include/RmlUi/Core/Header.h"
+#include "../../Include/RmlUi/Core/Types.h"
+#include "../../Include/RmlUi/Core/Traits.h"
+#include "../../Include/RmlUi/Core/DataTypes.h"
+#include "../../Include/RmlUi/Core/DataVariable.h"
+
+namespace Rml {
+
+class DataViews;
+class DataControllers;
+class Element;
+
+
+class DataModel : NonCopyMoveable {
+public:
+	DataModel(const TransformFuncRegister* transform_register = nullptr);
+	~DataModel();
+
+	void AddView(DataViewPtr view);
+	void AddController(DataControllerPtr controller);
+
+	bool BindVariable(const String& name, DataVariable variable);
+	bool BindFunc(const String& name, DataGetFunc get_func, DataSetFunc set_func);
+
+	bool BindEventCallback(const String& name, DataEventFunc event_func);
+
+	bool InsertAlias(Element* element, const String& alias_name, DataAddress replace_with_address);
+	bool EraseAliases(Element* element);
+
+	DataAddress ResolveAddress(const String& address_str, Element* element) const;
+	const DataEventFunc* GetEventCallback(const String& name);
+
+	DataVariable GetVariable(const DataAddress& address) const;
+	bool GetVariableInto(const DataAddress& address, Variant& out_value) const;
+
+	void DirtyVariable(const String& variable_name);
+	bool IsVariableDirty(const String& variable_name) const;
+
+	bool CallTransform(const String& name, Variant& inout_result, const VariantList& arguments) const;
+
+	// Elements declaring 'data-model' need to be attached.
+	void AttachModelRootElement(Element* element);
+	ElementList GetAttachedModelRootElements() const;
+
+	void OnElementRemove(Element* element);
+
+	bool Update(bool clear_dirty_variables);
+
+private:
+	UniquePtr<DataViews> views;
+	UniquePtr<DataControllers> controllers;
+
+	UnorderedMap<String, DataVariable> variables;
+	DirtyVariables dirty_variables;
+
+	UnorderedMap<String, UniquePtr<FuncDefinition>> function_variable_definitions;
+	UnorderedMap<String, DataEventFunc> event_callbacks;
+
+	using ScopedAliases = UnorderedMap<Element*, SmallUnorderedMap<String, DataAddress>>;
+	ScopedAliases aliases;
+
+	const TransformFuncRegister* transform_register;
+
+	SmallUnorderedSet<Element*> attached_elements;
+};
+
+
+} // namespace Rml
+#endif

+ 69 - 0
Source/Core/DataModelHandle.cpp

@@ -0,0 +1,69 @@
+/*
+ * This source file is part of RmlUi, the HTML/CSS Interface Middleware
+ *
+ * For the latest information, see http://github.com/mikke89/RmlUi
+ *
+ * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
+ * Copyright (c) 2019 The RmlUi Team, and contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include "../../Include/RmlUi/Core/DataModelHandle.h"
+#include "DataModel.h"
+
+namespace Rml {
+
+
+DataModelHandle::DataModelHandle(DataModel* model) : model(model)
+{}
+
+bool DataModelHandle::IsVariableDirty(const String& variable_name) {
+	return model->IsVariableDirty(variable_name);
+}
+
+void DataModelHandle::DirtyVariable(const String& variable_name) {
+	model->DirtyVariable(variable_name);
+}
+
+
+DataModelConstructor::DataModelConstructor() : model(nullptr), type_register(nullptr) {}
+
+DataModelConstructor::DataModelConstructor(DataModel* model, DataTypeRegister* type_register) : model(model), type_register(type_register) {
+	RMLUI_ASSERT(model && type_register);
+}
+
+DataModelHandle DataModelConstructor::GetModelHandle() const {
+	return DataModelHandle(model);
+}
+
+bool DataModelConstructor::BindFunc(const String& name, DataGetFunc get_func, DataSetFunc set_func) {
+	return model->BindFunc(name, std::move(get_func), std::move(set_func));
+}
+
+bool DataModelConstructor::BindEventCallback(const String& name, DataEventFunc event_func) {
+	return model->BindEventCallback(name, std::move(event_func));
+}
+
+bool DataModelConstructor::BindVariable(const String& name, DataVariable data_variable) {
+	return model->BindVariable(name, data_variable);
+}
+
+} // namespace Rml

+ 1 - 1
Source/Core/DataView.cpp

@@ -26,7 +26,7 @@
  *
  *
  */
  */
 
 
-#include "../../Include/RmlUi/Core/DataView.h"
+#include "DataView.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include <algorithm>
 #include <algorithm>
 
 

+ 7 - 7
Include/RmlUi/Core/DataView.h → Source/Core/DataView.h

@@ -29,10 +29,10 @@
 #ifndef RMLUI_CORE_DATAVIEW_H
 #ifndef RMLUI_CORE_DATAVIEW_H
 #define RMLUI_CORE_DATAVIEW_H
 #define RMLUI_CORE_DATAVIEW_H
 
 
-#include "Header.h"
-#include "Types.h"
-#include "Traits.h"
-#include "DataTypes.h"
+#include "../../Include/RmlUi/Core/Header.h"
+#include "../../Include/RmlUi/Core/Types.h"
+#include "../../Include/RmlUi/Core/Traits.h"
+#include "../../Include/RmlUi/Core/DataTypes.h"
 
 
 namespace Rml {
 namespace Rml {
 
 
@@ -40,7 +40,7 @@ class Element;
 class DataModel;
 class DataModel;
 
 
 
 
-class RMLUICORE_API DataViewInstancer : public NonCopyMoveable {
+class DataViewInstancer : public NonCopyMoveable {
 public:
 public:
 	DataViewInstancer() {}
 	DataViewInstancer() {}
 	virtual ~DataViewInstancer() {}
 	virtual ~DataViewInstancer() {}
@@ -66,7 +66,7 @@ public:
 	The modifier may or may not be required depending on the data view.
 	The modifier may or may not be required depending on the data view.
  */
  */
 
 
-class RMLUICORE_API DataView : public Releasable {
+class DataView : public Releasable {
 public:
 public:
 	virtual ~DataView();
 	virtual ~DataView();
 
 
@@ -104,7 +104,7 @@ private:
 
 
 
 
 
 
-class RMLUICORE_API DataViews : NonCopyMoveable {
+class DataViews : NonCopyMoveable {
 public:
 public:
 	DataViews();
 	DataViews();
 	~DataViews();
 	~DataViews();

+ 1 - 1
Source/Core/DataViewDefault.cpp

@@ -28,7 +28,7 @@
 
 
 #include "DataViewDefault.h"
 #include "DataViewDefault.h"
 #include "DataExpression.h"
 #include "DataExpression.h"
-#include "../../Include/RmlUi/Core/DataModel.h"
+#include "DataModel.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
 #include "../../Include/RmlUi/Core/ElementText.h"
 #include "../../Include/RmlUi/Core/Factory.h"
 #include "../../Include/RmlUi/Core/Factory.h"

+ 1 - 1
Source/Core/DataViewDefault.h

@@ -31,8 +31,8 @@
 
 
 #include "../../Include/RmlUi/Core/Header.h"
 #include "../../Include/RmlUi/Core/Header.h"
 #include "../../Include/RmlUi/Core/Types.h"
 #include "../../Include/RmlUi/Core/Types.h"
-#include "../../Include/RmlUi/Core/DataView.h"
 #include "../../Include/RmlUi/Core/Variant.h"
 #include "../../Include/RmlUi/Core/Variant.h"
+#include "DataView.h"
 
 
 namespace Rml {
 namespace Rml {
 
 

+ 1 - 1
Source/Core/Element.cpp

@@ -30,7 +30,6 @@
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/Context.h"
 #include "../../Include/RmlUi/Core/Context.h"
 #include "../../Include/RmlUi/Core/Core.h"
 #include "../../Include/RmlUi/Core/Core.h"
-#include "../../Include/RmlUi/Core/DataModel.h"
 #include "../../Include/RmlUi/Core/ElementDocument.h"
 #include "../../Include/RmlUi/Core/ElementDocument.h"
 #include "../../Include/RmlUi/Core/ElementInstancer.h"
 #include "../../Include/RmlUi/Core/ElementInstancer.h"
 #include "../../Include/RmlUi/Core/ElementScroll.h"
 #include "../../Include/RmlUi/Core/ElementScroll.h"
@@ -45,6 +44,7 @@
 #include "../../Include/RmlUi/Core/TransformPrimitive.h"
 #include "../../Include/RmlUi/Core/TransformPrimitive.h"
 #include "Clock.h"
 #include "Clock.h"
 #include "ComputeProperty.h"
 #include "ComputeProperty.h"
+#include "DataModel.h"
 #include "ElementAnimation.h"
 #include "ElementAnimation.h"
 #include "ElementBackgroundBorder.h"
 #include "ElementBackgroundBorder.h"
 #include "ElementDefinition.h"
 #include "ElementDefinition.h"

+ 3 - 3
Source/Core/ElementUtilities.cpp

@@ -29,14 +29,14 @@
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include "../../Include/RmlUi/Core/Context.h"
 #include "../../Include/RmlUi/Core/Context.h"
 #include "../../Include/RmlUi/Core/Core.h"
 #include "../../Include/RmlUi/Core/Core.h"
-#include "../../Include/RmlUi/Core/DataController.h"
-#include "../../Include/RmlUi/Core/DataModel.h"
-#include "../../Include/RmlUi/Core/DataView.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/Element.h"
 #include "../../Include/RmlUi/Core/ElementScroll.h"
 #include "../../Include/RmlUi/Core/ElementScroll.h"
 #include "../../Include/RmlUi/Core/Factory.h"
 #include "../../Include/RmlUi/Core/Factory.h"
 #include "../../Include/RmlUi/Core/FontEngineInterface.h"
 #include "../../Include/RmlUi/Core/FontEngineInterface.h"
 #include "../../Include/RmlUi/Core/RenderInterface.h"
 #include "../../Include/RmlUi/Core/RenderInterface.h"
+#include "DataController.h"
+#include "DataModel.h"
+#include "DataView.h"
 #include "ElementStyle.h"
 #include "ElementStyle.h"
 #include "LayoutDetails.h"
 #include "LayoutDetails.h"
 #include "LayoutEngine.h"
 #include "LayoutEngine.h"

+ 1 - 1
Tests/Source/Benchmarks/DataExpression.cpp

@@ -29,7 +29,7 @@
 
 
 #include "../../../Source/Core/DataExpression.cpp"
 #include "../../../Source/Core/DataExpression.cpp"
 
 
-#include <RmlUi/Core/DataModel.h>
+#include <RmlUi/Core/DataModelHandle.h>
 #include <doctest.h>
 #include <doctest.h>
 #include <nanobench.h>
 #include <nanobench.h>
 
 

+ 1 - 1
Tests/Source/UnitTests/DataExpression.cpp

@@ -29,7 +29,7 @@
 
 
 #include "../../../Source/Core/DataExpression.cpp"
 #include "../../../Source/Core/DataExpression.cpp"
 
 
-#include <RmlUi/Core/DataModel.h>
+#include <RmlUi/Core/DataModelHandle.h>
 #include <RmlUi/Core/Types.h>
 #include <RmlUi/Core/Types.h>
 
 
 #include <doctest.h>
 #include <doctest.h>

+ 1 - 0
Tests/Source/UnitTests/DataModel.cpp

@@ -28,6 +28,7 @@
 
 
 #include "../../../Source/Core/DataModel.cpp"
 #include "../../../Source/Core/DataModel.cpp"
 #include <RmlUi/Core/Types.h>
 #include <RmlUi/Core/Types.h>
+#include <RmlUi/Core/DataModelHandle.h>
 #include <doctest.h>
 #include <doctest.h>
 
 
 using namespace Rml;
 using namespace Rml;