1 #ifndef _RIVE_CORE_HPP_
2 #define _RIVE_CORE_HPP_
4 #include "core/binary_reader.hpp"
5 #include "status_code.hpp"
15 static const int invalidPropertyKey = 0;
17 virtual uint16_t coreType() const = 0;
18 virtual bool isTypeOf(uint16_t typeKey) const = 0;
19 virtual bool deserialize(uint16_t propertyKey,
20 BinaryReader& reader) = 0;
22 template <typename T> inline bool is() const
24 return isTypeOf(T::typeKey);
26 template <typename T> inline T* as()
29 return reinterpret_cast<T*>(this);
32 virtual Core* clone() const { return nullptr; }
34 template <typename T> inline const T* as() const
37 return reinterpret_cast<const T*>(this);
40 /// Called when the object is first added to the context, other objects
41 /// may not have resolved their dependencies yet. This is an opportunity
42 /// to look up objects referenced by id, but not assume that they in
43 /// turn have resolved their references yet. Called during
45 virtual StatusCode onAddedDirty(CoreContext* context)
47 return StatusCode::Ok;
50 /// Called when all the objects in the context have had onAddedDirty
51 /// called. This is an opportunity to reference things referenced by
52 /// dependencies. (A path should be able to find a Shape somewhere in
53 /// its hierarchy, which may be multiple levels up).
54 virtual StatusCode onAddedClean(CoreContext* context)
56 return StatusCode::Ok;
59 virtual StatusCode import(ImportStack& importStack)
61 return StatusCode::Ok;