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> bool is() const { return isTypeOf(T::typeKey); }
23 template <typename T> T* as()
26 return reinterpret_cast<T*>(this);
29 template <typename T> const T* as() const
32 return reinterpret_cast<const T*>(this);
35 /// Called when the object is first added to the context, other objects
36 /// may not have resolved their dependencies yet. This is an opportunity
37 /// to look up objects referenced by id, but not assume that they in
38 /// turn have resolved their references yet. Called during
40 virtual StatusCode onAddedDirty(CoreContext* context) = 0;
42 /// Called when all the objects in the context have had onAddedDirty
43 /// called. This is an opportunity to reference things referenced by
44 /// dependencies. (A path should be able to find a Shape somewhere in
45 /// its hierarchy, which may be multiple levels up).
46 virtual StatusCode onAddedClean(CoreContext* context) = 0;
48 virtual StatusCode import(ImportStack& importStack)
50 return StatusCode::Ok;