1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "Prerequisites/BsPrerequisitesUtil.h"
6
7namespace bs
8{
9 struct SerializationContext;
10
11 /** @addtogroup Internal-Utility
12 * @{
13 */
14
15 /** @addtogroup Serialization-Internal
16 * @{
17 */
18
19 /**
20 * Represents an interface RTTI objects need to implement if they want to provide custom method of comparing
21 * their objects for equality.
22 */
23 class BS_UTILITY_EXPORT ICompare
24 {
25 public:
26 virtual ~ICompare() = default;
27
28 /** Checks if two IReflectable objects are equal. */
29 virtual bool run(IReflectable& a, IReflectable& b) = 0;
30 };
31
32 /** Compares native IReflectable objects for equality. */
33 class BS_UTILITY_EXPORT BinaryCompare : public ICompare
34 {
35 public:
36 BinaryCompare();
37 virtual ~BinaryCompare() = default;
38
39 /** @copydoc ICompare::run */
40 bool run(IReflectable& a, IReflectable& b) override;
41
42 protected:
43 /**
44 * Checks if two IReflectable objects are equal. Inserts the results into an object map so multiple references
45 * to the same object don't need to be checked twice.
46 */
47 bool compare(IReflectable& a, IReflectable& b);
48
49 UnorderedSet<IReflectable*> mObjectMap;
50 SerializationContext* mContext = nullptr;
51 FrameAlloc* mAlloc = nullptr;
52 };
53
54 /** @} */
55 /** @} */
56}
57