diff --git a/.hgignore b/.hgignore index e826041..0279e00 100644 --- a/.hgignore +++ b/.hgignore @@ -1,6 +1,7 @@ QtC-pvData.creator.user bin lib +doc include documentation/html ./O.* diff --git a/Doxyfile b/Doxyfile index 2e97659..beb7069 100644 --- a/Doxyfile +++ b/Doxyfile @@ -17,7 +17,7 @@ # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. -PROJECT_NAME = pvData +PROJECT_NAME = pvDataCPP # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or @@ -100,7 +100,7 @@ ALWAYS_DETAILED_SEC = NO # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. -INLINE_INHERITED_MEMB = NO +INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set @@ -459,7 +459,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = pvDataApp +INPUT = include # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp diff --git a/documentation/COPYRIGHT b/documentation/COPYRIGHT deleted file mode 100644 index 7dcbbf7..0000000 --- a/documentation/COPYRIGHT +++ /dev/null @@ -1,7 +0,0 @@ -/**************************************************** -Copyright (c) 2008 All rights reserved -Copyright (c) 2008 Martin R. Kraimer -COSYLAB (Control System Laboratory) - (Cosylab) Ljubljana Slovenia -Copyright 2010 Brookhaven National Laboratory -*************************************************** */ diff --git a/documentation/LICENSE b/documentation/LICENSE deleted file mode 100644 index 5683195..0000000 --- a/documentation/LICENSE +++ /dev/null @@ -1,72 +0,0 @@ -Copyright (c) 2008 Martin R. Kraimer -Copyright (c) 2007 Control System Laboratory, - (COSYLAB) Ljubljana Slovenia -Copyright 2010 Brookhaven National Laboratory - -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -________________________________________________________________________ - -This software is in part copyrighted by the University of Chicago (UofC) - -In no event shall UofC be liable to any party for direct, indirect, -special, incidental, or consequential damages arising out of the use of -this software, its documentation, or any derivatives thereof, even if -UofC has been advised of the possibility of such damage. - -UofC specifically disclaims any warranties, including, but not limited -to, the implied warranties of merchantability, fitness for a particular -purpose, and non-infringement. This software is provided on an "as is" -basis, and UofC has no obligation to provide maintenance, support, -updates, enhancements, or modifications. - -________________________________________________________________________ - -This software is in part copyrighted by the BERLINER SPEICHERRING -GESELLSCHAFT FUER SYNCHROTRONSTRAHLUNG M.B.H. (BESSY), BERLIN, GERMANY. - -In no event shall BESSY be liable to any party for direct, indirect, -special, incidental, or consequential damages arising out of the use of -this software, its documentation, or any derivatives thereof, even if -BESSY has been advised of the possibility of such damage. - -BESSY specifically disclaims any warranties, including, but not limited -to, the implied warranties of merchantability, fitness for a particular -purpose, and non-infringement. This software is provided on an "as is" -basis, and BESSY has no obligation to provide maintenance, support, -updates, enhancements, or modifications. - -________________________________________________________________________ - -This software is in part copyrighted by the Deutsches Elektronen-Synchroton, - Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY. - -In no event shall DESY be liable to any party for direct, indirect, -special, incidental, or consequential damages arising out of the use of -this software, its documentation, or any derivatives thereof, even if -DESY has been advised of the possibility of such damage. - -DESY specifically disclaims any warranties, including, but not limited -to, the implied warranties of merchantability, fitness for a particular -purpose, and non-infringement. This software is provided on an "as is" -basis, and DESY has no obligation to provide maintenance, support, -updates, enhancements, or modifications. -________________________________________________________________________ diff --git a/documentation/pvDataCpp.html b/documentation/pvDataCpp.html index 2fd2a65..676c241 100644 --- a/documentation/pvDataCpp.html +++ b/documentation/pvDataCpp.html @@ -5,11 +5,23 @@ EPICS pvDataCPP + + + +

EPICS pvDataCPP
-2011.10.26

+2011.12.26

TODO

