diff --git a/documentation/pvDataCpp.html b/documentation/pvDataCpp.html index 4cb9be7..7ae2a6d 100644 --- a/documentation/pvDataCpp.html +++ b/documentation/pvDataCpp.html @@ -9,7 +9,7 @@
TODO
pvData describes and implements structured data. Interspection interfaces are used to describe the data and for each type of data a data interface provides a container to hold the data.
-pvData is modeled as a structured set of fields. A field has a name are a type. The type must be one of:
@@ -238,7 +236,7 @@ type. The type must be one of: addition each type has an introspection interface: Scalar, ScalarArray, Structure, and StructureArray. -Interface PVField provides access to the common information of every data container. In addition every possible type has an interface for accessing the @@ -257,7 +255,7 @@ data:
pvData provides support, via pvData structures and associated support, for the following:
@@ -274,7 +272,7 @@ the following:pvAccess provides client/server support for transmitting pvData objects. The server must provide access to objects identified by name. Each object must have @@ -329,7 +327,7 @@ features:
Large objects automatically span network packets. -IOC means Input/Output Controller, which is an EPICS term. A pvIOC is modeled after an EPICS IOC but supports pvData instead of flat record @@ -376,7 +374,7 @@ an existing EPICS IOC.
PVData is one of a set of related projects: pvData, pvAccess, and javaIOC. @@ -476,7 +474,7 @@ pvDataApp:
This section describes a meta language for describing pvData. Currently @@ -484,7 +482,7 @@ there are no plans for a parser for the meta language. It is used for documentation. Also the toString introspection and data methods described below present data in this format.
-PVData supports structured data. All data appears as a top level structure. A structure has an ordered set of fields where each field has a [] White space is permitted surrounding each comma.
-Define the following top level structure:
structure timeStamp
@@ -631,10 +629,10 @@ structure[] structureArrayExample
double y 10.0
Directory pvDataApp/pv has header files that completely describe pvData. The implementation is provided in directory pvDataApp/factory. Test programs @@ -668,7 +666,7 @@ converting and copying data between fields.
alarm, etc. -This provides C/C++ definitions for the pvData primitive types: boolean, byte, short, int, long, float, double, and string. Because pvData is network @@ -726,7 +724,7 @@ typedef std::string * StringBuilder;
This subsection describes pvIntrospect.h
@@ -741,7 +739,7 @@ especially important for arrays and structures so that a client can discover the type without requiring that a large data array or structure be transported over the network. -Types are defined as:
enum Type {
@@ -753,6 +751,7 @@ over the network.
class TypeFunc {
public:
+ const char* name(Type);
static void toString(StringBuilder buf,const Type type);
};
@@ -770,6 +769,7 @@ public:
static bool isNumeric(ScalarType type);
static bool isPrimitive(ScalarType type);
static ScalarType getScalarType(String value);
+ const char* name(ScalarType);
static void toString(StringBuilder buf,ScalarType scalarType);
};
@@ -811,6 +811,8 @@ following:
TypeFunction is a set of convenience methods for Type
This section describes the reflection interfaces which provide the following:
@@ -864,26 +868,41 @@ following:
-class Field : private NoDefaultMethods {
+class Field;
+class Scalar;
+class ScalarArray;
+class Structure;
+class StructureArray;
+
+typedef std::tr1::shared_ptr<const Field> FieldConstPtr;
+typedef FieldConstPtr * FieldConstPtrArray;
+typedef std::tr1::shared_ptr<const Scalar> ScalarConstPtr;
+typedef std::tr1::shared_ptr<const ScalarArray> ScalarArrayConstPtr;
+typedef std::tr1::shared_ptr<const Structure> StructureConstPtr;
+typedef std::tr1::shared_ptr<const StructureArray> StructureArrayConstPtr;
+
+
+protected:class Field : public std::tr1::enable_shared_from_this<Field> {
public:
- int getReferenceCount() const;
- String getFieldName() const;
- Type getType() const;
- virtual void toString(StringBuilder buf) const{toString(buf,0);}
- virtual void toString(StringBuilder buf,int indentLevel) const;
- void renameField(String newName);
- void incReferenceCount() const;
- void decReferenceCount() const;
- void dumpReferenceCount(StringBuilder buf,int indentLevel) const;
- virtual bool operator==(const Field& field) const;
- virtual bool operator!=(const Field& field) const;
-protected:
+ typedef std::tr1::shared_ptr<Field> shared_pointer;
+ typedef std::tr1::shared_ptr<const Field> const_shared_pointer;
+
+ String getFieldName() const{return m_fieldName;}
+ Type getType() const{return m_type;}
+ virtual void toString(StringBuilder buf) const{toString(buf,0);}
+ virtual void toString(StringBuilder buf,int indentLevel) const;
+ void renameField(String newName);
Field(String fieldName,Type type);
virtual ~Field();
};
class Scalar : public Field{
public:
+ typedef std::tr1::shared_ptr<Scalar> shared_pointer;
+ typedef std::tr1::shared_ptr<const Scalar> const_shared_pointer;
+ typedef Scalar& reference;
+ typedef const Scalar& const_reference;
+
ScalarType getScalarType() const {return scalarType;}
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
@@ -895,6 +914,11 @@ protected:
class ScalarArray : public Field{
public:
+ typedef std::tr1::shared_ptr<ScalarArray> shared_pointer;
+ typedef std::tr1::shared_ptr<const ScalarArray> const_shared_pointer;
+ typedef ScalarArray& reference;
+ typedef const ScalarArray& const_reference;
+
ScalarType getElementType() const {return elementType;}
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
@@ -906,17 +930,23 @@ protected:
class StructureArray : public Field{
public:
+ typedef std::tr1::shared_ptr<StructureArray> shared_pointer;
+ typedef std::tr1::shared_ptr<const StructureArray> const_shared_pointer;
+ typedef StructureArray& reference;
+ typedef const StructureArray& const_reference;
+
+ const Structure& structure() const {return *pstructure;}
StructureConstPtr getStructure() const {return pstructure;}
- virtual void toString(StringBuilder buf) const{toString(buf,0);}
- virtual void toString(StringBuilder buf,int indentLevel) const;
-protected:
- StructureArray(String fieldName,StructureConstPtr structure);
- virtual ~StructureArray();
- ...
+ virtual void toString(StringBuilder buf,int indentLevel=0) const;
};
class Structure : public Field {
public:
+ typedef std::tr1::shared_ptr<Structure> shared_pointer;
+ typedef std::tr1::shared_ptr<const Structure> const_shared_pointer;
+ typedef Structure& reference;
+ typedef const Structure& const_reference;
+
int getNumberFields() const {return numberFields;}
FieldConstPtr getField(String fieldName) const;
int getFieldIndex(String fieldName) const;
@@ -1061,7 +1091,7 @@ methods:
structure->incReferenceCount() must be called before this method.
-Standard Fields
+Standard Fields
The file standardField.h has a class description for creating or sharing
Field objects for standard fields. For each type of standard object two methods
@@ -1109,10 +1139,8 @@ public:
StructureConstPtr structure,String properties);
StructureConstPtr structure(String fieldName,
int numFields,FieldConstPtrArray fields);
- StructureConstPtr enumerated(String fieldName,
- StringArray choices);
- StructureConstPtr enumerated(String fieldName,
- StringArray choices, String properties);
+ StructureConstPtr enumerated(String fieldName);
+ StructureConstPtr enumerated(String fieldName, String properties);
ScalarConstPtr scalarValue(ScalarType type);
StructureConstPtr scalarValue(ScalarType type,String properties);
ScalarArrayConstPtr scalarArrayValue(ScalarType elementType);
@@ -1199,12 +1227,12 @@ extern StandardField * getStandardField();
the section on Properties for a description of how these are defined.
-This section defines the Java Interfaces for accessing the data within a PV record.
-PVField is the base interface for accessing data. A data structure consists of a top level PVStructure. Every field of every structure of every top level @@ -1214,30 +1242,28 @@ public: virtual void postPut() = 0; }; - class PVField -: public Requester, - public Serializable, +: public Serializable, private NoDefaultMethods { public: virtual ~PVField(); + virtual void message(String message,MessageType messageType) ; virtual void setRequester(Requester *prequester); int getFieldOffset() ; int getNextFieldOffset() ; int getNumberFields() ; PVAuxInfo * getPVAuxInfo(); bool isImmutable() ; - void setImmutable(); + virtual void setImmutable(); FieldConstPtr getField() ; PVStructure * getParent() ; bool renameField(String newName); void postPut() ; void setPostHandler(PostHandler *postHandler); + virtual bool equals(PVField &pv); virtual void toString(StringBuilder buf) ; virtual void toString(StringBuilder buf,int indentLevel) ; - virtual bool operator==(PVField &pv) = 0; - virtual bool operator!=(PVField &pv) = 0; protected: PVField(PVStructure *parent,FieldConstPtr field); void setParent(PVStructure *parent); @@ -1249,7 +1275,7 @@ be implemented by any code that calls setPostHandler. It's single virtual method. postPut is called whenever PVField::postPut is called.
-Requester,Serializable, and
+ Serializable, and
NoDefaultMethods are described in a later section. The public methods for PVField
@@ -1259,6 +1285,9 @@ are:
AuxInfo (Auxillary Information) is information about a field that is application specific. It will not be available outside the application that @@ -1349,7 +1377,7 @@ private:
class PVScalar : public PVField {
public:
virtual ~PVScalar();
@@ -1358,96 +1386,46 @@ protected:
PVScalar(PVStructure *parent,ScalarConstPtr scalar);
};
-The interfaces for primitive data types are:
-class PVBoolean : public PVScalar {
+template<typename T>
+class PVScalarValue : public PVScalar {
public:
- virtual ~PVBoolean();
- virtual bool get() = 0;
- virtual void put(bool value) = 0;
+ typedef std::tr1::shared_ptr<PVScalarValue> shared_pointer;
+ typedef std::tr1::shared_ptr<const PVScalarValue> const_shared_pointer;
+
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+
+ virtual ~PVScalarValue() {}
+ virtual T get() = 0;
+ virtual void put(T value) = 0;
protected:
- PVBoolean(PVStructure *parent,ScalarConstPtr scalar)
+ PVScalarValue(PVStructure *parent,ScalarConstPtr scalar)
: PVScalar(parent,scalar) {}
private:
};
-class PVByte : public PVScalar {
-public:
- virtual ~PVByte();
- virtual int8 get() = 0;
- virtual void put(int8 value) = 0;
-protected:
- PVByte(PVStructure *parent,ScalarConstPtr scalar)
- : PVScalar(parent,scalar) {}
-private:
-};
+typedef PVScalarValue<bool> PVBoolean;
+typedef PVScalarValue<int8> PVByte;
+typedef PVScalarValue<int16> PVShort;
+typedef PVScalarValue<int32> PVInt;
+typedef PVScalarValue<int64> PVLong;
+typedef PVScalarValue<float> PVFloat;
+typedef PVScalarValue<double> PVDouble;
-class PVShort : public PVScalar {
+// PVString is special case, since it implements SerializableArray
+class PVString : public PVScalarValue<String>, SerializableArray {
public:
- virtual ~PVShort();
- virtual int16 get() = 0;
- virtual void put(int16 value) = 0;
-protected:
- PVShort(PVStructure *parent,ScalarConstPtr scalar)
- : PVScalar(parent,scalar) {}
-private:
-};
-class PVInt : public PVScalar{
-public:
- virtual ~PVInt();
- virtual int32 get() = 0;
- virtual void put(int32 value) = 0;
-protected:
- PVInt(PVStructure *parent,ScalarConstPtr scalar)
- : PVScalar(parent,scalar) {}
-private:
-};
-
-class PVLong : public PVScalar {
-public:
- virtual ~PVLong();
- virtual int64 get() = 0;
- virtual void put(int64 value) = 0;
-protected:
- PVLong(PVStructure *parent,ScalarConstPtr scalar)
- : PVScalar(parent,scalar) {}
-private:
-};
-
-class PVFloat : public PVScalar {
-public:
- virtual ~PVFloat();
- virtual float get() = 0;
- virtual void put(float value) = 0;
-protected:
- PVFloat(PVStructure *parent,ScalarConstPtr scalar)
- : PVScalar(parent,scalar) {}
-private:
-};
-class PVDouble : public PVScalar {
-public:
- virtual ~PVDouble();
- virtual double get() = 0;
- virtual void put(double value) = 0;
-protected:
- PVDouble(PVStructure *parent,ScalarConstPtr scalar)
- : PVScalar(parent,scalar) {}
-private:
-};
-
-class PVString : public PVScalar {
-public:
- virtual ~PVString();
- virtual String get() = 0;
- virtual void put(String value) = 0;
+ virtual ~PVString() {}
protected:
PVString(PVStructure *parent,ScalarConstPtr scalar)
- : PVScalar(parent,scalar) {}
-private:
+ : PVScalarValue<String>(parent,scalar) {}
};
-PVArray and Extensions
+PVArray and Extensions
PVArray is the base interface for
all the other PV Array interfaces. It extends PVField and provides the
@@ -1461,17 +1439,9 @@ public:
bool isCapacityMutable() ;
void setCapacityMutable(bool isMutable);
virtual void setCapacity(int capacity) = 0;
- virtual void serialize(ByteBuffer *pbuffer,
- SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,
- DeserializableControl *pflusher) = 0;
- virtual void serialize(ByteBuffer *pbuffer,
- SerializableControl *pflusher, int offset, int count) = 0;
protected:
PVArray(PVStructure *parent,FieldConstPtr field);
void setCapacityLength(int capacity,int length);
-private:
- class PVArrayPvt * pImpl;
};
The interface for each array type has get and put methods which have the same arguments except for the data type. For example PVDoubleArray is:
-class DoubleArrayData {
+template<typename T>
+class PVArrayData {
public:
- DoubleArrayData(){}
- ~DoubleArrayData(){};
- DoubleArray data;
+ typedef std::tr1::shared_ptr<PVArrayData> shared_pointer;
+ typedef std::tr1::shared_ptr<const PVArrayData> const_shared_pointer;
+
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+
+ pointer data;
int offset;
};
-class PVDoubleArray : public PVScalarArray {
+
+class PVScalarArray : public PVArray {
public:
- virtual ~PVDoubleArray();
- virtual void setCapacity(int capacity) = 0;
- virtual int get(int offset, int length, DoubleArrayData *data) = 0;
- virtual int put(int offset,int length, DoubleArray from, int fromOffset) = 0;
- virtual void shareData(DoubleArray value,int capacity,int length) = 0;
- virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0;
+ typedef std::tr1::shared_ptr<PVScalarArray> shared_pointer;
+ typedef std::tr1::shared_ptr<const PVScalarArray> const_shared_pointer;
+
+ virtual ~PVScalarArray();
+ ScalarArrayConstPtr getScalarArray() ;
+
protected:
- PVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalar);
+ PVScalarArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
private:
-};
+};
+template<typename T>
+class PVValueArray : public PVScalarArray {
+public:
+ typedef std::tr1::shared_ptr<PVValueArray> shared_pointer;
+ typedef std::tr1::shared_ptr<const PVValueArray> const_shared_pointer;
+
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef PVArrayData<T> ArrayDataType;
+
+ virtual ~PVValueArray() {}
+ virtual int get(int offset, int length, ArrayDataType *data) = 0;
+ virtual int put(int offset,int length, pointer from, int fromOffset) = 0;
+ virtual void shareData(pointer value,int capacity,int length) = 0;
+protected:
+ PVValueArray(PVStructure *parent,ScalarArrayConstPtr scalar)
+ : PVScalarArray(parent,scalar) {}
+private:
+};
+typedef PVArrayData<bool> BooleanArrayData;
+typedef PVValueArray<bool> PVBooleanArray;
+
+typedef PVArrayData<int8> ByteArrayData;
+typedef PVValueArray<int8> PVByteArray;
+
+typedef PVArrayData<int16> ShortArrayData;
+typedef PVValueArray<int16> PVShortArray;
+
+typedef PVArrayData<int32> IntArrayData;
+typedef PVValueArray<int32> PVIntArray;
+
+typedef PVArrayData<int64> LongArrayData;
+typedef PVValueArray<int64> PVLongArray;
+
+
+typedef PVArrayData<float> FloatArrayData;
+typedef PVValueArray<float> PVFloatArray;
+
+typedef PVArrayData<double> DoubleArrayData;
+typedef PVValueArray<double> PVDoubleArray;
+
+typedef PVArrayData<String> StringArrayData;
+typedef PVValueArray<String> PVStringArray;
Get "exposes" it's internal array by setting data.data and data.offset. The caller is responsible for copying the array elements. This violates the @@ -1580,189 +1600,13 @@ that directly access the internal data array of a PVArray. This can be required for minimizing CPU overhead. In this case it is the applications responsibility to coordinate access to the array.
-class PVScalarArray : public PVArray {
-public:
- virtual ~PVScalarArray();
- ScalarArrayConstPtr getScalarArray() ;
- virtual void setCapacity(int capacity) = 0;
- virtual void serialize(ByteBuffer *pbuffer,
- SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,
- DeserializableControl *pflusher) = 0;
- virtual void serialize(ByteBuffer *pbuffer,
- SerializableControl *pflusher, int offset, int count) = 0;
-protected:
- PVScalarrray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
-private:
-};
-
-class BooleanArrayData {
-public:
- BooleanArray data;
- int offset;
-};
-
-class PVBooleanArray : public PVScalarArray {
-public:
- virtual ~PVBooleanArray();
- virtual void setCapacity(int capacity) = 0;
- virtual int get(int offset, int length, BooleanArrayData *data) = 0;
- virtual int put(int offset,int length, BooleanArray from, int fromOffset) = 0;
- virtual void shareData(BooleanArray value,int capacity,int length) = 0;
- virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0;
-protected:
- PVBooleanArrayclass ByteArrayData {
-public:
- ByteArray data;
- int offset;
-};
-
-class PVByteArray : public PVScalarArray {
-public:
- virtual ~PVByteArray();
- virtual void setCapacity(int capacity) = 0;
- virtual int get(int offset, int length, ByteArrayData *data) = 0;
- virtual int put(int offset,int length, ByteArray from, int fromOffset) = 0;
- virtual void shareData(ByteArray value,int capacity,int length) = 0;
- virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0;
-protected:
- PVByteArray(PVStructure *parent,ScalarArrayConstPtr scalar);
-private:
-};
-
-class ShortArrayData {
-public:
- ShortArray data;
- int offset;
-};
-
-class PVShortArray : public PVScalarArray {
-public:
- virtual ~PVShortArray();
- virtual void setCapacity(int capacity) = 0;
- virtual int get(int offset, int length, ShortArrayData *data) = 0;
- virtual int put(int offset,int length, ShortArray from, int fromOffset) = 0;
- virtual void shareData(ShortArray value,int capacity,int length) = 0;
- virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0;
-protected:
- PVShortArray(PVStructure *parent,ScalarArrayConstPtr scalar);
-private:
-};
-
-
-class IntArrayData {
-public:
- IntArray data;
- int offset;
-};
-
-class PVIntArray : public PVScalarArray {
-public:
- virtual ~PVIntArray();
- virtual void setCapacity(int capacity) = 0;
- virtual int get(int offset, int length, IntArrayData *data) = 0;
- virtual int put(int offset,int length, IntArray from, int fromOffset)= 0;
- virtual void shareData(IntArray value,int capacity,int length)= 0;
- virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher)= 0;
-protected:
- PVIntArray(PVStructure *parent,ScalarArrayConstPtr scalar);
-private:
-};
-
-class LongArrayData {
-public:
- LongArray data;
- int offset;
-};
-
-class PVLongArray : public PVScalarArray {
-public:
- virtual ~PVLongArray();
- virtual void setCapacity(int capacity) = 0;
- virtual int get(int offset, int length, LongArrayData *data) = 0;
- virtual int put(int offset,int length, LongArray from, int fromOffset)= 0;
- virtual void shareData(LongArray value,int capacity,int length)= 0;
- virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher)= 0;
-protected:
- PVLongArray(PVStructure *parent,ScalarArrayConstPtr scalar);
-private:
-};
-
-class FloatArrayData {
-public:
- FloatArray data;
- int offset;
-};
-
-class PVFloatArray : public PVScalarArray {
-public:
- virtual ~PVFloatArray();
- virtual void setCapacity(int capacity) = 0;
- virtual int get(int offset, int length, FloatArrayData *data) = 0;
- virtual int put(int offset,int length, FloatArray from, int fromOffset)= 0;
- virtual void shareData(FloatArray value,int capacity,int length)= 0;
- virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher)= 0;
-protected:
- PVFloatArray(PVStructure *parent,ScalarArrayConstPtr scalar);
-private:
-};
-
-
-class DoubleArrayData {
-public:
- DoubleArrayData(){}
- ~DoubleArrayData(){};
- DoubleArray data;
- int offset;
-};
-
-class PVDoubleArray : public PVScalarArray {
-public:
- virtual ~PVDoubleArray();
- virtual void setCapacity(int capacity) = 0;
- virtual int get(int offset, int length, DoubleArrayData *data) = 0;
- virtual int put(int offset,int length, DoubleArray from, int fromOffset) = 0;
- virtual void shareData(DoubleArray value,int capacity,int length) = 0;
- virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0;
-protected:
- PVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalar);
-private:
-};
-
-class StringArrayData {
-public:
- StringArray data;
- int offset;
-};
-
-class PVStringArray : public PVScalarArray {
-public:
- virtual ~PVStringArray();
- virtual void setCapacity(int capacity) = 0;
- virtual int get(int offset, int length, StringArrayData *data) = 0;
- virtual int put(int offset,int length, StringArray from, int fromOffset)= 0;
- virtual void shareData(StringArray value,int capacity,int length)= 0;
- virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
- virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher)= 0;
-protected:
- PVStringArray(PVStructure *parent,ScalarArrayConstPtr scalar);
-private:
-};
-
-The interface for a structure is:
class PVStructure : public PVField,public BitSetSerializable {
public:
- virtual ~PVStructure();
+
+};virtual ~PVStructure();
StructureConstPtr getStructure();
PVFieldPtrArray getPVFields();
PVField *getSubField(String fieldName);
@@ -1785,23 +1629,19 @@ public:
String getExtendsStructureName();
bool putExtendsStructureName(
String extendsStructureName);
- virtual bool operator==(PVField &pv) ;
- virtual bool operator!=(PVField &pv) ;
virtual void serialize(
- ByteBuffer *pbuffer,SerializableControl *pflusher) ;
+ ByteBuffer *pbuffer,SerializableControl *pflusher) const;
virtual void deserialize(
ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void serialize(ByteBuffer *pbuffer,
- SerializableControl *pflusher, int offset, int count) ;
- virtual void serialize(ByteBuffer *pbuffer,
- SerializableControl *pflusher,BitSet *pbitSet) ;
+ SerializableControl *pflusher,BitSet *pbitSet) const;
virtual void deserialize(ByteBuffer *pbuffer,
DeserializableControl*pflusher,BitSet *pbitSet);
-protected:
PVStructure(PVStructure *parent,StructureConstPtr structure);
- PVStructure(PVStructure *parent,StructureConstPtr structure,PVFieldPtrArray pvFields);
-private:
- class PVStructurePvt * pImpl;
+ PVStructure(
+ PVStructure *parent,
+ StructureConstPtr structure,
+ PVFieldPtrArray pvFields);
};
where
@@ -1871,7 +1711,7 @@ private:The interface for an array of structures is:
class StructureArrayData {
@@ -1882,9 +1722,8 @@ public:
class PVStructureArray : public PVArray {
public:
- virtual ~PVStructureArray();
+ virtual ~PVStructureArray() {}
virtual StructureArrayConstPtr getStructureArray() = 0;
- virtual void setCapacity(int capacity) = 0;
virtual int append(int number) = 0;
virtual bool remove(int offset,int number) = 0;
virtual void compress() = 0;
@@ -1893,16 +1732,9 @@ public:
virtual int put(int offset,int length,
PVStructurePtrArray from, int fromOffset) = 0;
virtual void shareData( PVStructurePtrArray value,int capacity,int length) = 0;
- virtual void serialize(ByteBuffer *pbuffer,
- SerializableControl *pflusher) = 0 ;
- virtual void deserialize(ByteBuffer *buffer,
- DeserializableControl *pflusher) = 0;
- virtual void serialize(ByteBuffer *pbuffer,
- SerializableControl *pflusher, int offset, int count) = 0;
protected:
PVStructureArray(PVStructure *parent,
StructureArrayConstPtr structureArray);
-private:
};
where
@@ -1925,25 +1757,6 @@ private:The other methods are similar to the methods for other array types.
-Important Note: Code that calls put must be aware of the fact that -introsection interfaces are shared. When creating array elements the shared -introspection interface must be used. The following shows an example:
-void put(PVStructure* powerSupplyArrayStruct)
-{
- PVStructurePtrArray structureArray = new PVStructurePtr[3];
- StructureConstPtr structure =
- powerSupplyArray->getStructureArray()->getStructure();
- structure->incReferenceCount();
- structureArray[0] = pvDataCreate->createPVStructure(0,structure);
- structure->incReferenceCount();
- structureArray[1] = pvDataCreate->createPVStructure(0,structure);
- structure->incReferenceCount();
- structureArray[2] = pvDataCreate->createPVStructure(0,structure);
- powerSupplyArray->put(0,3,structureArray,0);
-}
-
-Note that incReferenceCount is called before each element is created.
-PVDataCreate is an interface that provides methods that create PVField @@ -1972,7 +1785,7 @@ public: PVStructure *createPVStructure(PVStructure *parent, String fieldName,int numberFields,FieldConstPtrArray fields); PVStructure *createPVStructure(PVStructure *parent, - String fieldName,int numberFields,PVFieldPtrArray pvFields); + String fieldName,int numberFields,PVFieldPtrArray pvFields); PVStructure *createPVStructure(PVStructure *parent, String fieldName,PVStructure *structToClone); protected: @@ -2054,9 +1867,9 @@ public: PVStructure* structureArray(PVStructure *parent, String fieldName,StructureConstPtr structure,String properties); PVStructure * enumerated(PVStructure *parent, - String fieldName,StringArray choices); + String fieldName,StringArray choices, int number); PVStructure * enumerated(PVStructure *parent, - String fieldName,StringArray choices, String properties); + String fieldName,StringArray choices, int number, String properties); PVScalar * scalarValue(PVStructure *parent,ScalarType type); PVStructure * scalarValue(PVStructure *parent, ScalarType type,String properties); @@ -2118,12 +1931,34 @@ Thus the source and target share the same primitive array.
class Convert : NoDefaultMethods {
+bool operator==(PVField&, PVField&);
+
+static inline bool operator!=(PVField& a, PVField& b)
+{return !(a==b);}
+
+bool operator==(const Field&, const Field&);
+bool operator==(const Scalar&, const Scalar&);
+bool operator==(const ScalarArray&, const ScalarArray&);
+bool operator==(const Structure&, const Structure&);
+bool operator==(const StructureArray&, const StructureArray&);
+
+static inline bool operator!=(const Field& a, const Field& b)
+{return !(a==b);}
+static inline bool operator!=(const Scalar& a, const Scalar& b)
+{return !(a==b);}
+static inline bool operator!=(const ScalarArray& a, const ScalarArray& b)
+{return !(a==b);}
+static inline bool operator!=(const Structure& a, const Structure& b)
+{return !(a==b);}
+static inline bool operator!=(const StructureArray& a, const StructureArray& b)
+{return !(a==b);}
+
+class Convert : NoDefaultMethods {
public:
Convert();
~Convert();
void getFullName(StringBuilder buf,PVField *pvField);
- bool equals(PVField *a,PVField *b);
+ bool equals(PVField &a,PVField &b);
void getString(StringBuilder buf,PVField * pvField,int indentLevel);
void getString(StringBuilder buf,PVField *pvField);
void fromString(PVScalar *pv, String from);
@@ -2156,11 +1991,11 @@ public:
double toDouble(PVScalar *pv);
String toString(PVScalar *pv);
void fromByte(PVScalar *pv,int8 from);
- void fromShort(PVScalar *pv,int16 from);
- void fromInt(PVScalar *pv, int32 from);
- void fromLong(PVScalar *pv, int64 from);
- void fromFloat(PVScalar* pv, float from);
- void fromDouble(PVScalar *pv, double from);
+ void fromShort(PVScalar *pv,int16 from);
+ void fromInt(PVScalar *pv, int32 from);
+ void fromLong(PVScalar *pv, int64 from);
+ void fromFloat(PVScalar* pv, float from);
+ void fromDouble(PVScalar *pv, double from);
int toByteArray(PVScalarArray *pv, int offset, int length,
ByteArray to, int toOffset);
int toShortArray(PVScalarArray *pv, int offset, int length,
@@ -2185,7 +2020,7 @@ public:
FloatArray from, int fromOffset);
int fromDoubleArray(PVScalarArray *pv, int offset, int length,
DoubleArray from, int fromOffset);
- void newLine(StringBuilder buf, int indentLevel);
+ void newLine(StringBuilder buf, int indentLevel);
};
extern Convert * getConvert();
@@ -2199,8 +2034,7 @@ for code that implements toString It
generates a newline and inserts blanks at the beginning of the newline.
-Namespace, Typedefs, and Memory
-Management
+Namespace and Memory Management
Namespace
@@ -2210,61 +2044,9 @@ Management
// ...
}}
-As described above pvType.h provides C++ typdefs for the pvData primitive -types.
- -File pvInterspect.h, which is described in the next section has the -typedefs:
-typedef Field const * FieldConstPtr; -typedef FieldConstPtr * FieldConstPtrArray; -typedef Scalar const * ScalarConstPtr; -typedef ScalarArray const * ScalarArrayConstPtr; -typedef Structure const * StructureConstPtr; -typedef StructureArray const * StructureArrayConstPtr;- -
These are definitions for introspection objects. All introspecton objects -are immutable and always accessed via pointers.
- -File pvData.h has the typedefs:
-typedef std::map<String,PVScalar * > PVScalarMap; -typedef PVScalarMap::const_iterator PVScalarMapIter; -typedef PVStructure * PVStructurePtr; -typedef PVStructurePtr* PVStructurePtrArray; -typedef PVField* PVFieldPtr; -typedef PVFieldPtr * PVFieldPtrArray; -typedef bool * BooleanArray; -typedef int8 * ByteArray; -typedef int16 * ShortArray; -typedef int32 * IntArray; -typedef int64 * LongArray; -typedef float * FloatArray; -typedef double * DoubleArray; -typedef String * StringArray;- -
where
-Any class that does not want the compiler to generate default methods can privately extend the following class which is defined in file @@ -2280,27 +2062,12 @@ private: NoDefaultMethods & operator=(const NoDefaultMethods &); }; -
Introspection objects are meant to be shared. The constructors and -destructors are all private or protected so that an introspection object can -only be created via a call to one of the FieldCreate methods described abofe. -The introspection implementation, together with PVField keeps reference counts -and automatically deletes objects when the reference count goes to 0. Code that -uses introspection objects always accesses introspection objects via pointers -never via references or direct access to the object. When an introspection -interface is created via one of the methods of class FieldCreate the reference -count is set to 1. When any code wants to get an introspection interface from -an existing data object and use it for another data object, i.e. share the -interface, then incReferenceCount MUST be called.
+Introspection objects are meant to be shared. They are all made available +via std::tri::shared_pointer.
-The introspection destructors are all private. When code, normally ~PVField, -is done using an intrispection interface it calls decReferenceCount. If the -field is a structure then it is a recursive call. When the reference count for -a field becomes 0 the field is deleted. Note than user code should never call -decReferenceCount since the destructor for PVField calls it.
- -All PVData data objects must publically extend PVField, which does not allow default methods but does have a virtual destructor. It is expected that each @@ -2313,7 +2080,7 @@ After deletion all pointers to data in the record are invalid. Similarly pvAccess creates and destroys PVData objects and notifies clients before destroying PVData data objects.
-The classes in property, i.e. alarm, timeStamp, display, and control are all meant to be free copied and shared. They can be created on the stack. In most @@ -2324,10 +2091,10 @@ be extended. Thus they can only be created via "new" and must be destroyed via "delete".
Assume that code wants to print two fields from a PVStructure:
Example of creating a scalar field.
PVDataCreate *pvDataCreate = getPVDataCreate();
@@ -2385,10 +2152,10 @@ and a timeStamp and alarm. Do it the easy way.
String("timeStamp,alarm"))
Only fields named "value" have properties. A record can have multiple value fields, which can appear in the top level structure of a record or in a @@ -2428,7 +2195,7 @@ structure powerSupplySimple powerSupplyValueStructure power powerSupplyValueStructure current -
The following field names have special meaning, i.e. support properties for general purpose clients.
@@ -2496,7 +2263,7 @@ examples are: that support the PVData data model. For example a powerSupport record can have fields power, voltage, current that each support the PVData data model. -Except for enumerated, each property has two files: a property.h and a pvProperty.h . For example: timeStamp.h @@ -2525,7 +2292,7 @@ stack. For example the following is permitted:
... } -A timeStamp is represented by the following structure
structure timeStamp @@ -2551,7 +2318,7 @@ that can be attached to a time stamp pvData structure. It provides get and set methods to get/set a TimeStamp as defined by timeStamp.h -timeStamp.h
+timeStamp.h
This provides
extern int32 milliSecPerSec; @@ -2653,7 +2420,7 @@ execute. This is done as follows: endTime.getCurrent(); double time = TimeStamp::diff(endTime,startTime);-pvTimeStamp.h
+pvTimeStamp.h
class PVTimeStamp { public: PVTimeStamp(); @@ -2692,7 +2459,7 @@ public: thrown if not attached to a pvData structure.
An alarm structure is defined as follows:
structure alarm @@ -2714,7 +2481,7 @@ style="font-family: courier;">pvAlarm.h is a class that can be attached to a time stamp pvData structure. It provides get and set methods to get/set a Alarm as defined by alarm.h -alarm.h
+alarm.h
enum AlarmSeverity { noAlarm,minorAlarm,majorAlarm,invalidAlarm }; @@ -2760,7 +2527,7 @@ public:
class PVAlarm {
public:
PVAlarm() : pvSeverity(0),pvMessage(0) {}
@@ -2800,7 +2567,7 @@ public:
if not attached to a pvData structure.
-control
+control
Control information is represented by the following structure
structure control
@@ -2818,7 +2585,7 @@ attached to a time stamp pvData structure. It provides get and set methods to
get/set a Control as defined by control.h
-control.h
+control.h
class Control {
public:
Control();
@@ -2843,7 +2610,7 @@ public:
class PVControl {
public:
PVControl();
@@ -2883,7 +2650,7 @@ public:
thrown if not attached to a pvData structure.
-display
+display
Display information is represented by the following structure
structure display
@@ -2904,7 +2671,7 @@ class that can be attached to a display pvData structure. It provides get and
set methods to get/set a Diaplay as defined by diaplay.h
-display.h
+display.h
class Display {
public:
Display();
@@ -2947,7 +2714,7 @@ public:
class PVDisplay {
public:
PVDisplay()
@@ -2987,7 +2754,7 @@ public:
thrown if not attached to a pvData structure.
-pvEnumerated
+pvEnumerated
An enumerated structure is a structure that has fields:
structure
@@ -3054,7 +2821,7 @@ public:
-PVData Factories
+PVData Factories
Directory factory has code that implements everything described by the files
@@ -3074,25 +2841,13 @@ PVDataCreate and implements getPVDataCreate.
Convert.cpp automatically creates a single instance of Convert and
implements getConvert.
-The following are included by PVDataCreateFactory and implement the
-corresponding class described in pvData.h:
-
There is a large set of files named "DefaultXXX.cpp" that implement each of -the other classes described in pvData.cpp. Each is included and used by -PVDataCreate.
+Other files implement PVData base classes
This package provides utility code:
Note that directory testApp/misc has test code for all the classes in misc. The test code also can be used as examples.
-This is adapted from the java.util.BitSet. bitSet.h is:
class BitSet /*: public Serializable*/ {
@@ -3234,7 +2989,7 @@ private:
A ByteBuffer is used to serialize and deserialize primitive data. File byteBuffer.h is:
@@ -3274,7 +3029,7 @@ private:x
-This class provides coordinates activity between threads. One thread can wait for the event and the other signals the event.
@@ -3306,7 +3061,7 @@ private:File epicsException.h describes:
class BaseException : public std::exception {
@@ -3324,7 +3079,7 @@ private:
x
-Executor
+Executor
An Executor is a thread that can execute commands. The user can request that
a single command be executed.
@@ -3363,7 +3118,7 @@ execute.
nothing is done.
-Linked List
+Linked List
LinkedList implements a double linked list that requires a user to allocate
the nodes. It is more efficent that std::list. linkedList.h is a template that
@@ -3465,7 +3220,7 @@ public:
lock.h is:
class Mutex {
@@ -3514,9 +3269,9 @@ once. This can be implemented as follows:
// initialization
}
-class MessageNode {
public:
String getMessage() const;
@@ -3538,7 +3293,7 @@ public:
int getClearOverrun();
};
-This is for use by code that wants to handle messages without blocking higher priority threads.
@@ -3550,7 +3305,7 @@ higher priority threads.A messageQueue is an interface with public methods:
@@ -3581,7 +3336,7 @@ higher priority threads.Look at miscTest/testMessageQueue.cpp for an example.
-If a class privately extends this class then the compiler can not create any of the following: default constructor, default copy constructror, or default @@ -3600,7 +3355,7 @@ assignment contructor.
NoDefaultMethods & operator=(const NoDefaultMethods &); }; -A PVField extends Requester. Requester is present so that when database errors are found there is someplace to send a message.
@@ -3630,7 +3385,7 @@ public:This is a helper class for serialization, which is required for sending and receiving pvData over the nerwork.
@@ -3701,7 +3456,7 @@ properly implemented.x
-This is a facility that allows a class to report how many objects of that @@ -3736,7 +3491,7 @@ public: static inline CDRNode* getNode(CDRNodeInstance *inst); -
Status provides a way to pass status back to client code:
class Status : public epics::pvData::Serializable {
@@ -3792,9 +3547,9 @@ static inline CDRNode* getNode(CDRNodeInstance *inst);
status optimization.
-enum ThreadPriority {
lowestPriority,
lowerPriority,
@@ -3811,7 +3566,7 @@ public:
static int getEpicsPriority(ThreadPriority threadPriority);
};
-class Runnable {
public:
virtual void run() = 0;
@@ -3858,7 +3613,7 @@ exception is thrown if run remains active when delete is called.
TimeFunction is a facility that measures the average number of seconds a function call requires. When timeCall is called, it calls function in a loop. @@ -3900,7 +3655,7 @@ long a function takes. It has the single method:
one second to call it ntimes. -This provides a general purpose timer. It allows a user callback to be called after a delay or periodically.
@@ -3975,7 +3730,7 @@ be used to schedule multiple callbacks. It has the methods:This provides a queue which has an immutable capacity. When the queue is full the user code is expected to keep using the current element until a new @@ -4057,10 +3812,10 @@ public: }
The following is also provided:
class BitSetUtil : private NoDefaultMethods {
@@ -4089,7 +3844,7 @@ currently has only one method:
entire structures if the structure offset bit is set.
-MultiChoice
+MultiChoice
MultiChoice defines an array of strings and a bit set that selects an
arbitrary set of the choices. This will be implemented if the java version is
@@ -4097,7 +3852,7 @@ accepted.
NOT DONE
-License Agreement
+License Agreement
Copyright (c) 2008 Martin R. Kraimer
Copyright (c) 2007 Control System Laboratory,
diff --git a/pvDataApp/monitor/monitor.h b/pvDataApp/monitor/monitor.h
index 248ac72..b5a3bc2 100644
--- a/pvDataApp/monitor/monitor.h
+++ b/pvDataApp/monitor/monitor.h
@@ -63,8 +63,8 @@ namespace epics { namespace pvData {
virtual Status stop() = 0;
/**
* If monitor has occurred return data.
- * @return monitorElement for modified data on null
- * if no monitors have occurred.
+ * @return monitorElement for modified data.
+ * Must call get to determine if data is available.
*/
virtual MonitorElement::shared_pointer poll() = 0;
/**
@@ -72,7 +72,7 @@ namespace epics { namespace pvData {
* @param monitorElement
*/
virtual void release(
- MonitorElement::shared_pointer& monitorElement) = 0;
+ MonitorElement::shared_pointer monitorElement) = 0;
};
@@ -92,18 +92,18 @@ namespace epics { namespace pvData {
* @param structure The structure defining the data.
*/
virtual void monitorConnect(const Status &status,
- Monitor::shared_pointer& monitor, StructureConstPtr& structure) = 0;
+ Monitor &monitor, StructureConstPtr structure) = 0;
/**
* A monitor event has occurred.
* The requester must call Monitor.poll to get data.
* @param monitor The monitor.
*/
- virtual void monitorEvent(Monitor::shared_pointer& monitor) = 0;
+ virtual void monitorEvent(Monitor &monitor) = 0;
/**
* The data source is no longer available.
* @param monitor The monitor.
*/
- virtual void unlisten(Monitor::shared_pointer& monitor) = 0;
+ virtual void unlisten(Monitor &monitor) = 0;
};
}}
diff --git a/pvDataApp/monitor/monitorQueue.cpp b/pvDataApp/monitor/monitorQueue.cpp
index d135600..c8e6164 100644
--- a/pvDataApp/monitor/monitorQueue.cpp
+++ b/pvDataApp/monitor/monitorQueue.cpp
@@ -67,7 +67,8 @@ MonitorQueueElement *MonitorElementImpl::getQueueElement()
MonitorQueue::MonitorQueue(PVStructure::shared_pointer* structures,int number)
: number(number),
structures(structures),
- queue(0)
+ queue(0),
+ nullElement(MonitorElement::shared_pointer())
{
if(number<2) {
throw std::logic_error(String("queueSize must be >=2"));
@@ -127,7 +128,7 @@ MonitorElement::shared_pointer MonitorQueue::getFree()
{
MonitorQueueElement *queueElement = queue->getFree();
- if(queueElement==0) return MonitorElement::shared_pointer();
+ if(queueElement==0) return nullElement;
return *queueElement->getObject();
}
@@ -140,7 +141,7 @@ void MonitorQueue::setUsed(MonitorElement::shared_pointer element)
MonitorElement::shared_pointer MonitorQueue::getUsed()
{
MonitorQueueElement *queueElement = queue->getUsed();
- if(queueElement==0) return MonitorElement::shared_pointer();
+ if(queueElement==0) return nullElement;
return *queueElement->getObject();
}
diff --git a/pvDataApp/monitor/monitorQueue.h b/pvDataApp/monitor/monitorQueue.h
index 70693c7..749fda8 100644
--- a/pvDataApp/monitor/monitorQueue.h
+++ b/pvDataApp/monitor/monitorQueue.h
@@ -36,6 +36,7 @@ private:
int number;
PVStructure::shared_pointer* structures;
Queue *queue;
+ MonitorElement::shared_pointer nullElement;
};
}}
diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h
index ae8fca4..31b0b79 100644
--- a/pvDataApp/pv/pvData.h
+++ b/pvDataApp/pv/pvData.h
@@ -251,7 +251,10 @@ public:
virtual void deserialize(ByteBuffer *pbuffer,
DeserializableControl*pflusher,BitSet *pbitSet);
PVStructure(PVStructure *parent,StructureConstPtr structure);
- PVStructure(PVStructure *parent,StructureConstPtr structure,PVFieldPtrArray pvFields);
+ PVStructure(
+ PVStructure *parent,
+ StructureConstPtr structure,
+ PVFieldPtrArray pvFields);
private:
void setParentPvt(PVField *pvField,PVStructure *parent);
class PVStructurePvt * pImpl;
diff --git a/pvDataApp/pv/standardPVField.h b/pvDataApp/pv/standardPVField.h
index 4339552..e6cafda 100644
--- a/pvDataApp/pv/standardPVField.h
+++ b/pvDataApp/pv/standardPVField.h
@@ -35,14 +35,16 @@ public:
PVScalar * scalarValue(PVStructure *parent,ScalarType type);
PVStructure * scalarValue(PVStructure *parent,
ScalarType type,String properties);
- PVScalarArray * scalarArrayValue(PVStructure *parent,ScalarType elementType);
+ PVScalarArray * scalarArrayValue(
+ PVStructure *parent,ScalarType elementType);
PVStructure * scalarArrayValue(PVStructure *parent,
ScalarType elementType, String properties);
PVStructureArray * structureArrayValue(PVStructure *parent,
StructureConstPtr structure);
PVStructure * structureArrayValue(PVStructure *parent,
StructureConstPtr structure,String properties);
- PVStructure * enumeratedValue(PVStructure *parent,StringArray choices,int number);
+ PVStructure * enumeratedValue(
+ PVStructure *parent,StringArray choices,int number);
PVStructure * enumeratedValue(PVStructure *parent,
StringArray choices,int number, String properties);
PVStructure * alarm(PVStructure *parent);