10 #define PVINTROSPECT_H
17 #include <epicsAssert.h>
20 #include <pv/noDefaultMethods.h>
21 #include <pv/pvType.h>
22 #include <pv/byteBuffer.h>
23 #include <pv/serialize.h>
24 #include <pv/pvdVersion.h>
27 #define PVD_DEPRECATED_52 PVD_DEPRECATED("See https://github.com/epics-base/pvDataCPP/issues/52")
40 # if __cplusplus>=201103L
47 # if __cplusplus>=201103L
48 # define OVERRIDE override
54 namespace epics {
namespace pvData {
77 long& l = indent_value(ios);
84 indent_value(stream) = saved_level;
98 array_at(std::size_t ix) : index(ix) {}
212 epicsShareExtern
const char*
name(
Type type);
272 #define MAX_SCALAR_TYPE pvString
278 namespace ScalarTypeFunc {
330 public std::tr1::enable_shared_from_this<Field> {
332 static size_t num_instances;
334 POINTER_DEFINITIONS(
Field);
356 std::tr1::shared_ptr<PVField> build()
const;
368 const Type m_fieldType;
371 friend struct Helper;
373 friend class StructureArray;
374 friend class Structure;
375 friend class PVFieldPvt;
376 friend class StandardField;
377 friend class BasePVStructureArray;
378 friend class FieldCreate;
379 EPICS_NOT_COPYABLE(Field)
391 POINTER_DEFINITIONS(
Scalar);
410 std::tr1::shared_ptr<
PVScalar> build() const;
422 EPICS_NOT_COPYABLE(
Scalar)
429 class epicsShareClass BoundedString : public Scalar{
431 POINTER_DEFINITIONS(BoundedString);
432 virtual ~BoundedString();
440 std::size_t getMaximumLength()
const;
443 BoundedString(std::size_t maxStringLength);
445 std::size_t maxLength;
446 friend class FieldCreate;
447 EPICS_NOT_COPYABLE(BoundedString)
456 POINTER_DEFINITIONS(
Array);
461 enum ArraySizeType { variable,
fixed, bounded };
467 virtual ArraySizeType getArraySizeType()
const = 0;
473 virtual std::size_t getMaximumCapacity()
const = 0;
482 EPICS_NOT_COPYABLE(
Array)
523 const std::
string getIDScalarArrayLUT() const;
526 EPICS_NOT_COPYABLE(ScalarArray)
559 friend class FieldCreate;
560 EPICS_NOT_COPYABLE(BoundedScalarArray)
591 friend class FieldCreate;
592 EPICS_NOT_COPYABLE(FixedScalarArray)
636 friend class FieldCreate;
637 EPICS_NOT_COPYABLE(StructureArray)
681 friend class FieldCreate;
682 EPICS_NOT_COPYABLE(UnionArray)
706 typedef const Structure& const_reference;
725 template<
typename FT>
728 STATIC_ASSERT(FT::isField);
745 template<
typename FT>
748 STATIC_ASSERT(FT::isField);
749 std::tr1::shared_ptr<const FT> result(
750 std::tr1::dynamic_pointer_cast<const FT>(getFieldT(fieldName))
771 template<
typename FT>
772 std::tr1::shared_ptr<const FT>
getField(std::size_t index)
const
774 STATIC_ASSERT(FT::isField);
791 template<
typename FT>
792 std::tr1::shared_ptr<const FT>
getFieldT(std::size_t index)
const
794 STATIC_ASSERT(FT::isField);
795 std::tr1::shared_ptr<const FT> result(
796 std::tr1::dynamic_pointer_cast<const FT>(getFieldT(index))
810 std::size_t getFieldIndex(
std::string const &fieldName)
const;
846 FieldConstPtr getFieldImpl(const std::
string& fieldName,
bool throws) const;
847 void dumpFields(std::
ostream& o) const;
849 friend class FieldCreate;
858 class epicsShareClass Union : public Field {
860 POINTER_DEFINITIONS(Union);
885 typedef Union& reference;
886 typedef const Union& const_reference;
905 template<
typename FT>
908 STATIC_ASSERT(FT::isField);
925 template<
typename FT>
928 STATIC_ASSERT(FT::isField);
929 std::tr1::shared_ptr<const FT> result(
930 std::tr1::dynamic_pointer_cast<const FT>(getFieldT(fieldName))
951 template<
typename FT>
952 std::tr1::shared_ptr<const FT>
getField(std::size_t index)
const
954 STATIC_ASSERT(FT::isField);
971 template<
typename FT>
972 std::tr1::shared_ptr<const FT>
getFieldT(std::size_t index)
const
974 STATIC_ASSERT(FT::isField);
975 std::tr1::shared_ptr<const FT> result(
976 std::tr1::dynamic_pointer_cast<const FT>(getFieldT(index))
990 std::size_t getFieldIndex(
std::string const &fieldName)
const;
1026 virtual std::
ostream& dump(std::
ostream& o) const OVERRIDE FINAL;
1033 std::tr1::shared_ptr<
PVUnion> build() const;
1043 FieldConstPtr getFieldImpl(const std::
string& fieldName,
bool throws) const;
1044 void dumpFields(std::
ostream& o) const;
1046 friend class FieldCreate;
1047 friend class Structure;
1048 EPICS_NOT_COPYABLE(Union)
1052 typedef std::tr1::shared_ptr<FieldCreate> FieldCreatePtr;
1055 typedef std::tr1::shared_ptr<FieldBuilder> FieldBuilderPtr;
1064 class epicsShareClass FieldBuilder :
1065 public std::tr1::enable_shared_from_this<FieldBuilder>
1070 static FieldBuilderPtr
begin();
1095 FieldBuilderPtr addBoundedString(
std::string const & name, std::size_t maxLength) PVD_DEPRECATED_52;
1120 FieldBuilderPtr addFixedArray(
std::string const & name,
ScalarType scalarType, std::size_t size) PVD_DEPRECATED_52;
1129 FieldBuilderPtr addBoundedArray(
std::string const & name,
ScalarType scalarType, std::size_t bound) PVD_DEPRECATED_52;
1161 FieldBuilderPtr addNestedStructure(
std::string const & name);
1171 FieldBuilderPtr addNestedUnion(
std::string const & name);
1181 FieldBuilderPtr addNestedStructureArray(
std::string const & name);
1191 FieldBuilderPtr addNestedUnionArray(
std::string const & name);
1199 FieldBuilderPtr endNested();
1203 FieldBuilder(
const Structure*);
1204 FieldBuilder(
const FieldBuilderPtr & _parentBuilder,
const std::string& name,
const Structure*);
1205 FieldBuilder(
const FieldBuilderPtr & _parentBuilder,
const std::string& name,
const StructureArray*);
1206 FieldBuilder(
const FieldBuilderPtr & _parentBuilder,
const std::string& name,
const Union*);
1207 FieldBuilder(
const FieldBuilderPtr & _parentBuilder,
const std::string& name,
const UnionArray*);
1208 FieldBuilder(FieldBuilderPtr
const & parentBuilder,
1210 Type nestedClassToBuild,
bool nestedArray);
1217 friend class FieldCreate;
1219 const FieldCreatePtr fieldCreate;
1227 const FieldBuilderPtr parentBuilder;
1228 const Type nestedClassToBuild;
1230 const bool nestedArray;
1231 const bool createNested;
1235 struct field_factory;
1242 class epicsShareClass FieldCreate {
1243 friend struct detail::field_factory;
1250 FieldBuilderPtr createFieldBuilder()
const;
1395 mutable Mutex mutex;
1401 EPICS_NOT_COPYABLE(FieldCreate)
1409 return FieldCreate::getFieldCreate();
1422 template<
typename T>
1431 template<ScalarType ID>
1434 #define OP(ENUM, TYPE) \
1435 template<> struct ScalarTypeTraits<ENUM> {typedef TYPE type;}; \
1436 template<> struct ScalarTypeID<TYPE> { enum {value=ENUM}; }; \
1437 template<> struct ScalarTypeID<const TYPE> { enum {value=ENUM}; };
1453 bool epicsShareExtern compare(
const Field&,
const Field&);
1454 bool epicsShareExtern compare(
const Scalar&,
const Scalar&);
1455 bool epicsShareExtern compare(
const ScalarArray&,
const ScalarArray&);
1456 bool epicsShareExtern compare(
const Structure&,
const Structure&);
1457 bool epicsShareExtern compare(
const StructureArray&,
const StructureArray&);
1458 bool epicsShareExtern compare(
const Union&,
const Union&);
1459 bool epicsShareExtern compare(
const UnionArray&,
const UnionArray&);
1468 #define MAKE_COMPARE(CLASS) \
1469 static FORCE_INLINE bool operator==(const CLASS& a, const CLASS& b) {return (void*)&a==(void*)&b;} \
1470 static FORCE_INLINE bool operator!=(const CLASS& a, const CLASS& b) {return !(a==b);}
1474 MAKE_COMPARE(ScalarArray)
1475 MAKE_COMPARE(Structure)
1476 MAKE_COMPARE(StructureArray)
1478 MAKE_COMPARE(UnionArray)
const FieldConstPtr & getField(std::size_t index) const
basic_ostream< _CharT, _Traits > & operator<<(basic_ostream< _CharT, _Traits > &__os, const basic_string< _CharT, _Traits, _Alloc > &__str)
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::bernoulli_distribution &__x)
UnionConstPtr getUnion() const
std::tr1::shared_ptr< const FT > getField(std::size_t index) const
std::string getFieldName(std::size_t fieldIndex) const
bool isUInteger(ScalarType scalarType)
virtual ArraySizeType getArraySizeType() const
const char * name(ScalarType scalarType)
std::tr1::shared_ptr< const StructureArray > StructureArrayConstPtr
valarray< size_t > size() const
FieldConstPtr getFieldT(std::size_t index) const
std::tr1::shared_ptr< const FT > getField(std::string const &fieldName) const
virtual ArraySizeType getArraySizeType() const
ScalarType getScalarType(std::string const &value)
Data interface for a structure,.
static const std::string DEFAULT_ID
std::tr1::shared_ptr< const Structure > StructureConstPtr
bool isPrimitive(ScalarType scalarType)
std::size_t getNumberFields() const
constexpr reference at(size_type __n)
directory_iterator begin(directory_iterator __iter) noexcept
std::tr1::shared_ptr< const FT > getField(std::size_t index) const
const std::string & getFieldName(std::size_t fieldIndex) const
This class implements introspection object for Array.
This class implements introspection object for a structureArray.
StringArray const & getFieldNames() const
Callback class for serialization.
This class implements introspection object for field.
std::tr1::shared_ptr< const UnionArray > UnionArrayConstPtr
This class implements introspection object for bounded scalar array.
std::tr1::shared_ptr< const Field > FieldConstPtr
This class implements introspection object for a union.
virtual ArraySizeType getArraySizeType() const
Base class for a scalarArray.
This class implements a Bytebuffer that is like the java.nio.ByteBuffer.
const StructureConstPtr & getStructure() const
This is a singleton class for creating introspection interfaces.
virtual std::size_t getMaximumCapacity() const
ScalarType getScalarType() const
StringArray const & getFieldNames() const
reference at(size_type __n)
This class implements introspection object for Scalar.
std::size_t getNumberFields() const
PVScalar is the base class for each scalar field.
FieldConstPtr getField(std::size_t index) const
virtual std::size_t getMaximumCapacity() const
ios_base & fixed(ios_base &__base)
std::tr1::shared_ptr< const Union > UnionConstPtr
This class implements introspection object for a unionArray.
virtual ArraySizeType getArraySizeType() const
virtual std::size_t getMaximumCapacity() const
std::tr1::shared_ptr< const FT > getField(std::string const &fieldName) const
This class implements introspection object for scalar array.
template class for all extensions of PVArray.
FieldConstPtr getFieldT(std::string const &fieldName) const
const char * name(Type type)
virtual std::size_t getMaximumCapacity() const
Callback class for deserialization.
This class implements introspection object for BoundedString.
std::tr1::shared_ptr< const FT > getFieldT(std::string const &fieldName) const
PVField is the base class for each PVData field.
ScalarType getElementType() const
std::tr1::shared_ptr< const FT > getFieldT(std::string const &fieldName) const
std::vector< FieldConstPtr > FieldConstPtrArray
shared_ptr< _Tp > dynamic_pointer_cast(const shared_ptr< _Up > &__r) noexcept
basic_ostream< char > ostream
virtual ArraySizeType getArraySizeType() const
std::tr1::shared_ptr< const ScalarArray > ScalarArrayConstPtr
const FieldCreatePtr & getFieldCreate()
virtual std::size_t getMaximumCapacity() const
static const std::string ANY_ID
bool isNumeric(ScalarType scalarType)
FieldConstPtrArray const & getFields() const
size_t elementSize(ScalarType id)
gives sizeof(T) where T depends on the scalar type id.
std::tr1::shared_ptr< const Scalar > ScalarConstPtr
Interface for in-line creating of introspection interfaces.
std::tr1::shared_ptr< const FT > getFieldT(std::size_t index) const
PVUnion has a single subfield.
Base class for serialization.
FieldConstPtr getFieldT(std::size_t index) const
std::tr1::shared_ptr< const FT > getFieldT(std::size_t index) const
This class implements introspection object for bounded scalar array.
This class implements introspection object for a structure.
static const std::string DEFAULT_ID
bool isInteger(ScalarType scalarType)
std::tr1::shared_ptr< const Array > ArrayConstPtr
FieldConstPtr getFieldT(std::string const &fieldName) const
std::tr1::shared_ptr< const BoundedString > BoundedStringConstPtr
FieldConstPtrArray const & getFields() const