15 #include <vsg/app/RecordTraversal.h>
16 #include <vsg/core/ConstVisitor.h>
17 #include <vsg/core/Visitor.h>
18 #include <vsg/core/ref_ptr.h>
19 #include <vsg/core/type_name.h>
26 template<
class ParentClass,
class Sub
class>
30 template<
typename... Args>
32 ParentClass(args...) {}
34 template<
typename... Args>
40 template<
typename... Args>
47 std::size_t sizeofObject()
const noexcept
override {
return sizeof(Subclass); }
48 const char* className()
const noexcept
override {
return type_name<Subclass>(); }
49 const std::type_info& type_info()
const noexcept
override {
return typeid(Subclass); }
50 bool is_compatible(
const std::type_info& type)
const noexcept
override {
return typeid(Subclass) == type || ParentClass::is_compatible(type); }
52 int compare(
const Object& rhs)
const override
54 int result = ParentClass::compare(rhs);
55 if (result != 0)
return result;
57 size_t startOfSubclass =
sizeof(ParentClass);
58 size_t size =
sizeof(Subclass) - startOfSubclass;
61 if (size == 0)
return 0;
63 const char* lhs_ptr =
reinterpret_cast<const char*
>(
this);
64 const char* rhs_ptr =
reinterpret_cast<const char*
>(&rhs);
67 return std::memcmp(lhs_ptr + startOfSubclass, rhs_ptr + startOfSubclass, size);
70 void accept(
Visitor& visitor)
override { visitor.apply(
static_cast<Subclass&
>(*
this)); }
71 void accept(
ConstVisitor& visitor)
const override { visitor.apply(
static_cast<const Subclass&
>(*
this)); }
72 void accept(
RecordTraversal& visitor)
const override { visitor.apply(
static_cast<const Subclass&
>(*
this)); }
Definition: ConstVisitor.h:147
RecordTraversal traverses a scene graph doing view frustum culling and invoking state/commands to rec...
Definition: RecordTraversal.h:61
Definition: Visitor.h:147