1 |
|
|
#ifndef ZSERIO_I_WALK_OBSERVER_H_INC |
2 |
|
|
#define ZSERIO_I_WALK_OBSERVER_H_INC |
3 |
|
|
|
4 |
|
|
#include "zserio/WalkerConst.h" |
5 |
|
|
#include "zserio/IReflectable.h" |
6 |
|
|
#include "zserio/ITypeInfo.h" |
7 |
|
|
|
8 |
|
|
namespace zserio |
9 |
|
|
{ |
10 |
|
|
|
11 |
|
|
/** |
12 |
|
|
* Interface for observers which are called by the walker. |
13 |
|
|
*/ |
14 |
|
|
template <typename ALLOC = std::allocator<uint8_t>> |
15 |
|
75 |
class IBasicWalkObserver |
16 |
|
|
{ |
17 |
|
|
public: |
18 |
|
|
/** Destructor. */ |
19 |
✗✓✗✓
|
89 |
virtual ~IBasicWalkObserver() = default; |
20 |
|
|
|
21 |
|
|
/** |
22 |
|
|
* Called for the root compound zserio object which is to be walked-through. |
23 |
|
|
* |
24 |
|
|
* \param compound Reflectable root compound zserio object. |
25 |
|
|
*/ |
26 |
|
|
virtual void beginRoot(const IBasicReflectableConstPtr<ALLOC>& compound) = 0; |
27 |
|
|
|
28 |
|
|
/** |
29 |
|
|
* Called at the end of just walked root compound zserio object. |
30 |
|
|
* |
31 |
|
|
* \param compound Reflectable root compound zserio object. |
32 |
|
|
*/ |
33 |
|
|
virtual void endRoot(const IBasicReflectableConstPtr<ALLOC>& compound) = 0; |
34 |
|
|
|
35 |
|
|
/** |
36 |
|
|
* Called at the beginning of an array. |
37 |
|
|
* |
38 |
|
|
* Note that for unset arrays (i.e. non-present optionals) the visitValue method with nullptr is called |
39 |
|
|
* instead! |
40 |
|
|
* |
41 |
|
|
* \param array Reflectable zserio array. |
42 |
|
|
* \param fieldInfo Array field info. |
43 |
|
|
*/ |
44 |
|
|
virtual void beginArray(const IBasicReflectableConstPtr<ALLOC>& array, |
45 |
|
|
const BasicFieldInfo<ALLOC>& fieldInfo) = 0; |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* Called at the end of an array. |
49 |
|
|
* |
50 |
|
|
* \param array Reflectable zserio array. |
51 |
|
|
* \param fieldInfo Array field info. |
52 |
|
|
*/ |
53 |
|
|
virtual void endArray(const IBasicReflectableConstPtr<ALLOC>& array, |
54 |
|
|
const BasicFieldInfo<ALLOC>& fieldInfo) = 0; |
55 |
|
|
|
56 |
|
|
/** |
57 |
|
|
* Called at the beginning of an compound field object. |
58 |
|
|
* |
59 |
|
|
* Note that for unset compounds (i.e. non-present optionals) the visitValue method with nullptr is called |
60 |
|
|
* instead! |
61 |
|
|
* |
62 |
|
|
* \param compound Reflectable compound zserio object. |
63 |
|
|
* \param fieldInfo Compound field info. |
64 |
|
|
* \param elementIndex Element index in array or WALKER_NOT_ELEMENT if the compound is not in array. |
65 |
|
|
*/ |
66 |
|
|
virtual void beginCompound(const IBasicReflectableConstPtr<ALLOC>& compound, |
67 |
|
|
const BasicFieldInfo<ALLOC>& fieldInfo, size_t elementIndex) = 0; |
68 |
|
|
|
69 |
|
|
/** |
70 |
|
|
* Called at the end of just walked compound object. |
71 |
|
|
* |
72 |
|
|
* \param compound Reflectable compound zserio object. |
73 |
|
|
* \param fieldInfo Compound field info. |
74 |
|
|
* \param elementIndex Element index in array or WALKER_NOT_ELEMENT if the compound is not in array. |
75 |
|
|
*/ |
76 |
|
|
virtual void endCompound(const IBasicReflectableConstPtr<ALLOC>& compound, |
77 |
|
|
const BasicFieldInfo<ALLOC>& fieldInfo, size_t elementIndex) = 0; |
78 |
|
|
|
79 |
|
|
/** |
80 |
|
|
* Called when a simple (or an unset compound or array - i.e. nullptr) value is reached. |
81 |
|
|
* |
82 |
|
|
* \param value Reflectable simple value. |
83 |
|
|
* \param fieldInfo Field info. |
84 |
|
|
* \param elementIndex Element index in array or WALKER_NOT_ELEMENT if the value is not in array. |
85 |
|
|
*/ |
86 |
|
|
virtual void visitValue(const IBasicReflectableConstPtr<ALLOC>& value, |
87 |
|
|
const BasicFieldInfo<ALLOC>& fieldInfo, size_t elementIndex) = 0; |
88 |
|
|
}; |
89 |
|
|
|
90 |
|
|
/** Typedefs to walk observer interface provided for convenience - using default std::allocator<uint8_t>. */ |
91 |
|
|
/** \{ */ |
92 |
|
|
using IWalkObserver = IBasicWalkObserver<>; |
93 |
|
|
/** \} */ |
94 |
|
|
|
95 |
|
|
} // namespace zserio |
96 |
|
|
|
97 |
|
|
#endif // ZSERIO_I_WALK_OBSERVER_H_INC |