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 @@

EPICS pvDataCPP
-2011.04.14

+2011.05.11

TODO

-
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 // ... }}
-

typedefs

+

Memory Managemment

-

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

-
-
PVScalarMap and PVScalarMapIter
-
A map and iterator that maps field names to PVScalars.
-
PVStructurePtr
-
A pointer to a PVStructure.
-
PVStructurePtrArray
-
A pointer to PVStructurePtr[], e. g. an array of pointers to a - PVStructure.
-
PVFieldPtr
-
A pointer to a PVField
-
PVFieldPtrArray
-
A pointer to a PVFieldPtr[], e. g. an array of pointers to a - PVField.
-
BooleanArray, ByteArray, ..., - StringArray
-
An array of the specified type NOT a pointer to the type.
-
- -

Memory Managemment

- -

NoDefaultMethods

+

NoDefaultMethods

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 &); }; -

PVData introspection objects

+

PVData introspection objects

-

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.

- -

PVData data objects

+

PVData data objects

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.

-

Other code in this project

+

Other code in this project

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".


-

Examples

+

Examples


-

Accessing PVData

+

Accessing PVData

Assume that code wants to print two fields from a PVStructure:

@@ -2355,7 +2122,7 @@ be extended. Thus they can only be created via "new" and must be destroyed via timeStampPV->toString(buf); } -

Creating PVData

+

Creating PVData

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"))

-

Property

+

Property


-

Definition of Property

+

Definition of Property

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 -

Standard Properties

+

Standard Properties

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.

-

Overview of Property Support

+

Overview of Property Support

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:

... } -

timeStamp

+

timeStamp

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. 
 
-

alarm

+

alarm

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:
     
Set the severity.
-

pvAlarm.h

+

pvAlarm.h

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:
     
Set the high limit.
-

pvControl.h

+

pvControl.h

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:
     
Set the units.
-

pvDisplay.h

+

pvDisplay.h

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:

-
-
PVField.cpp
-
PVScalar.cpp
-
PVArray.cpp
-
PVScalarArray.cpp
-
PVStructure.cpp
-
- -

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


-

Miscellanous Classes

+

Miscellanous Classes


-

Overview

+

Overview

This package provides utility code:

@@ -3140,7 +2895,7 @@ PVDataCreate.

Note that directory testApp/misc has test code for all the classes in misc. The test code also can be used as examples.

-

BitSet

+

BitSet

This is adapted from the java.util.BitSet. bitSet.h is:

class BitSet /*: public Serializable*/ {
@@ -3234,7 +2989,7 @@ private:
     
Show the current values of the bitSet.
-

ByteBuffer

+

ByteBuffer

A ByteBuffer is used to serialize and deserialize primitive data. File byteBuffer.h is:

@@ -3274,7 +3029,7 @@ private:

x

-

Event

+

Event

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:
returns (false,true) if the event is (empty,full)
-

Exception

+

Exception

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:

Does the list contain the specified object?
-

Lock and Mutex

+

Lock and Mutex

lock.h is:

class Mutex  {
@@ -3514,9 +3269,9 @@ once. This can be implemented as follows:

// initialization }
-

Message Queue

+

Message Queue

-

Definitions

+

Definitions

class MessageNode {
 public:
     String getMessage() const;
@@ -3538,7 +3293,7 @@ public:
     int getClearOverrun();
 };
-

MessageQueue

+

MessageQueue

This is for use by code that wants to handle messages without blocking higher priority threads.

@@ -3550,7 +3305,7 @@ higher priority threads.

getMessageType
The message type.
setMessageNull
-
Set the message to be a null string.
+
Set the message to be a null string.

A messageQueue is an interface with public methods:

@@ -3581,7 +3336,7 @@ higher priority threads.

Look at miscTest/testMessageQueue.cpp for an example.

-

NoDefaultMethods

+

NoDefaultMethods

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 &); };
-

Requester

+

Requester

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:
Gives a message to the requester.
-

Serialize

+

Serialize

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

-

CDRMonitor - Monitor and Report +

CDRMonitor - Monitor and Report Construction and Destruction

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

+

Status

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. -

Thread

+

Thread

-

ThreadPriority

+

ThreadPriority

enum ThreadPriority {
     lowestPriority,
     lowerPriority,
@@ -3811,7 +3566,7 @@ public:
     static int getEpicsPriority(ThreadPriority threadPriority);
 };
-

Thread

+

Thread

class Runnable {
 public:
     virtual void run() = 0;
@@ -3858,7 +3613,7 @@ exception is thrown if run remains active when delete is called. 

Make the current thread sleep for the specified number of seconds.
-

Time Function Call

+

Time Function Call

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. -

Timer

+

Timer

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:

Schedule a periodic callback.
-

Queue

+

Queue

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: }


-

pvMisc

+

pvMisc


-

BitSetUtil

+

BitSetUtil

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);