Zserio C++ runtime library  1.0.2
Built for Zserio 2.14.1
IReflectable.h
Go to the documentation of this file.
1 #ifndef ZSERIO_I_REFLECTABLE_H_INC
2 #define ZSERIO_I_REFLECTABLE_H_INC
3 
4 #include <memory>
5 
6 #include "zserio/AnyHolder.h"
7 #include "zserio/BitBuffer.h"
9 #include "zserio/RebindAlloc.h"
10 #include "zserio/Span.h"
11 #include "zserio/String.h"
12 #include "zserio/StringView.h"
13 #include "zserio/Vector.h"
14 
15 namespace zserio
16 {
17 
18 // forward declaration
19 template <typename ALLOC>
20 class IBasicTypeInfo;
21 
30 template <typename ALLOC = std::allocator<uint8_t>>
32 {
33 public:
35  using Ptr = std::shared_ptr<IBasicReflectable>;
36 
38  using ConstPtr = std::shared_ptr<const IBasicReflectable>;
39 
43  virtual ~IBasicReflectable() = default;
44 
50  virtual const IBasicTypeInfo<ALLOC>& getTypeInfo() const = 0;
51 
57  virtual bool isArray() const = 0;
58 
68  virtual void initializeChildren() = 0;
69 
78  virtual void initialize(const vector<AnyHolder<ALLOC>, ALLOC>& typeArguments) = 0;
79 
89  virtual size_t initializeOffsets(size_t bitPosition) = 0;
90 
100  virtual size_t initializeOffsets() = 0;
101 
113  virtual size_t bitSizeOf(size_t bitPosition) const = 0;
114 
126  virtual size_t bitSizeOf() const = 0;
127 
137  virtual void write(BitStreamWriter& writer) const = 0;
138 
152  virtual ConstPtr getField(StringView name) const = 0;
153  virtual Ptr getField(StringView name) = 0;
169  virtual void setField(StringView name, const AnyHolder<ALLOC>& value) = 0;
170 
183  virtual Ptr createField(StringView name) = 0;
184 
198  virtual ConstPtr getParameter(StringView name) const = 0;
199  virtual Ptr getParameter(StringView name) = 0;
216  virtual ConstPtr callFunction(StringView name) const = 0;
217  virtual Ptr callFunction(StringView name) = 0;
229  virtual StringView getChoice() const = 0;
230 
248  virtual ConstPtr find(StringView path) const = 0;
249  virtual Ptr find(StringView path) = 0;
258  virtual ConstPtr operator[](StringView path) const = 0;
259  virtual Ptr operator[](StringView path) = 0;
271  virtual size_t size() const = 0;
272 
282  virtual void resize(size_t size) = 0;
283 
295  virtual ConstPtr at(size_t index) const = 0;
296  virtual Ptr at(size_t index) = 0;
305  virtual ConstPtr operator[](size_t index) const = 0;
306  virtual Ptr operator[](size_t index) = 0;
317  virtual void setAt(const AnyHolder<ALLOC>& value, size_t index) = 0;
318 
326  virtual void append(const AnyHolder<ALLOC>& value) = 0;
327 
345  virtual AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const = 0;
346  virtual AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) = 0;
347  virtual AnyHolder<ALLOC> getAnyValue() const = 0;
357  virtual bool getBool() const = 0;
358 
365  virtual int8_t getInt8() const = 0;
366 
373  virtual int16_t getInt16() const = 0;
374 
381  virtual int32_t getInt32() const = 0;
382 
389  virtual int64_t getInt64() const = 0;
390 
397  virtual uint8_t getUInt8() const = 0;
398 
405  virtual uint16_t getUInt16() const = 0;
406 
413  virtual uint32_t getUInt32() const = 0;
414 
421  virtual uint64_t getUInt64() const = 0;
422 
429  virtual float getFloat() const = 0;
430 
437  virtual double getDouble() const = 0;
438 
445  virtual Span<const uint8_t> getBytes() const = 0;
446 
453  virtual StringView getStringView() const = 0;
454 
461  virtual const BasicBitBuffer<ALLOC>& getBitBuffer() const = 0;
462 
471  virtual int64_t toInt() const = 0;
472 
482  virtual uint64_t toUInt() const = 0;
483 
492  virtual double toDouble() const = 0;
493 
508  virtual string<ALLOC> toString(const ALLOC& allocator) const = 0;
509  virtual string<ALLOC> toString() const = 0;
511 };
512 
515 template <typename ALLOC = std::allocator<uint8_t>>
517 
518 template <typename ALLOC = std::allocator<uint8_t>>
537 template <typename T, typename ALLOC = std::allocator<uint8_t>>
538 IBasicReflectablePtr<ALLOC> enumReflectable(T value, const ALLOC& allocator = ALLOC());
539 
540 } // namespace zserio
541 
542 #endif // ZSERIO_I_REFLECTABLE_H_INC
virtual double getDouble() const =0
virtual Ptr callFunction(StringView name)=0
virtual Span< const uint8_t > getBytes() const =0
virtual string< ALLOC > toString() const =0
virtual void write(BitStreamWriter &writer) const =0
virtual Ptr getParameter(StringView name)=0
virtual size_t bitSizeOf(size_t bitPosition) const =0
virtual StringView getStringView() const =0
virtual void initialize(const vector< AnyHolder< ALLOC >, ALLOC > &typeArguments)=0
virtual ConstPtr getParameter(StringView name) const =0
virtual AnyHolder< ALLOC > getAnyValue(const ALLOC &allocator)=0
virtual int8_t getInt8() const =0
virtual bool isArray() const =0
virtual Ptr find(StringView path)=0
virtual bool getBool() const =0
virtual AnyHolder< ALLOC > getAnyValue() const =0
virtual void resize(size_t size)=0
virtual void setAt(const AnyHolder< ALLOC > &value, size_t index)=0
virtual AnyHolder< ALLOC > getAnyValue(const ALLOC &allocator) const =0
std::shared_ptr< const IBasicReflectable > ConstPtr
Definition: IReflectable.h:38
virtual Ptr getField(StringView name)=0
virtual Ptr operator[](size_t index)=0
virtual int16_t getInt16() const =0
virtual size_t size() const =0
virtual size_t initializeOffsets()=0
virtual const IBasicTypeInfo< ALLOC > & getTypeInfo() const =0
virtual Ptr createField(StringView name)=0
virtual double toDouble() const =0
virtual void setField(StringView name, const AnyHolder< ALLOC > &value)=0
virtual AnyHolder< ALLOC > getAnyValue()=0
virtual ConstPtr operator[](StringView path) const =0
virtual ConstPtr at(size_t index) const =0
virtual uint64_t toUInt() const =0
virtual void append(const AnyHolder< ALLOC > &value)=0
virtual uint32_t getUInt32() const =0
virtual float getFloat() const =0
virtual Ptr at(size_t index)=0
virtual Ptr operator[](StringView path)=0
virtual int32_t getInt32() const =0
virtual int64_t getInt64() const =0
virtual ~IBasicReflectable()=default
virtual uint8_t getUInt8() const =0
virtual ConstPtr getField(StringView name) const =0
virtual uint64_t getUInt64() const =0
virtual size_t initializeOffsets(size_t bitPosition)=0
virtual string< ALLOC > toString(const ALLOC &allocator) const =0
virtual ConstPtr find(StringView path) const =0
virtual StringView getChoice() const =0
virtual const BasicBitBuffer< ALLOC > & getBitBuffer() const =0
std::shared_ptr< IBasicReflectable > Ptr
Definition: IReflectable.h:35
virtual uint16_t getUInt16() const =0
virtual void initializeChildren()=0
virtual ConstPtr callFunction(StringView name) const =0
virtual int64_t toInt() const =0
virtual ConstPtr operator[](size_t index) const =0
virtual size_t bitSizeOf() const =0
IBasicReflectablePtr<> IReflectablePtr
Definition: IReflectable.h:525
std::basic_string< char, std::char_traits< char >, RebindAlloc< ALLOC, char > > string
Definition: String.h:17
std::vector< T, RebindAlloc< ALLOC, T > > vector
Definition: Vector.h:17
IBasicReflectablePtr< ALLOC > enumReflectable(T value, const ALLOC &allocator=ALLOC())
IBasicReflectableConstPtr<> IReflectableConstPtr
Definition: IReflectable.h:526
typename IBasicReflectable< ALLOC >::Ptr IBasicReflectablePtr
Definition: IReflectable.h:516
typename IBasicReflectable< ALLOC >::ConstPtr IBasicReflectableConstPtr
Definition: IReflectable.h:519