Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef CPP_INTROSPECTION_FIELD_H
00030 #define CPP_INTROSPECTION_FIELD_H
00031
00032 #include <introspection/forwards.h>
00033 #include <introspection/type.h>
00034
00035 namespace cpp_introspection {
00036
00037 class Field
00038 {
00039 public:
00040 virtual ~Field() { }
00041
00042 virtual const Message& message() const = 0;
00043
00044 virtual const char* getName() const = 0;
00045 virtual const char* getDataType() const = 0;
00046 virtual const char* getValueType() const = 0;
00047 virtual std::size_t getIndex() const = 0;
00048 virtual const std::type_info& getTypeId() const = 0;
00049 virtual TypePtr getType() const { return type(getValueType()); }
00050
00051 virtual bool isArray() const = 0;
00052 virtual bool isVector() const = 0;
00053 virtual bool isContainer() const = 0;
00054 virtual bool isSimple() const = 0;
00055 virtual bool isFixedSize() const = 0;
00056 virtual bool isMessage() const = 0;
00057
00058 virtual bool hasInstance() const { return false; }
00059 virtual boost::any get(std::size_t i = 0) const { return boost::any(); }
00060 template <typename T> T as(std::size_t i = 0) const { return getType()->as<T>(get(i)); }
00061
00062 virtual void setAny(const boost::any& value, std::size_t i = 0) const { }
00063 template <typename T> void set(const T& value, std::size_t i = 0) const { setAny(getType()->from(value), i); }
00064
00065 virtual std::size_t size() const { return 1; }
00066 virtual void resize(size_t new_size) const {}
00067 virtual bool empty() const { return false; }
00068 virtual std::size_t capacity() const { return 1; }
00069
00070 virtual MessagePtr expand(std::size_t i = 0) const;
00071 virtual FieldPtr access(AccessorBase& accessor) const = 0;
00072 };
00073
00074 }
00075
00076 #endif // CPP_INTROSPECTION_FIELD_H