-
  • License Agreement

  • @@ -176,8 +187,11 @@

    Preface


    -

    This product is available via the open source -license described at the end of this document.

    +

    This product is available via an open source license

    + +

    This is the overview for pvDataCPP. +Doxygen documentation is available at doxygenDoc

    +

    pvData is one of a set of related projects:

    @@ -1913,8 +1927,8 @@ extern PVDataCreate * getPVDataCreate(); class StandardField it has two forms of the methods which create a field, one without properties and one with properties. Again the properties is some combination of alarm, timeStamp, control, display, and valueAlarm. And just -like StandardField there are methods to create thye standard properties. The -meythods are:

    +like StandardField there are methods to create the standard properties. The +methods are:

    class StandardPVField : private NoDefaultMethods {
     public:
         StandardPVField();
    @@ -3952,83 +3966,5 @@ currently has only one method:

    arbitrary set of the choices. This will be implemented if the java version is accepted.

    NOT DONE
    -
    - -

    License Agreement

    -
    -
    Copyright (c) 2008 Martin R. Kraimer
    -Copyright (c) 2007 Control System Laboratory,
    -    (COSYLAB) Ljubljana Slovenia
    -Copyright (c) 2010 Brookhaven National Laboratory
    -
    -
    -Permission is hereby granted, free of charge, to any person
    -obtaining a copy of this software and associated documentation
    -files (the "Software"), to deal in the Software without
    -restriction, including without limitation the rights to use,
    -copy, modify, merge, publish, distribute, sublicense, and/or sell
    -copies of the Software, and to permit persons to whom the
    -Software is furnished to do so, subject to the following
    -conditions:
    -
    -The above copyright notice and this permission notice shall be
    -included in all copies or substantial portions of the Software.
    -
    -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    -OTHER DEALINGS IN THE SOFTWARE.
    -
    -________________________________________________________________________
    -
    -This software is in part copyrighted by Brookhaven National Laboratory(BNL)
    -
    -In no event shall BNL be liable to any party for direct, indirect,
    -special, incidental, or consequential damages arising out of the use of
    -this software, its documentation, or any derivatives thereof, even if
    -BNL has been advised of the possibility of such damage.
    -
    -BNL specifically disclaims any warranties, including, but not limited
    -to, the implied warranties of merchantability, fitness for a particular
    -purpose, and non-infringement.  This software is provided on an "as is"
    -basis, and BNL has no obligation to provide maintenance, support,
    -updates, enhancements, or modifications.
    -
    -________________________________________________________________________
    -
    -This software is in part copyrighted by the BERLINER SPEICHERRING
    -GESELLSCHAFT FUER SYNCHROTRONSTRAHLUNG M.B.H. (BESSY), BERLIN, GERMANY.
    -
    -In no event shall BESSY be liable to any party for direct, indirect,
    -special, incidental, or consequential damages arising out of the use of
    -this software, its documentation, or any derivatives thereof, even if
    -BESSY has been advised of the possibility of such damage.
    -
    -BESSY specifically disclaims any warranties, including, but not limited
    -to, the implied warranties of merchantability, fitness for a particular
    -purpose, and non-infringement.  This software is provided on an "as is"
    -basis, and BESSY has no obligation to provide maintenance, support,
    -updates, enhancements, or modifications.
    -
    -________________________________________________________________________
    -
    -This software is in part copyrighted by the Deutsches Elektronen-Synchroton,
    -    Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
    -
    -In no event shall DESY be liable to any party for direct, indirect,
    -special, incidental, or consequential damages arising out of the use of
    -this software, its documentation, or any derivatives thereof, even if
    -DESY has been advised of the possibility of such damage.
    -
    -DESY specifically disclaims any warranties, including, but not limited
    -to, the implied warranties of merchantability, fitness for a particular
    -purpose, and non-infringement.  This software is provided on an "as is"
    -basis, and DESY has no obligation to provide maintenance, support,
    -updates, enhancements, or modifications.
    -________________________________________________________________________
    diff --git a/pvDataApp/misc/byteBuffer.h b/pvDataApp/misc/byteBuffer.h index 7c05e40..149a912 100644 --- a/pvDataApp/misc/byteBuffer.h +++ b/pvDataApp/misc/byteBuffer.h @@ -164,10 +164,24 @@ inline double swap(double val) #define UNALIGNED_ACCESS true #define ADAPTIVE_ACCESS true #define USE_INLINE_MEMCPY true - + +/** + * This class implements {@code Bytebuffer} that is like the {@code java.nio.ByteBuffer}. + *

    A {@code BitSet} is not safe for multithreaded use without + * external synchronization. + * + * Based on Java implementation. + */ class ByteBuffer { public: + /** + * Constructor. + * + * @param size The number of bytes. + * @param byteOrder The byte order. + * Must be one of EPICS_BYTE_ORDER,EPICS_ENDIAN_LITTLE,EPICS_ENDIAN_BIG, + */ ByteBuffer(uintptr_t size, int byteOrder = EPICS_BYTE_ORDER) : _buffer(0), _size(size), _reverseEndianess(byteOrder != EPICS_BYTE_ORDER), @@ -176,71 +190,120 @@ public: _buffer = (char*)malloc(size); clear(); } - + /** + * Destructor + */ ~ByteBuffer() { if (_buffer) free(_buffer); } - + /** + * Set the byte order. + * + * @param byteOrder The byte order. + * Must be one of EPICS_BYTE_ORDER,EPICS_ENDIAN_LITTLE,EPICS_ENDIAN_BIG, + */ inline void setEndianess(int byteOrder) { _reverseEndianess = (byteOrder != EPICS_BYTE_ORDER); _reverseFloatEndianess = (byteOrder != EPICS_FLOAT_WORD_ORDER); } - + /** + * Get the raw buffer data. + * @return the raw buffer data. + */ inline const char* getBuffer() { return _buffer; } - + /** + * Makes a buffer ready for a new sequence of channel-read or relative put operations: + * It sets the limit to the capacity and the position to zero. + */ inline void clear() { _position = _buffer; _limit = _buffer + _size; } - + /** + * Makes a buffer ready for a new sequence of channel-write or relative get operations: + * It sets the limit to the current position and then sets the position to zero. + */ inline void flip() { _limit = _position; _position = _buffer; } - + /** + * Makes a buffer ready for re-reading the data that it already contains: + * It leaves the limit unchanged and sets the position to zero. + */ inline void rewind() { _position = _buffer; } - + /** + * Returns the current position. + * @return The current position in the raw data. + */ inline uintptr_t getPosition() { return (((uintptr_t)(const void *)_position) - ((uintptr_t)(const void *)_buffer)); } - + /** + * Sets the buffer position. + * If the mark is defined and larger than the new position then it is discarded. + * + * @param pos The offset into the raw buffer. + * The new position value; must be no larger than the current limit + */ inline void setPosition(uintptr_t pos) { _position = _buffer + pos; } - + /** + * Returns this buffer's limit. + * + * @return The offset into the raw buffer. + */ inline uintptr_t getLimit() { return (((uintptr_t)(const void *)_limit) - ((uintptr_t)(const void *)_buffer)); } - + /** + * Sets this buffer's limit. + * If the position is larger than the new limit then it is set to the new limit.s + * If the mark is defined and larger than the new limit then it is discarded. + * + * @param limit The new position value; + * must be no larger than the current limit + */ inline void setLimit(uintptr_t limit) { _limit = _buffer + limit; } - + /** + * Returns the number of elements between the current position and the limit. + * + * @return The number of elements remaining in this buffer. + */ inline uintptr_t getRemaining() { return (((uintptr_t)(const void *)_limit) - ((uintptr_t)(const void *)_position)); } - + /** + * Returns The size, i.e. capacity of the raw data buffer in bytes. + * + * @return The size of the raw data buffer. + */ inline uintptr_t getSize() { return _size; } - - - - + + /** + * Put the value into the raw buffer as a byte stream in the current byte order. + * + * @param value The value to be put into the byte buffer. + */ template inline void put(T value) { @@ -258,7 +321,7 @@ public: if (UNALIGNED_ACCESS) { - // NOTE: some CPU handle unaligned access preety good (e.g. x86) + // NOTE: some CPU handle unaligned access pretty good (e.g. x86) *((T*)_position) = value; _position += sizeof(T); } @@ -289,9 +352,12 @@ public: } } - - - + /** + * Put the value into the raw buffer at the specified index as a byte stream in the current byte order. + * + * @param index Offset in the byte buffer. + * @param value The value to be put into the byte buffer. + */ template inline void put(uintptr_t index, T value) { @@ -337,10 +403,12 @@ public: } } - - - - + /** + * Get the new object from the byte buffer. The item MUST have type {@code T}. + * The position is adjusted based on the type. + * + * @return The object. + */ template inline T get() { @@ -393,9 +461,14 @@ public: return value; } - - - + /** + * Get the new object from the byte buffer at the specified index. + * The item MUST have type {@code T}. + * The position is adjusted based on the type. + * + * @param index The location in the byte buffer. + * @return The object. + */ template inline T get(uintptr_t index) { @@ -444,23 +517,39 @@ public: return value; } - - - - + /** + * Put a sub-array of bytes into the byte buffer. + * The position is increased by the count. + * + * @param src The source array. + * @param offset The starting position within src. + * @param count The number of bytes to put into the byte buffer, + */ inline void put(const char* src, uintptr_t src_offset, uintptr_t count) { //if(count>getRemaining()) THROW_BASE_EXCEPTION("buffer overflow"); memcpy(_position, src + src_offset, count); _position += count; } - - + /** + * Get a sub-array of bytes from the byte buffer. + * The position is increased by the count. + * + * @param dest The destination array. + * @param offset The starting position within src. + * @param count The number of bytes to put into the byte buffer, + */ inline void get(char* dest, uintptr_t dest_offset, uintptr_t count) { //if(count>getRemaining()) THROW_BASE_EXCEPTION("buffer overflow"); memcpy(dest + dest_offset, _position, count); _position += count; } - + /** + * Put an array of type {@code T} into the byte buffer. + * The position is adjusted. + * + * @param values The input array. + * @param count The number of elements. + */ template inline void putArray(T* values, uintptr_t count) { @@ -488,12 +577,13 @@ public: } } } - - - - - - + /** + * Get an array of type {@code T} from the byte buffer. + * The position is adjusted. + * + * @param values The destination array. + * @param count The number of elements. + */ template inline void getArray(T* values, uintptr_t count) { @@ -521,57 +611,209 @@ public: } } } - - + /** + * Is the byte order the EPICS_BYTE_ORDER + * @return (false,true) if (is, is not) the EPICS_BYTE_ORDER + */ template inline bool reverse() { return _reverseEndianess; } - - - - // NOTE: size must be power of 2 + /** + * Adjust position so that it is aligned to the specified size. + * Size MUST be a power of 2. + * @param size The alignment requirement. + */ inline void align(int size) { const uintptr_t k = size - 1; _position = (char*)((((uintptr_t)(const void *)_position) + k) & ~(k)); } - - - - - + /** + * Put a boolean value into the byte buffer. + * + * @param value The value. + */ inline void putBoolean( bool value) { put< int8>(value ? 1 : 0); } + /** + * Put a byte value into the byte buffer. + * + * @param value The value. + */ inline void putByte ( int8 value) { put< int8>(value); } + /** + * Put a short value into the byte buffer. + * + * @param value The value. + */ inline void putShort ( int16 value) { put< int16>(value); } + /** + * Put an int value into the byte buffer. + * + * @param value The value. + */ inline void putInt ( int32 value) { put< int32>(value); } + /** + * Put a long value into the byte buffer. + * + * @param value The value. + */ inline void putLong ( int64 value) { put< int64>(value); } + /** + * Put a float value into the byte buffer. + * + * @param value The value. + */ inline void putFloat ( float value) { put< float>(value); } + /** + * Put a double value into the byte buffer. + * + * @param value The value. + */ inline void putDouble (double value) { put(value); } + /** + * Put a boolean value into the byte buffer at the specified index. + * + * @param index The offset in the byte buffer, + * @param value The value. + */ inline void putBoolean(uintptr_t index, bool value) { put< int8>(index, value); } + /** + * Put a byte value into the byte buffer at the specified index. + * + * @param index The offset in the byte buffer, + * @param value The value. + */ inline void putByte (uintptr_t index, int8 value) { put< int8>(index, value); } + /** + * Put a short value into the byte buffer at the specified index. + * + * @param index The offset in the byte buffer, + * @param value The value. + */ inline void putShort (uintptr_t index, int16 value) { put< int16>(index, value); } + /** + * Put an int value into the byte buffer at the specified index. + * + * @param index The offset in the byte buffer, + * @param value The value. + */ inline void putInt (uintptr_t index, int32 value) { put< int32>(index, value); } + /** + * Put a long value into the byte buffer at the specified index. + * + * @param index The offset in the byte buffer, + * @param value The value. + */ inline void putLong (uintptr_t index, int64 value) { put< int64>(index, value); } + /** + * Put a float value into the byte buffer at the specified index. + * + * @param index The offset in the byte buffer, + * @param value The value. + */ inline void putFloat (uintptr_t index, float value) { put< float>(index, value); } + /** + * Put a double value into the byte buffer at the specified index. + * + * @param index The offset in the byte buffer, + * @param value The value. + */ inline void putDouble (uintptr_t index,double value) { put(index, value); } + /** + * Get a boolean value from the byte buffer. + * + * @return The value. + */ inline bool getBoolean() { return get< int8>() != 0; } + /** + * Get a byte value from the byte buffer. + * + * @return The value. + */ inline int8 getByte () { return get< int8>(); } + /** + * Get a short value from the byte buffer. + * + * @return The value. + */ inline int16 getShort () { return get< int16>(); } + /** + * Get a int value from the byte buffer. + * + * @return The value. + */ inline int32 getInt () { return get< int32>(); } + /** + * Get a long value from the byte buffer. + * + * @return The value. + */ inline int64 getLong () { return get< int64>(); } + /** + * Get a float value from the byte buffer. + * + * @return The value. + */ inline float getFloat () { return get< float>(); } + /** + * Get a double value from the byte buffer. + * + * @return The value. + */ inline double getDouble () { return get(); } + /** + * Get a boolean value from the byte buffer at the specified index. + * + * @param index The offset in the byte buffer. + * @return The value. + */ inline bool getBoolean(uintptr_t index) { return get< int8>(index) != 0; } + /** + * Get a byte value from the byte buffer at the specified index. + * + * @param index The offset in the byte buffer. + * @return The value. + */ inline int8 getByte (uintptr_t index) { return get< int8>(index); } + /** + * Get a short value from the byte buffer at the specified index. + * + * @param index The offset in the byte buffer. + * @return The value. + */ inline int16 getShort (uintptr_t index) { return get< int16>(index); } + /** + * Get an int value from the byte buffer at the specified index. + * + * @param index The offset in the byte buffer. + * @return The value. + */ inline int32 getInt (uintptr_t index) { return get< int32>(index); } + /** + * Get a long value from the byte buffer at the specified index. + * + * @param index The offset in the byte buffer. + * @return The value. + */ inline int64 getLong (uintptr_t index) { return get< int64>(index); } + /** + * Get a float value from the byte buffer at the specified index. + * + * @param index The offset in the byte buffer. + * @return The value. + */ inline float getFloat (uintptr_t index) { return get< float>(index); } + /** + * Get a boolean value from the byte buffer at the specified index. + * + * @param double The offset in the byte buffer. + * @return The value. + */ inline double getDouble (uintptr_t index) { return get(index); } // TODO remove diff --git a/pvDataApp/pv/convert.h b/pvDataApp/pv/convert.h index b5f131c..7bd049a 100644 --- a/pvDataApp/pv/convert.h +++ b/pvDataApp/pv/convert.h @@ -3,6 +3,7 @@ * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvDataCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. + * Author - Marty Kraimer */ #ifndef CONVERT_H #define CONVERT_H @@ -39,74 +40,449 @@ static inline bool operator!=(const StructureArray& a, const StructureArray& b) {return !(a==b);} +/** + * Convert between numeric types, convert any field to a string, + * or convert from a string to a scalar field. + *

    Numeric conversions are between scalar numeric types or between arrays of + * numeric types. It is not possible to convert between a scalar + * and an array. + * Numeric conversions are between types: + * pvByte, pvShort, pvInt, + * pvLong, pvFloat, or pvDouble.

    + * + *

    getString converts any supported type to a String. + * Code that implements a PVField interface can implement + * method toString by calling this method.

    + * + *

    fromString converts a String to a scalar. + * fromStringArray converts an array of String + * to a pvArray, which must have a scaler element type. + * A scalar field is a numeric field or pvBoolean or pvString.

    + *

    All from methods put data into a PVField, e.g. from means where the PVField gets it's data.

    + */ + class Convert : NoDefaultMethods { public: Convert(); ~Convert(); + /** + * Get the full fieldName for the pvField. + * @param builder The builder that will have the result. + * @param pvField The pvField. + */ void getFullName(StringBuilder buf,PVField *pvField); + /** + * Do fields have the same definition. + * + * @param First field + * @param Second field + * @return (false, true) if the fields (are not, are) the same. + */ bool equals(PVField &a,PVField &b); + /** + * Convert a PVField to a string. + * @param buf buffer for the result + * @param pv a PVField to convert to a string. + * If a PVField is a structure or array be prepared for a very long string. + * @param indentLevel indentation level + */ void getString(StringBuilder buf,PVField * pvField,int indentLevel); + /** + * Convert a PVField to a string. + * param buf buffer for the result + * @param pv The PVField to convert to a string. + * If the PVField is a structure or array be prepared for a very long string. + */ void getString(StringBuilder buf,PVField *pvField); + /** + * Convert from an array of String to a PVScalar + * @param pv The PV. + * @param from The array of String value to convert and put into a PV. + * @param fromStartIndex The first element if the array of strings. + * @throws std::logic_error if the array of String does not have a valid values. + */ int fromString(PVStructure *pv, std::vector& from, int fromStartIndex = 0); + /** + * Convert from a String to a PVScalar + * @param pv The PV. + * @param from The String value to convert and put into a PV. + * @throws std::logic_error if the String does not have a valid value. + */ void fromString(PVScalar *pv, String from); + /** + * Convert from a String to a PVScalarArray. + * The String must be a comma separated set of values optionally enclosed in [] + * @param pv The PV. + * @param from The String value to convert and put into a PV. + * @return The number of elements converted. + * @throws std::invalid_argument if the element Type is not a scalar. + * @throws std::logic_error if the String does not have a valid array values. + */ int fromString(PVScalarArray *pv, String from); + /** + * Convert a PVScalarArray from a String array. + * The array element type must be a scalar. + * @param pv The PV. + * @param offset Starting element in a PV. + * @param length The number of elements to transfer. + * @param from The array of values to put into the PV. + * @param fromOffset Starting element in the source array. + * @return The number of elements converted. + * @throws std::invalid_argument if the element Type is not a scalar. + * @throws std::logic_error if the String does not have a valid value. + */ int fromStringArray(PVScalarArray *pv, int offset, int length, StringArray from, int fromOffset); + /** + * Convert a PVScalarArray to a String array. + * @param pv The PV. + * @param offset Starting element in the PV array. + * @param length Number of elements to convert to the string array. + * @param to String array to receive the converted PV data. + * @param toOffset Starting element in the string array. + * @return Number of elements converted. + */ int toStringArray(PVScalarArray *pv, int offset, int length, StringArray to, int toOffset); + /** + * Are from and to valid arguments to copy. + * This first checks of both arguments have the same Type. + * Then calls one of isCopyScalarCompatible, + * isCopyArrayCompatible, or isCopyStructureCompatible. + * @param from The source. + * @param to The destination. + * @return (false,true) is the arguments (are not, are) compatible. + */ bool isCopyCompatible(FieldConstPtr from, FieldConstPtr to); + /** + * Copy from a PVField to another PVField. + * This calls one on copyScalar, copyArray, copyStructure. + * The two arguments must be compatible. + * @param from The source. + * @param to The destination + * @throws std::invalid_argument if the arguments are not compatible. + */ void copy(PVField *from,PVField *to); + /** + * Are from and to valid arguments to copyScalar. + * false will be returned if either argument is not a scalar as defined by Type.isScalar(). + * If both are scalars the return value is true if any of the following are true. + *
      + *
    • Both arguments are numeric.
    • + *
    • Both arguments have the same type.
    • + *
    • Either argument is a string.
    • + *
    + * @param from The introspection interface for the from data. + * @param to The introspection interface for the to data.. + * @return (false,true) If the arguments (are not, are) compatible. + */ bool isCopyScalarCompatible( ScalarConstPtr from, ScalarConstPtr to); + /** + * Copy from a scalar pv to another scalar pv. + * @param from the source. + * @param to the destination. + * @throws std::invalid_argument if the arguments are not compatible. + */ void copyScalar(PVScalar *from, PVScalar *to); + /** + * Are from and to valid arguments to copyArray. + * The results are like isCopyScalarCompatible except that the tests are made on the elementType. + * @param from The from array. + * @param to The to array. + * @return (false,true) If the arguments (are not, are) compatible. + */ bool isCopyScalarArrayCompatible(ScalarArrayConstPtr from, ScalarArrayConstPtr to); + /** + * Convert from a source PV array to a destination PV array. + * @param from The source array. + * @param offset Starting element in the source. + * @param to The destination array. + * @param toOffset Starting element in the array. + * @param length Number of elements to transfer. + * @return Number of elements converted. + * @throws std::invalid_argument if the arguments are not compatible. + */ int copyScalarArray(PVScalarArray *from, int offset, PVScalarArray *to, int toOffset, int length); + /** + * Are from and to valid arguments for copyStructure. + * They are only compatible if they have the same Structure description. + * @param from from structure. + * @param to structure. + * @return (false,true) If the arguments (are not, are) compatible. + */ bool isCopyStructureCompatible( StructureConstPtr from, StructureConstPtr to); + /** + * Copy from a structure pv to another structure pv. + * NOTE: Only compatible nodes are copied. This means: + *
      + *
    • For scalar nodes this means that isCopyScalarCompatible is true.
    • + *
    • For array nodes this means that isCopyArrayCompatible is true.
    • + *
    • For structure nodes this means that isCopyStructureCompatible is true.
    • + *
    • Link nodes are not copied.
    • + *
    + * @param from The source. + * @param to The destination. + * @throws std::invalid_argument if the arguments are not compatible. + */ void copyStructure(PVStructure *from, PVStructure *to); + /** + * Are from and to valid for copyStructureArray. + * @param from The from StructureArray. + * @param to The to StructureArray. + * @return (false,true) If the arguments (are not, are) compatible. + */ bool isCopyStructureArrayCompatible( StructureArrayConstPtr from, StructureArrayConstPtr to); + /** + * Copy from a structure array to another structure array. + * @param from The source array. + * @param to The destination array. + */ void copyStructureArray( PVStructureArray *from, PVStructureArray *to); + /** + * Convert a PV to a . + * @param pv a PV + * @return converted value + */ int8 toByte(PVScalar *pv); + /** + * Convert a PV to a short. + * @param pv a PV + * @return converted value + * @throws std::invalid_argument if the Type is not a numeric scalar + */ int16 toShort(PVScalar *pv); + /** + * Convert a PV to a short. + * @param pv a PV + * @return converted value + * @throws std::invalid_argument if the Type is not a numeric scalar + */ int32 toInt(PVScalar *pv); + /** + * Convert a PV to an int + * @param pv a PV + * @return converted value + * @throws std::invalid_argument if the Type is not a numeric scalar + */ int64 toLong(PVScalar *pv); + /** + * Convert a PV to a float + * @param pv a PV + * @return converted value + * @throws std::invalid_argument if the Type is not a numeric scalar + */ float toFloat(PVScalar *pv); + /** + * Convert a PV to a double + * @param pv a PV + * @return converted value + * @throws std::invalid_argument if the Type is not a numeric scalar + */ double toDouble(PVScalar *pv); + /** + * Convert a PV to a String + * @param pv a PV + * @return converted value + */ String toString(PVScalar *pv); + /** + * Convert a PV from a byte + * @param pv a PV + * @param from value to put into PV + * @throws std::invalid_argument if the Type is not a numeric scalar + */ void fromByte(PVScalar *pv,int8 from); + /** + * Convert a PV from a short + * @param pv a PV + * @param from value to put into PV + * @throws std::invalid_argument if the Type is not a numeric scalar + */ void fromShort(PVScalar *pv,int16 from); + /** + * Convert a PV from an int + * @param pv a PV + * @param from value to put into PV + * @throws std::invalid_argument if the Type is not a numeric scalar + */ void fromInt(PVScalar *pv, int32 from); + /** + * Convert a PV from a long + * @param pv a PV + * @param from value to put into PV + * @throws std::invalid_argument if the Type is not a numeric scalar + */ void fromLong(PVScalar *pv, int64 from); + /** + * Convert a PV from a float + * @param pv a PV + * @param from value to put into PV + * @throws std::invalid_argument if the Type is not a numeric scalar + */ void fromFloat(PVScalar* pv, float from); + /** + * Convert a PV from a double + * @param pv a PV + * @param from value to put into PV + * @throws std::invalid_argument if the Type is not a numeric scalar + */ void fromDouble(PVScalar *pv, double from); + /** + * Convert a PV array to a byte array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param to where to put the PV data + * @param toOffset starting element in the array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int toByteArray(PVScalarArray *pv, int offset, int length, ByteArray to, int toOffset); + /** + * Convert a PV array to a short array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param to where to put the PV data + * @param toOffset starting element in the array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int toShortArray(PVScalarArray *pv, int offset, int length, ShortArray to, int toOffset); + /** + * Convert a PV array to an int array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param to where to put the PV data + * @param toOffset starting element in the array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int toIntArray(PVScalarArray *pv, int offset, int length, IntArray to, int toOffset); + /** + * Convert a PV array to a long array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param to where to put the PV data + * @param toOffset starting element in the array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int toLongArray(PVScalarArray *pv, int offset, int length, LongArray to, int toOffset); + /** + * Convert a PV array to a float array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param to where to put the PV data + * @param toOffset starting element in the array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int toFloatArray(PVScalarArray *pv, int offset, int length, FloatArray to, int toOffset); + /** + * Convert a PV array to a double array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param to where to put the PV data + * @param toOffset starting element in the array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int toDoubleArray(PVScalarArray *pv, int offset, int length, DoubleArray to, int toOffset); + /** + * Convert a PV array from a byte array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param from value to put into PV + * @param fromOffset + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int fromByteArray(PVScalarArray *pv, int offset, int length, ByteArray from, int fromOffset); + /** + * Convert a PV array from a short array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param from value to put into PV + * @param fromOffset starting element in the source array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int fromShortArray(PVScalarArray *pv, int offset, int length, ShortArray from, int fromOffset); + /** + * Convert a PV array from an int array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param from value to put into PV + * @param fromOffset starting element in the source array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int fromIntArray(PVScalarArray *pv, int offset, int length, IntArray from, int fromOffset); + /** + * Convert a PV array from a long array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param from value to put into PV + * @param fromOffset starting element in the source array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int fromLongArray(PVScalarArray *pv, int offset, int length, LongArray from, int fromOffset); + /** + * Convert a PV array from a float array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param from value to put into PV + * @param fromOffset starting element in the source array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int fromFloatArray(PVScalarArray *pv, int offset, int length, FloatArray from, int fromOffset); + /** + * Convert a PV array from a double array. + * @param pv a PV + * @param offset starting element in a PV + * @param length number of elements to transfer + * @param from value to put into PV + * @param fromOffset starting element in the source array + * @return number of elements converted + * @throws std::invalid_argument if the element type is not numeric + */ int fromDoubleArray(PVScalarArray *pv, int offset, int length, DoubleArray from, int fromOffset); + /** + * Convenience method for implementing toString. + * It generates a newline and inserts blanks at the beginning of the newline. + * @param builder The StringBuilder being constructed. + * @param indentLevel Indent level, Each level is four spaces. + */ void newLine(StringBuilder buf, int indentLevel); }; diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index d6e6bba..a2aa597 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -3,6 +3,7 @@ * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvDataCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. + * Author - Marty Kraimer */ #ifndef PVDATA_H #define PVDATA_H @@ -27,21 +28,77 @@ class PVScalarArray; class PVStructure; class PVStructureArray; +/** + * typedef for a pointer to a PVStructure. + */ typedef PVStructure * PVStructurePtr; +/** + * typedef for a pointer to a array of pointer to PVStructure. + */ typedef PVStructurePtr* PVStructurePtrArray; +/** + * typedef for a pointer to a PVField. + */ typedef PVField* PVFieldPtr; +/** + * typedef for a pointer to a array of pointer to PVField. + */ typedef PVFieldPtr * PVFieldPtrArray; +/** + * This class provides auxillary information about a PVField. + * Each item is stored as a PVScalar. + * A (key,value) is provided for accessing the items where the key is a String. + */ class PVAuxInfo : private NoDefaultMethods { public: + /** + * Constructor + * @param The fields to which the Auxinfo is attached. + */ PVAuxInfo(PVField *pvField); + /** + * Destructor + */ ~PVAuxInfo(); + /** + * Get the PVField to which the Auxinfo is attached. + * @return The fields to which the Auxinfo is attached. + */ PVField * getPVField(); + /** + * Add a new auxiliary item or retrieve the interface to an existing item. + * + * @param key The key. + * @param scalarType The scalrType for the new item being added/ + * @return The new PVScalar that has been added to the Auxinfo. + */ PVScalar * createInfo(String key,ScalarType scalarType); + /** + * Get the number of PVScalars in the Auxinfo. + * @return The number. + */ int getNumberInfo(); - PVScalar * getInfo(String name); + /** + * Get the Auxinfo with the specified key. + * @return The PVScalar or null if it does not exist. + */ + PVScalar * getInfo(String key); + /** + * Get the Auxinfo with the specified index. + * @return The PVScalar or null if it does not exist. + */ PVScalar * getInfo(int index); + /** + * Convert the Auxinfo to a string and add it to builder. + * @param builder The string builder. + */ void toString(StringBuilder buf); + /** + * Convert the Auxinfo to a string and add it to builder. + * @param builder The string builder. + * @param indentLevel The number of blanks at the beginning of new lines. + */ void toString(StringBuilder buf,int indentLevel); private: PVField *pvField; @@ -51,34 +108,125 @@ private: friend class PVDataCreate; }; +/** + * This class is implemented by code that calls setPostHander + */ class PostHandler { public: + /** + * Destructor + */ virtual ~PostHandler(){} + /** + * This is called evertime postPut is called for this field. + */ virtual void postPut() = 0; }; +/** + * PVField is the base class for each PVData field. + * Each PVData field has an interface that extends PVField. + */ class PVField : virtual public Serializable, private NoDefaultMethods { public: POINTER_DEFINITIONS(PVField); + /** + * Destructor + */ virtual ~PVField(); + /** + * Called to report errors associated with the field. + * @param message The message. + * @param messageType The message type. + */ virtual void message(String message,MessageType messageType) ; + /** + * Register the message requester. + * At most one requester can be registered. + * @param prequester The requester. + */ virtual void setRequester(Requester *prequester); + /** + * Get offset of the PVField field within top level structure. + * Every field within the PVStructure has a unique offset. + * The top level structure has an offset of 0. + * The first field within the structure has offset equal to 1. + * The other offsets are determined by recursively traversing each structure of the tree. + * @return The offset. + */ int getFieldOffset() ; + /** + * Get the next offset. If the field is a scalar or array field then this is just offset + 1. + * If the field is a structure it is the offset of the next field after this structure. + * Thus (nextOffset - offset) is always equal to the number of fields within the field. + * @return The offset. + */ int getNextFieldOffset() ; + /** + * Get the total number of fields in this field. + * This is equal to nextFieldOffset - fieldOffset. + */ int getNumberFields() ; + /** + * Get the PVAuxInfo interface for the PVField. + * @return The PVAuxInfo interface. + */ PVAuxInfo * getPVAuxInfo(); + /** + * Is the field immutable, i.e. does it not allow changes. + * @return (false,true) if it (is not, is) immutable. + */ bool isImmutable() ; + /** + * Set the field to be immutable, i. e. it can no longer be modified. + * This is permanent, i.e. once done the field can onot be made mutable. + */ virtual void setImmutable(); + /** + * Get the Field that describes the field. + * @return Field, which is the reflection interface. + */ FieldConstPtr getField() ; + /** + * Get the parent of this field. + * @return The parent interface or null if this is PVRecord + */ PVStructure * getParent() ; + /** + * Rename the field name. + * @param newName The new name. + */ bool renameField(String newName); + /** + * postPut. Called when the field is updated by the implementation. + */ void postPut() ; + /** + * Set the handler for postPut. + * At most one handler can be set. + * @param postHandler The handler. + */ void setPostHandler(PostHandler *postHandler); + /** + * Is this field equal to another field. + * @param pv other field + * @return (false,true) if (is not,is) equal. + */ virtual bool equals(PVField &pv); + /** + * Convert the PVField to a string. + * @param buf buffer for the result + */ virtual void toString(StringBuilder buf) ; + /** + * Convert the PVField to a string. + * Each line is indented. + * @param buf buffer for the result + * @param indentLevel The indentation level. + */ virtual void toString(StringBuilder buf,int indentLevel) ; protected: PVField(PVStructure *parent,FieldConstPtr field); @@ -92,15 +240,28 @@ private: friend class PVStructure; }; +/** + * PVScalar is the base class for each scalar field. + */ class PVScalar : public PVField { public: POINTER_DEFINITIONS(PVScalar); + /** + * Destructor + */ virtual ~PVScalar(); + /** + * Get the Scalar introspection interface for the PVScalar. + * @return the interface. + */ ScalarConstPtr getScalar() ; protected: PVScalar(PVStructure *parent,ScalarConstPtr scalar); }; +/** + * Class that holds the data for each posssible scalar type. + */ template class PVScalarValue : public PVScalar { public: @@ -108,9 +269,19 @@ public: typedef T value_type; typedef T* pointer; typedef const T* const_pointer; - + /** + * Destructor + */ virtual ~PVScalarValue() {} + /** + * Get the value. + * @return The value. + */ virtual T get() = 0; + /** + * Put a new value into the PVScalar. + * @param The value. + */ virtual void put(T value) = 0; protected: PVScalarValue(PVStructure *parent,ScalarConstPtr scalar) @@ -118,6 +289,9 @@ protected: private: }; +/** + * typedefs for the various possible scalar types. + */ typedef PVScalarValue PVBoolean; typedef PVScalarValue PVByte; typedef PVScalarValue PVShort; @@ -126,9 +300,14 @@ typedef PVScalarValue PVLong; typedef PVScalarValue PVFloat; typedef PVScalarValue PVDouble; -// BasePVString is special case, since it implements SerializableArray +/** + * PVString is special case, since it implements SerializableArray + */ class PVString : public PVScalarValue, SerializableArray { public: + /** + * Destructor + */ virtual ~PVString() {} protected: PVString(PVStructure *parent,ScalarConstPtr scalar) @@ -136,17 +315,46 @@ protected: }; +/** + * PVArray is the base class for all array types, i.e. the scalarArray types and structureArray. + */ class PVArray : public PVField, public SerializableArray { public: POINTER_DEFINITIONS(PVArray); + /** + * Destructor + */ virtual ~PVArray(); + /** + * Get the array length. + * @return The length. + */ int getLength() const; + /** + * Set the array length. + * @param The length. + */ void setLength(int length); + /** + * Get the array capacity. + * @return The capacity. + */ int getCapacity() const; + /** + * Can the capacity be changed. + * @return (false,true) if (can not, can) be changed. + */ bool isCapacityMutable(); + /** + * Set the mutability of the array capacity. + * @return false or true + */ void setCapacityMutable(bool isMutable); + /** + * Set the array capacity. + * @param The capacity. + */ virtual void setCapacity(int capacity) = 0; - protected: PVArray(PVStructure *parent,FieldConstPtr field); void setCapacityLength(int capacity,int length); @@ -154,6 +362,9 @@ private: class PVArrayPvt * pImpl; }; +/** + * Class provided by caller of get + */ template class PVArrayData { public: @@ -161,16 +372,31 @@ public: typedef T value_type; typedef T* pointer; typedef const T* const_pointer; - + /** + * The data array. + */ pointer data; + /** + * The offset. This is the offset into the actual array of the first element in data, + */ int offset; }; +/** + * Base class for a scalarArray. + */ class PVScalarArray : public PVArray { public: POINTER_DEFINITIONS(PVScalarArray); + /** + * Destructor + */ virtual ~PVScalarArray(); + /** + * Get the introspection interface + * @return The interface. + */ ScalarArrayConstPtr getScalarArray() ; protected: @@ -178,20 +404,67 @@ protected: private: }; +/** + * This is provided by code that calls get. + */ typedef PVArrayData StructureArrayData; +/** + * Data class for a structureArray + */ class PVStructureArray : public PVArray { public: POINTER_DEFINITIONS(PVStructureArray); + /** + * Destructor + */ virtual ~PVStructureArray() {} + /** + * Get the introspection interface + * @return The interface. + */ virtual StructureArrayConstPtr getStructureArray() = 0; + /** + * Append new elements to the end of the array. + * @param number The number of elements to add. + * @return the new length of the array. + */ virtual int append(int number) = 0; + /** + * Remove elements from the array. + * @param offset The offset of the first element to remove. + * @param number The number of elements to remove. + * @return (false,true) if the elements were removed. + */ virtual bool remove(int offset,int number) = 0; + /** + * Compress. This removes all null elements from the array. + */ virtual void compress() = 0; + /** + * Get array elements + * @param offset The offset of the first element, + * @param length The number of elements to get. + * @param data The place where the data is placed. + */ virtual int get(int offset, int length, StructureArrayData *data) = 0; + /** + * Put data into the array. + * @param offset The offset of the first element, + * @param length The number of elements to get. + * @param from The new values to put into the array. + * @param fromOffset The offset in from. + * @return The number of elements put into the array. + */ virtual int put(int offset,int length, PVStructurePtrArray from, int fromOffset) = 0; + /** + * Share data from another source. + * @param value The data to share. + * @param capacity The capacity of the array. + * @param length The length of the array. + */ virtual void shareData( PVStructurePtrArray value,int capacity,int length) = 0; protected: @@ -204,38 +477,170 @@ private: class PVStructure : public PVField,public BitSetSerializable { public: POINTER_DEFINITIONS(PVStructure); + /** + * Destructor + */ virtual ~PVStructure(); + /** + * Get the introspection interface + * @return The interface. + */ StructureConstPtr getStructure(); + /** + * Get the array of pointers to the subfields in the structure. + * @return The array. + */ PVFieldPtrArray getPVFields(); + /** + * Get the subfield with the specified name. + * @param fieldName The name of the field. + * @return Pointer to the field or null if field does not exist. + */ PVField *getSubField(String fieldName); + /** + * Get the subfield with the specified offset. + * @param fieldOffset The offset. + * @return Pointer to the field or null if field does not exist. + */ PVField *getSubField(int fieldOffset); + /** + * Append a field to the structure. + * @param pvField The field to append. + */ void appendPVField(PVField *pvField); + /** + * Append fields to the structure. + * @param numberFields The number of fields. + * @param pvFields The fields to append. + * @return Pointer to the field or null if field does not exist. + */ void appendPVFields(int numberFields,PVFieldPtrArray pvFields); + /** + * Remove a field from the structure. + * @param fieldName The name of the field to remove. + */ void removePVField(String fieldName); + /** + * Get a boolean field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVBoolean *getBooleanField(String fieldName); + /** + * Get a byte field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVByte *getByteField(String fieldName); + /** + * Get a short field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVShort *getShortField(String fieldName); + /** + * Get a int field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVInt *getIntField(String fieldName); + /** + * Get a long field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVLong *getLongField(String fieldName); + /** + * Get a float field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVFloat *getFloatField(String fieldName); + /** + * Get a double field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVDouble *getDoubleField(String fieldName); + /** + * Get a string field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVString *getStringField(String fieldName); + /** + * Get a structure field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVStructure *getStructureField(String fieldName); + /** + * Get a scalarArray field with the specified name. + * @param fieldName The name of the field to get. + * @param elementType The element type. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVScalarArray *getScalarArrayField( String fieldName,ScalarType elementType); + /** + * Get a structureArray field with the specified name. + * @param fieldName The name of the field to get. + * @return Pointer to the field of null if a field with that name and type does not exist. + */ PVStructureArray *getStructureArrayField(String fieldName); + /** + * Get the name if this structure extends another structure. + * @return The string which may be null. + */ String getExtendsStructureName(); + /** + * Put the extends name. + * @param extendsStructureName The name. + */ bool putExtendsStructureName( String extendsStructureName); + /** + * Serialize. + * @param pbuffer The byte buffer. + * @param pflusher Interface to call when buffer is full. + */ virtual void serialize( ByteBuffer *pbuffer,SerializableControl *pflusher) const; + /** + * Deserialize + * @param pbuffer The byte buffer. + * @param pflusher Interface to call when buffer is empty. + */ virtual void deserialize( ByteBuffer *pbuffer,DeserializableControl *pflusher); + /** + * Serialize. + * @param pbuffer The byte buffer. + * @param pflusher Interface to call when buffer is full. + * @param pbitSet A bitset the specifies which fields to serialize. + */ virtual void serialize(ByteBuffer *pbuffer, SerializableControl *pflusher,BitSet *pbitSet) const; + /** + * Deserialize + * @param pbuffer The byte buffer. + * @param pflusher Interface to call when buffer is empty. + * @param pbitSet A bitset the specifies which fields to deserialize. + */ virtual void deserialize(ByteBuffer *pbuffer, DeserializableControl*pflusher,BitSet *pbitSet); + /** + * Constructor + * @param parent The parent structure. + * @param structure The introspection interface. + */ PVStructure(PVStructure *parent,StructureConstPtr structure); + /** + * Constructor + * @param parent The parent structure. + * @param structure The introspection interface. + * @param pvFields The array of fields for the structure. + */ PVStructure( PVStructure *parent, StructureConstPtr structure, @@ -254,9 +659,32 @@ public: typedef const T* const_pointer; typedef PVArrayData ArrayDataType; + /** + * Destructor + */ virtual ~PVValueArray() {} + /** + * Get array elements + * @param offset The offset of the first element, + * @param length The number of elements to get. + * @param data The place where the data is placed. + */ virtual int get(int offset, int length, ArrayDataType *data) = 0; + /** + * Put data into the array. + * @param offset The offset of the first element, + * @param length The number of elements to get. + * @param from The new values to put into the array. + * @param fromOffset The offset in from. + * @return The number of elements put into the array. + */ virtual int put(int offset,int length, pointer from, int fromOffset) = 0; + /** + * Share data from another source. + * @param value The data to share. + * @param capacity The capacity of the array. + * @param length The length of the array. + */ virtual void shareData(pointer value,int capacity,int length) = 0; protected: PVValueArray(PVStructure *parent,ScalarArrayConstPtr scalar) @@ -264,6 +692,9 @@ protected: private: }; +/** + * Definitions for the various scalarArray types. + */ typedef PVArrayData BooleanArrayData; typedef PVValueArray PVBooleanArray; @@ -289,31 +720,123 @@ typedef PVValueArray PVDoubleArray; typedef PVArrayData StringArrayData; typedef PVValueArray PVStringArray; +/** + * This is a singlton class for creating data instances. + */ class PVDataCreate { public: - PVField *createPVField(PVStructure *parent, - FieldConstPtr field); - PVField *createPVField(PVStructure *parent, - String fieldName,PVField * fieldToClone); - PVScalar *createPVScalar(PVStructure *parent,ScalarConstPtr scalar); - PVScalar *createPVScalar(PVStructure *parent, - String fieldName,ScalarType scalarType); - PVScalar *createPVScalar(PVStructure *parent, - String fieldName,PVScalar * scalarToClone); - PVScalarArray *createPVScalarArray(PVStructure *parent, - ScalarArrayConstPtr scalarArray); - PVScalarArray *createPVScalarArray(PVStructure *parent, - String fieldName,ScalarType elementType); - PVScalarArray *createPVScalarArray(PVStructure *parent, - String fieldName,PVScalarArray * scalarArrayToClone); - PVStructureArray *createPVStructureArray(PVStructure *parent, - StructureArrayConstPtr structureArray); - PVStructure *createPVStructure(PVStructure *parent, - StructureConstPtr structure); - PVStructure *createPVStructure(PVStructure *parent, - String fieldName,int numberFields,FieldConstPtrArray fields); - PVStructure *createPVStructure(PVStructure *parent, - String fieldName,int numberFields,PVFieldPtrArray pvFields); + /** + * Create a PVField using given Field introspection data. + * @param parent The parent interface. + * @param field The introspection data to be used to create PVField. + * @return The PVField implementation. + */ + PVField *createPVField(PVStructure *parent, + FieldConstPtr field); + /** + * Create a PVField using given a PVField to clone. + * This method calls the appropriate createPVScalar, createPVArray, or createPVStructure. + * @param parent The parent interface. + * @param fieldToClone The field to clone. + * @return The PVField implementation + */ + PVField *createPVField(PVStructure *parent, + String fieldName,PVField * fieldToClone); + /** + * Create an implementation of a scalar field reusing the Scalar introspection interface. + * @param parent The parent. + * @param scalar The introspection interface. + * @return The PVScalar implementation. + */ + PVScalar *createPVScalar(PVStructure *parent,ScalarConstPtr scalar); + /** + * Create an implementation of a scalar field. A Scalar introspection interface is created. + * @param parent The parent interface. + * @param fieldName The field name. + * @param fieldType The field type. + * @return The PVScalar implementation. + */ + PVScalar *createPVScalar(PVStructure *parent, + String fieldName,ScalarType scalarType); + /** + * Create an implementation of a scalar field by cloning an existing PVScalar. + * The new PVScalar will have the same value and auxInfo as the original. + * @param parent The parent interface. + * @param fieldName The field name. + * @param scalarToClone The PVScalar to clone. + * @return The PVScalar implementation. + */ + PVScalar *createPVScalar(PVStructure *parent, + String fieldName,PVScalar * scalarToClone); + /** + * Create an implementation of an array field reusing the Array introspection interface. + * @param parent The parent interface. + * @param array The introspection interface. + * @return The PVScalarArray implementation. + */ + PVScalarArray *createPVScalarArray(PVStructure *parent, + ScalarArrayConstPtr scalarArray); + /** + * Create an implementation for an array field. An Array introspection interface is created. + * @param parent The parent interface. + * @param fieldName The field name. + * @param elementType The element type. + * @return The PVScalarArray implementation. + */ + PVScalarArray *createPVScalarArray(PVStructure *parent, + String fieldName,ScalarType elementType); + /** + * Create an implementation of an array field by cloning an existing PVArray. + * The new PVArray will have the same value and auxInfo as the original. + * @param parent The parent interface. + * @param fieldName The field name. + * @param arrayToClone The PVScalarArray to clone. + * @return The PVScalarArray implementation. + */ + PVScalarArray *createPVScalarArray(PVStructure *parent, + String fieldName,PVScalarArray * scalarArrayToClone); + /** + * Create an implementation of an array with structure elements. + * @param parent The parent interface. + * @param structureArray The introspection interface. + * All elements share the same introspection interface. + * @return The PVStructureArray implementation. + */ + PVStructureArray *createPVStructureArray(PVStructure *parent, + StructureArrayConstPtr structureArray); + /** + * Create implementation for PVStructure. + * @param parent The parent interface. + * @param structure The introspection interface. + * @return The PVStructure implementation + */ + PVStructure *createPVStructure(PVStructure *parent, + StructureConstPtr structure); + /** + * Create implementation for PVStructure. + * @param parent The parent interface. + * @param fieldName The field name. + * @param fields Array of reflection interfaces for the subFields. + * @return The PVStructure implementation + */ + PVStructure *createPVStructure(PVStructure *parent, + String fieldName,int numberFields,FieldConstPtrArray fields); + /** + * Create implementation for PVStructure. + * @param parent The parent interface. + * @param fieldName The field name. + * @param pvFields Array of PVFields + * @return The PVStructure implementation + */ + PVStructure *createPVStructure(PVStructure *parent, + String fieldName,int numberFields,PVFieldPtrArray pvFields); + /** + * Create implementation for PVStructure. + * @param parent The parent interface. + * @param fieldName The field name. + * @param structToClone A structure. Each subfield and any auxInfo is cloned and added to the newly created structure. + * @return The PVStructure implementation. + */ PVStructure *createPVStructure(PVStructure *parent, String fieldName,PVStructure *structToClone); protected: @@ -321,6 +844,11 @@ protected: friend PVDataCreate * getPVDataCreate(); }; +/** + * Get the single class that implemnents PVDataCreate + * @param The PVDataCreate factory. + */ + extern PVDataCreate * getPVDataCreate(); }} diff --git a/pvDataApp/pv/pvIntrospect.h b/pvDataApp/pv/pvIntrospect.h index 7cfbe9b..369b562 100644 --- a/pvDataApp/pv/pvIntrospect.h +++ b/pvDataApp/pv/pvIntrospect.h @@ -3,6 +3,7 @@ * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvDataCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. + * Author - Marty Kraimer */ #ifndef PVINTROSPECT_H #define PVINTROSPECT_H @@ -20,55 +21,195 @@ class ScalarArray; class Structure; class StructureArray; +/** + * typedef for a shared pointer to an immutable Field. + */ typedef std::tr1::shared_ptr FieldConstPtr; +/** + * typedef for an array of shared pointer to an immutable Field. + */ typedef FieldConstPtr * FieldConstPtrArray; +/** + * typedef for a shared pointer to an immutable Scalar. + */ typedef std::tr1::shared_ptr ScalarConstPtr; +/** + * typedef for a shared pointer to an immutable ScalarArray. + */ typedef std::tr1::shared_ptr ScalarArrayConstPtr; +/** + * typedef for a shared pointer to an immutable Structure. + */ typedef std::tr1::shared_ptr StructureConstPtr; +/** + * typedef for a shared pointer to an immutable StructureArray. + */ typedef std::tr1::shared_ptr StructureArrayConstPtr; +/** + * Definition of support field types. + */ enum Type { + /** + * The type is scalar. It has a scalarType + */ scalar, + /** + * The type is scalarArray. Each element is a scalar of the same scalarType. + */ scalarArray, + /** + * The type is structure. + */ structure, + /** + * The type is structureArray. Each element is a structure. + */ structureArray }; +/** + * Convenience functions for Type. + */ namespace TypeFunc { - const char* name(Type); - void toString(StringBuilder buf,const Type type); + /** + * Get a name for the type. + * @param type The type. + * @return The name for the type. + */ + const char* name(Type type); + /** + * Convert the type to a string and add it to builder. + * @param builder The string builder. + * @param type The type. + */ + void toString(StringBuilder builder,const Type type); }; +/** + * Definition of support scalar types. + */ enum ScalarType { + /** + * The type is boolean, i. e. value can be {@code false} or {@code true} + */ pvBoolean, + /** + * The type is byte, i. e. a 8 bit signed integer. + */ pvByte, + /** + * The type is short, i. e. a 16 bit signed integer. + */ pvShort, + /** + * The type is int, i. e. a 32 bit signed integer. + */ pvInt, + /** + * The type is long, i. e. a 64 bit signed integer. + */ pvLong, + /** + * The type is float, i. e. 32 bit IEEE floating point, + */ pvFloat, + /** + * The type is float, i. e. 64 bit IEEE floating point, + */ pvDouble, + /** + * The type is string, i. e. a UTF8 character string. + */ pvString }; +/** + * Convenience functions for ScalarType. + */ namespace ScalarTypeFunc { - bool isInteger(ScalarType type); - bool isNumeric(ScalarType type); - bool isPrimitive(ScalarType type); + /** + * Is the type an integer, i. e. is it one of byte,...long + * @param scalarType The type. + * @return (false,true) if the scalarType is an integer. + */ + bool isInteger(ScalarType scalarType); + /** + * Is the type numeric, i. e. is it one of byte,...,double + * @param scalarType The type. + * @return (false,true) if the scalarType is a numeric + */ + bool isNumeric(ScalarType scalarType); + /** + * Is the type primitive, i. e. not string + * @param scalarType The type. + * @return (false,true) if the scalarType is primitive. + */ + bool isPrimitive(ScalarType scalarType); + /** + * Get the scalarType for value. + * @param value The name of the scalar type. + * @return The scalarType. + * An exception is thrown if the name is not the name of a scalar type. + */ ScalarType getScalarType(String value); - const char* name(ScalarType); - void toString(StringBuilder buf,ScalarType scalarType); + /** + * Get a name for the scalarType. + * @param scalarType The type. + * @return The name for the scalarType. + */ + const char* name(ScalarType scalarType); + /** + * Convert the scalarType to a string and add it to builder. + * @param builder The string builder. + * @param scalarType The type. + */ + void toString(StringBuilder builder,ScalarType scalarType); }; +/** + * This class implements introspection object for field. + */ class Field : public std::tr1::enable_shared_from_this { public: POINTER_DEFINITIONS(Field); + /** + * Destructor. + */ virtual ~Field(); + /** + * Get the name of the field. + * @return The field name. + */ String getFieldName() const{return m_fieldName;} + /** + * Get the field type. + * @return The type. + */ Type getType() const{return m_type;} - virtual void toString(StringBuilder buf) const{toString(buf,0);} - virtual void toString(StringBuilder buf,int indentLevel) const; + /** + * Convert the scalarType to a string and add it to builder. + * @param builder The string builder. + */ + virtual void toString(StringBuilder builder) const{toString(builder,0);} + /** + * Convert the scalarType to a string and add it to builder. + * @param builder The string builder. + * @param indentLevel The number of blanks at the beginning of new lines. + */ + virtual void toString(StringBuilder builder,int indentLevel) const; + /** + * Rename the field. + * @param newName The new name. + * This MUST not be called after the field is put into use!!! + */ void renameField(String newName); protected: + /** + * Constructor + * @param fieldName The field name. + * @param fieldName The field type. + */ Field(String fieldName,Type type); private: String m_fieldName; @@ -85,74 +226,178 @@ private: }; +/** + * This class implements introspection object for Scalar. + */ class Scalar : public Field{ public: - POINTER_DEFINITIONS(Scalar); - virtual ~Scalar(); - 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; + POINTER_DEFINITIONS(Scalar); + /** + * Destructor. + */ + virtual ~Scalar(); + typedef Scalar& reference; + typedef const Scalar& const_reference; + /** + * Get the scalarType + * @return the scalarType + */ + ScalarType getScalarType() const {return scalarType;} + /** + * Convert the scalar to a string and add it to builder. + * @param builder The string builder. + */ + virtual void toString(StringBuilder buf) const{toString(buf,0);} + /** + * Convert the scalar to a string and add it to builder. + * @param builder The string builder. + * @param indentLevel The number of blanks at the beginning of new lines. + */ + virtual void toString(StringBuilder buf,int indentLevel) const; protected: - Scalar(String fieldName,ScalarType scalarType); + Scalar(String fieldName,ScalarType scalarType); private: - ScalarType scalarType; - friend class FieldCreate; + ScalarType scalarType; + friend class FieldCreate; }; +/** + * This class implements introspection object for field. + */ class ScalarArray : public Field{ public: - POINTER_DEFINITIONS(ScalarArray); - ScalarArray(String fieldName,ScalarType scalarType); - typedef ScalarArray& reference; - typedef const ScalarArray& const_reference; + POINTER_DEFINITIONS(ScalarArray); + ScalarArray(String fieldName,ScalarType scalarType); + 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; + /** + * Get the scalarType for the elements. + * @return the scalarType + */ + ScalarType getElementType() const {return elementType;} + /** + * Convert the scalarType to a string and add it to builder. + * @param builder The string builder. + */ + virtual void toString(StringBuilder buf) const{toString(buf,0);} + /** + * Convert the scalarType to a string and add it to builder. + * @param builder The string builder. + * @param indentLevel The number of blanks at the beginning of new lines. + */ + virtual void toString(StringBuilder buf,int indentLevel) const; protected: - virtual ~ScalarArray(); + /** + * Destructor. + */ + virtual ~ScalarArray(); private: - ScalarType elementType; - friend class FieldCreate; + ScalarType elementType; + friend class FieldCreate; }; +/** + * This class implements introspection object for a structureArray + */ class StructureArray : public Field{ public: - POINTER_DEFINITIONS(StructureArray); - typedef StructureArray& reference; - typedef const StructureArray& const_reference; + POINTER_DEFINITIONS(StructureArray); + typedef StructureArray& reference; + typedef const StructureArray& const_reference; - const Structure& structure() const {return *pstructure;} - StructureConstPtr getStructure() const {return pstructure;} + const Structure& structure() const {return *pstructure;} + /** + * Get the introspection interface for the array elements. + * @return The introspection interface. + */ + StructureConstPtr getStructure() const {return pstructure;} - virtual void toString(StringBuilder buf,int indentLevel=0) const; + /** + * Convert the scalarType to a string and add it to builder. + * @param builder The string builder. + * @param indentLevel The number of blanks at the beginning of new lines. + */ + virtual void toString(StringBuilder buf,int indentLevel=0) const; protected: - StructureArray(String fieldName,StructureConstPtr structure); - virtual ~StructureArray(); + /** + * Constructor. + * @param fieldName The name for the field. + * @param structure The introspection interface for the elements. + */ + StructureArray(String fieldName,StructureConstPtr structure); + /** + * Destructor. + */ + virtual ~StructureArray(); private: - StructureConstPtr pstructure; - friend class FieldCreate; + StructureConstPtr pstructure; + friend class FieldCreate; }; +/** + * This class implements introspection object for a structure. + */ class Structure : public Field { public: - POINTER_DEFINITIONS(Structure); - virtual ~Structure(); - typedef Structure& reference; - typedef const Structure& const_reference; + POINTER_DEFINITIONS(Structure); + /** + * Destructor. + */ + virtual ~Structure(); + typedef Structure& reference; + typedef const Structure& const_reference; - int getNumberFields() const {return numberFields;} - FieldConstPtr getField(String fieldName) const; - int getFieldIndex(String fieldName) const; - FieldConstPtrArray getFields() const {return fields;} - void appendField(FieldConstPtr field); - void appendFields(int numberFields,FieldConstPtrArray fields); - void removeField(int index); - virtual void toString(StringBuilder buf) const{toString(buf,0);} - virtual void toString(StringBuilder buf,int indentLevel) const; + /** + * Get the number of immediate subfields in the structure/ + * @return The number of fields. + */ + int getNumberFields() const {return numberFields;} + /** + * Get the field for the specified fieldName. + * @return The introspection interface. + * This will hold a null pointer if the field is not in the structure. + */ + FieldConstPtr getField(String fieldName) const; + /** + * Get the field index for the specified fieldName. + * @return The introspection interface. + * This will be -1 if the field is not in the structure. + */ + int getFieldIndex(String fieldName) const; + /** + * Get the fields in the structure. + * @return The array of fields. + */ + FieldConstPtrArray getFields() const {return fields;} + /** + * Append a field to the structure. + * @param field The field to append. + */ + void appendField(FieldConstPtr field); + /** + * Append an array of fields to the structure. + * @param field The fields to append. + * The array MUST be allocated on the heap. + * The structure takes ownership of the field array. + */ + void appendFields(int numberFields,FieldConstPtrArray fields); + /** + * Remove a field from the structure. + * @param field The field to remove. + */ + void removeField(int index); + /** + * Convert the structure to a string and add it to builder. + * @param builder The string builder. + */ + virtual void toString(StringBuilder buf) const{toString(buf,0);} + /** + * Convert the structure to a string and add it to builder. + * @param builder The string builder. + * @param indentLevel The number of blanks at the beginning of new lines. + */ + virtual void toString(StringBuilder buf,int indentLevel) const; protected: Structure(String fieldName, int numberFields,FieldConstPtrArray fields); private: @@ -161,21 +406,59 @@ private: friend class FieldCreate; }; +/** + * This is a singlton class for creating introspection interfaces. + */ class FieldCreate : NoDefaultMethods { public: - FieldConstPtr create(String fieldName,FieldConstPtr field) const; - ScalarConstPtr createScalar(String fieldName,ScalarType scalarType) const; - ScalarArrayConstPtr createScalarArray(String fieldName, - ScalarType elementType) const; - StructureConstPtr createStructure (String fieldName, - int numberFields,FieldConstPtrArray fields) const; - StructureArrayConstPtr createStructureArray(String fieldName, - StructureConstPtr structure) const; + /** + * Create a new Field like an existing field but with a different name. + * @param fieldName The field name. + * @param field An existing field + * @return a {@code Field} interface for the newly created object. + */ + FieldConstPtr create(String fieldName,FieldConstPtr field) const; + /** + * Create a {@code ScalarField}. + * @param fieldName The field name. + * @param scalarType The scalar type. + * @return a {@code Scalar} interface for the newly created object. + * @throws An {@code IllegalArgumentException} if an illegal type is specified. + */ + ScalarConstPtr createScalar(String fieldName,ScalarType scalarType) const; + /** + * Create an {@code Array} field. + * @param fieldName The field name + * @param elementType The {@code scalarType} for array elements + * @return An {@code Array} Interface for the newly created object. + */ + ScalarArrayConstPtr createScalarArray(String fieldName, + ScalarType elementType) const; + /** + * Create an {@code Array} field that is has element type Structure + * @param fieldName The field name + * @param elementStructure The {@code Structure} for each array element. + * @return An {@code Array} Interface for the newly created object. + */ + StructureConstPtr createStructure (String fieldName, + int numberFields,FieldConstPtrArray fields) const; + /** + * Create a {@code Structure} field. + * @param fieldName The field name + * @param fields The array of {@code Field}s for the structure. + * @return a {@code Structure} interface for the newly created object. + */ + StructureArrayConstPtr createStructureArray(String fieldName, + StructureConstPtr structure) const; private: FieldCreate(); friend FieldCreate * getFieldCreate(); }; +/** + * Get the single class that implemnents FieldCreate, + * @param The fieldCreate factory. + */ extern FieldCreate * getFieldCreate(); }} diff --git a/pvDataApp/pv/pvType.h b/pvDataApp/pv/pvType.h index 176fcfa..bb4c4fb 100644 --- a/pvDataApp/pv/pvType.h +++ b/pvDataApp/pv/pvType.h @@ -3,6 +3,7 @@ * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvDataCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. + * Author - Marty Kraimer */ /* Definitions for the primitive types for pvData. @@ -16,27 +17,82 @@ namespace epics { namespace pvData { +/** + * This is a set of typdefs used by pvData. + */ + +/** + * boolean, i.e. can only have the values {@code false} or {@code true} + */ typedef bool boolean; +/** + * A 8 bit signed integer + */ typedef int8_t int8; +/** + * A 16 bit signed integer + */ typedef int16_t int16; +/** + * A 32 bit signed integer + */ typedef int32_t int32; +/** + * A 64 bit signed integer + */ typedef int64_t int64; +/** + * A 32 bit unsigned integer + */ typedef uint32_t uint32; +/** + * A 64 bit unsigned integer + */ typedef uint64_t uint64; + // float and double are types +/** + * A string + */ typedef std::string String; +/** + * A boolean array. + */ typedef bool * BooleanArray; +/** + * A byte array. + */ typedef int8 * ByteArray; +/** + * A short array. + */ typedef int16 * ShortArray; +/** + * A int array. + */ typedef int32 * IntArray; +/** + * A long array. + */ typedef int64 * LongArray; +/** + * A float array. + */ typedef float * FloatArray; +/** + * A double array. + */ typedef double * DoubleArray; +/** + * A string array. + */ typedef String* StringArray; -// convenience definition for toString methods +/** + * A convenience definition for toString methods + */ typedef std::string * StringBuilder; }} diff --git a/pvDataApp/pv/standardField.h b/pvDataApp/pv/standardField.h index adf073d..22adf60 100644 --- a/pvDataApp/pv/standardField.h +++ b/pvDataApp/pv/standardField.h @@ -3,6 +3,7 @@ * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvDataCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. + * Author - Marty Kraimer */ #ifndef STANDARDFIELD_H #define STANDARDFIELD_H @@ -12,6 +13,41 @@ namespace epics { namespace pvData { +/** + * Standard Fields is a class or creating or sharing Field objects for standard fields. + * For each type of standard object two methods are defined:s + * one with no properties and with properties + * The property field is a comma separated string of property names of the following: + * alarm, timeStamp, display, control, and valueAlarm. + * An example is "alarm,timeStamp,valueAlarm". + * The method with properties creates a structure with fields named fieldName and each of the property names.s + * Each property field is a structure defining the property. + * The details about each property is given in the section named "Property". For example the call: + * {@code + StructureConstPtr example = standardField->scalar( + String("value"), + pvDouble, + String("value,alarm,timeStamp")); + * } + * Will result in a Field definition that has the form: {@code + structure example + double value + structure alarm + structure severity + int index + string[] choices + structure timeStamp + long secondsPastEpoch + int nanoSeconds + * } + * In addition there are methods that create each of the property structures, + * i.e. the methods named: alarm, .... enumeratedAlarm." + * + * StandardField is a singleton class. The class is accessed via the statement: {@code + StandardField *standardField = getStandardField(); + * } + */ + class StandardField : private NoDefaultMethods { public: StandardField(); diff --git a/pvDataApp/pv/standardPVField.h b/pvDataApp/pv/standardPVField.h index 943c40b..273e5bb 100644 --- a/pvDataApp/pv/standardPVField.h +++ b/pvDataApp/pv/standardPVField.h @@ -3,6 +3,7 @@ * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvDataCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. + * Author - Marty Kraimer */ #ifndef STANDARDPVFIELD_H #define STANDARDPVFIELD_H @@ -12,6 +13,17 @@ #include namespace epics { namespace pvData { +/** + * StandardPVField is a class or creating standard data fields. + * Like class StandardField it has two forms of the methods which create a fields: + * one without properties and one with properties. + * The properties are some combination of alarm, timeStamp, control, display, and valueAlarm. + * Just like StandardField there are methods to create the standard properties. + * + * StandardPVField is a singleton class. The class is accessed via the statement: {@code + StandardPVField *standardPVField = getStandardPVField(); + * } + */ class StandardPVField : private NoDefaultMethods { public: diff --git a/test/testBaseException b/test/testBaseException index e195adc..0de1968 100644 --- a/test/testBaseException +++ b/test/testBaseException @@ -5,7 +5,7 @@ There is a logic_error On line 68 of ../testBaseException.cpp ../bin/linux-x86/testBaseException[0x80497b9] ../bin/linux-x86/testBaseException[0x8049a54] -/lib/libc.so.6(__libc_start_main+0xe6)[0x3aae36] +/lib/libc.so.6(__libc_start_main+0xe6)[0x126e36] ../bin/linux-x86/testBaseException[0x80490e1] To translate run 'addr2line -e execname 0xXXXXXXX ...' Note: Must be compiled with debug symbols @@ -17,7 +17,7 @@ On line 75 of ../testBaseException.cpp ../bin/linux-x86/testBaseException() [0x8049cec] ../bin/linux-x86/testBaseException() [0x8049923] ../bin/linux-x86/testBaseException() [0x8049a54] -/lib/libc.so.6(__libc_start_main+0xe6) [0x3aae36] +/lib/libc.so.6(__libc_start_main+0xe6) [0x126e36] ../bin/linux-x86/testBaseException() [0x80490e1] testBaseException... @@ -26,7 +26,7 @@ all is OK On line 48 of ../testBaseException.cpp ../bin/linux-x86/testBaseException() [0x8049581] ../bin/linux-x86/testBaseException() [0x8049a5c] -/lib/libc.so.6(__libc_start_main+0xe6) [0x3aae36] +/lib/libc.so.6(__libc_start_main+0xe6) [0x126e36] ../bin/linux-x86/testBaseException() [0x80490e1] @@ -38,7 +38,7 @@ On line 57 of ../testBaseException.cpp ../bin/linux-x86/testBaseException() [0x80491ec] ../bin/linux-x86/testBaseException() [0x80496f9] ../bin/linux-x86/testBaseException() [0x8049a5c] -/lib/libc.so.6(__libc_start_main+0xe6) [0x3aae36] +/lib/libc.so.6(__libc_start_main+0xe6) [0x126e36] ../bin/linux-x86/testBaseException() [0x80490e1] diff --git a/test/testBaseExceptionDiff b/test/testBaseExceptionDiff index e1b9937..a3b016c 100644 --- a/test/testBaseExceptionDiff +++ b/test/testBaseExceptionDiff @@ -1,5 +1,5 @@ --- testBaseExceptionGold 2011-04-27 13:11:55.000000000 -0400 -+++ testBaseException 2011-10-21 08:41:54.000000000 -0400 ++++ testBaseException 2011-12-12 08:58:22.000000000 -0500 @@ -1,37 +1,46 @@ + + @@ -8,7 +8,7 @@ +On line 68 of ../testBaseException.cpp +../bin/linux-x86/testBaseException[0x80497b9] +../bin/linux-x86/testBaseException[0x8049a54] -+/lib/libc.so.6(__libc_start_main+0xe6)[0x3aae36] ++/lib/libc.so.6(__libc_start_main+0xe6)[0x126e36] +../bin/linux-x86/testBaseException[0x80490e1] +To translate run 'addr2line -e execname 0xXXXXXXX ...' + Note: Must be compiled with debug symbols @@ -20,7 +20,7 @@ +../bin/linux-x86/testBaseException() [0x8049cec] +../bin/linux-x86/testBaseException() [0x8049923] +../bin/linux-x86/testBaseException() [0x8049a54] -+/lib/libc.so.6(__libc_start_main+0xe6) [0x3aae36] ++/lib/libc.so.6(__libc_start_main+0xe6) [0x126e36] +../bin/linux-x86/testBaseException() [0x80490e1] + testBaseException... @@ -34,7 +34,7 @@ +On line 48 of ../testBaseException.cpp +../bin/linux-x86/testBaseException() [0x8049581] +../bin/linux-x86/testBaseException() [0x8049a5c] -+/lib/libc.so.6(__libc_start_main+0xe6) [0x3aae36] ++/lib/libc.so.6(__libc_start_main+0xe6) [0x126e36] +../bin/linux-x86/testBaseException() [0x80490e1] + @@ -67,7 +67,7 @@ +../bin/linux-x86/testBaseException() [0x80491ec] +../bin/linux-x86/testBaseException() [0x80496f9] +../bin/linux-x86/testBaseException() [0x8049a5c] -+/lib/libc.so.6(__libc_start_main+0xe6) [0x3aae36] ++/lib/libc.so.6(__libc_start_main+0xe6) [0x126e36] +../bin/linux-x86/testBaseException() [0x80490e1] + diff --git a/test/testLinkedListAux b/test/testLinkedListAux index 640d6b4..0a2b711 100644 --- a/test/testLinkedListAux +++ b/test/testLinkedListAux @@ -1,20 +1,20 @@ Time test -diff 26.014862 milliSeconds -time per iteration 26.014862 microseconds -time per addTail/removeHead 0.013007 microseconds +diff 22.467672 milliSeconds +time per iteration 22.467672 microseconds +time per addTail/removeHead 0.011234 microseconds Time test locked -diff 207.007364 milliSeconds -time per iteration 207.007364 microseconds -time per addTail/removeHead 0.103504 microseconds +diff 203.349351 milliSeconds +time per iteration 203.349351 microseconds +time per addTail/removeHead 0.101675 microseconds Time std::list test -diff 633.793804 milliSeconds -time per iteration 633.793804 microseconds -time per addTail/removeHead 0.316897 microseconds +diff 628.939624 milliSeconds +time per iteration 628.939624 microseconds +time per addTail/removeHead 0.314470 microseconds Time std::list test locked -diff 787.046498 milliSeconds -time per iteration 787.046498 microseconds -time per addTail/removeHead 0.393523 microseconds +diff 780.516186 milliSeconds +time per iteration 780.516186 microseconds +time per addTail/removeHead 0.390258 microseconds diff --git a/test/testPropertyAux b/test/testPropertyAux index 6639da5..bc6385d 100644 --- a/test/testPropertyAux +++ b/test/testPropertyAux @@ -1 +1 @@ -2011.10.21 08:41:59 266990875 nanoSeconds isDst true userTag 32 +2011.12.12 08:58:27 851342349 nanoSeconds isDst false userTag 32 diff --git a/test/testThreadAux b/test/testThreadAux index 6a366cf..168a173 100644 --- a/test/testThreadAux +++ b/test/testThreadAux @@ -1 +1 @@ -time per call 37.044874 microseconds +time per call 39.476176 microseconds diff --git a/test/testTimeStampAux b/test/testTimeStampAux index 0fdc9d3..1c33772 100644 --- a/test/testTimeStampAux +++ b/test/testTimeStampAux @@ -1,5 +1,5 @@ -current 1319200918 391667584 milliSec 1319200918391 -2011.10.21 08:41:58 391667584 nanoSeconds isDst true +current 1323698306 842810605 milliSec 1323698306842 +2011.12.12 08:58:26 842810605 nanoSeconds isDst false fromTime_t -current 1319200918 0 milliSec 1319200918000 -2011.10.21 08:41:58 0 nanoSeconds isDst true +current 1323698306 0 milliSec 1323698306000 +2011.12.12 08:58:26 0 nanoSeconds isDst false diff --git a/test/testTimerAux b/test/testTimerAux index 3296fdf..4b07300 100644 --- a/test/testTimerAux +++ b/test/testTimerAux @@ -1,6 +1,6 @@ -one requested 0.400000 diff 0.400280 seconds -two requested 0.200000 diff 0.200272 seconds -one requested 0.200000 diff 0.200357 seconds -two requested 0.400000 diff 0.400289 seconds -one requested 0.000000 diff 0.000028 seconds -two requested 0.000000 diff 0.000044 seconds +one requested 0.400000 diff 0.400209 seconds +two requested 0.200000 diff 0.200265 seconds +one requested 0.200000 diff 0.200253 seconds +two requested 0.400000 diff 0.400278 seconds +one requested 0.000000 diff 0.000039 seconds +two requested 0.000000 diff 0.000060 seconds