18 Commits
7.1.0 ... 7.1.3

Author SHA1 Message Date
Michael Davidsaver
6da871fa64 7.1.3 2019-04-17 11:48:01 -07:00
Michael Davidsaver
d53cb0cbc9 doc 2019-04-17 11:47:56 -07:00
Michael Davidsaver
8f0111e482 fix ByteBuffer::putArray() and getArray()
Erroneous mixing of byte and element indexing
introduced by a51b308cc8
2019-04-08 09:46:23 -07:00
Michael Davidsaver
5525119778 test ByteBuffer array operations 2019-04-08 09:46:20 -07:00
Michael Davidsaver
6410600205 testByteBuffer cleanup 2019-04-08 09:46:16 -07:00
Michael Davidsaver
a5d44745d1 cleanup testSharedVector
"using namespace" considered harmful...
2019-04-08 09:46:07 -07:00
Michael Davidsaver
8c275cbc1c 7.1.2 2019-03-18 11:07:20 -07:00
Michael Davidsaver
b79f69231c more doxygen 2019-03-18 10:32:50 -07:00
Michael Davidsaver
ff165595c4 minor doc 2019-03-18 09:28:00 -07:00
Michael Davidsaver
12d851dc6f release notes for 7.1.1 2019-03-18 09:08:08 -07:00
Michael Davidsaver
643f289c23 missing include 2019-03-11 14:55:55 -07:00
Michael Davidsaver
68e74ed1d2 update release notes 2019-03-11 14:08:01 -07:00
Michael Davidsaver
f0ef0965c4 AnyScalar doc 2019-03-11 14:05:10 -07:00
Michael Davidsaver
61ce532fdf cleanup test 2019-03-11 14:05:05 -07:00
Michael Davidsaver
d746e1bfb3 minor 2019-03-11 14:04:53 -07:00
MJGaughran
deccc41b9a Disabled NEED_OLL_FUNCS for Visual Studio 2013+ (#64)
* Disabled NEED_OLL_FUNCS for Visual Studio 2013+

Both _MSC_VER (VC++ compiler version) and EPICS base version should be
checked for strtoll, strtoull definitions.

* NEED_OLL_FUNCS now defined only for VS builds
2019-03-02 11:11:42 -08:00
Michael Davidsaver
2814c779bd StandardField::getStandardField safety 2019-01-15 21:01:38 -08:00
Michael Davidsaver
4c73607799 cleanup StandardField 2019-01-15 21:01:38 -08:00
15 changed files with 327 additions and 651 deletions

View File

@@ -1,4 +1,4 @@
EPICS_PVD_MAJOR_VERSION = 7
EPICS_PVD_MINOR_VERSION = 1
EPICS_PVD_MAINTENANCE_VERSION = 0
EPICS_PVD_MAINTENANCE_VERSION = 3
EPICS_PVD_DEVELOPMENT_FLAG = 0

View File

@@ -38,7 +38,7 @@ PROJECT_NAME = "PVData C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 7.1.0
PROJECT_NUMBER = 7.1.3
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -319,7 +319,7 @@ AUTOLINK_SUPPORT = YES
# diagrams that involve STL classes more complete and accurate.
# The default value is: NO.
BUILTIN_STL_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
# If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support.
@@ -1001,7 +1001,7 @@ VERBATIM_HEADERS = YES
# compiled with the --with-libclang option.
# The default value is: NO.
CLANG_ASSISTED_PARSING = NO
CLANG_ASSISTED_PARSING = YES
# If clang assisted parsing is enabled you can provide the compiler with command
# line options that you would normally use when invoking the compiler. Note that
@@ -1948,7 +1948,7 @@ ENABLE_PREPROCESSING = YES
# The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
MACRO_EXPANSION = NO
MACRO_EXPANSION = YES
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
# the macro expansion is limited to the macros specified with the PREDEFINED and
@@ -1970,7 +1970,7 @@ SEARCH_INCLUDES = YES
# preprocessor.
# This tag requires that the tag SEARCH_INCLUDES is set to YES.
INCLUDE_PATH =
INCLUDE_PATH = ../src/misc ../src ../../../include/
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
@@ -1997,7 +1997,7 @@ PREDEFINED =
# definition found in the source code.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
EXPAND_AS_DEFINED =
EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
# remove all references to function-like macros that are alone on a line, have
@@ -2007,7 +2007,7 @@ EXPAND_AS_DEFINED =
# The default value is: YES.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
SKIP_FUNCTION_MACROS = YES
SKIP_FUNCTION_MACROS = NO
#---------------------------------------------------------------------------
# Configuration options related to external references
@@ -2026,7 +2026,7 @@ SKIP_FUNCTION_MACROS = YES
# the path). If a tag file is not located in the directory in which doxygen is
# run, you must also specify the path to the tagfile here.
TAGFILES = ../../../base-git/documentation/epics-base.tag
TAGFILES = "libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen"
# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
# tag file that is based on the input files it reads. See section "Linking to
@@ -2045,14 +2045,14 @@ ALLEXTERNALS = NO
# listed.
# The default value is: YES.
EXTERNAL_GROUPS = YES
EXTERNAL_GROUPS = NO
# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in
# the related pages index. If set to NO, only the current project's pages will
# be listed.
# The default value is: YES.
EXTERNAL_PAGES = YES
EXTERNAL_PAGES = NO
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of 'which perl').

View File

@@ -3,11 +3,14 @@ all: gen
clean:
rm -rf doxygen_sqlite3.db html
gen:
gen: libstdc++.tag
doxygen
commit: gen
touch html/.nojekyll
./commit-gh.sh documentation/html/ html/.nojekyll html/*.* html/search/*.*
libstdc++.tag:
wget -O $@ https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/libstdc++.tag
.PHONY: all clean gen commit

View File

@@ -3,7 +3,8 @@
/**
@mainpage pvDataCPP documentation
- [Download](https://sourceforge.net/projects/epics-pvdata/files/)
- This module is included in [EPICS Base releases](https://epics-controls.org/resources-and-support/base/) beginning with 7.0.1
- It may also be [Downloaded](https://github.com/epics-base/pvDataCPP/releases) and built separately.
- @htmlonly <a href="modules.html">API components</a> @endhtmlonly
- @ref release_notes

View File

@@ -2,8 +2,26 @@
@page release_notes Release Notes
Release 7.1.3 (Apr 2019)
========================
- Fix for array serialization error to/from big endian.
https://github.com/epics-base/pvDataCPP/issues/65
Release 7.1.2 (Mar 2019)
========================
- 7.1.1 tag pushed prematurely.
Release 7.1.1 (Mar 2019)
========================
- Fixes
- Init order issue with StandardField::getStandardField()
- Build fix for Visual Studio 2013+
Release 7.1.0 (Nov 2018)
==========================
========================
- Deprecations
- BoundedString, BoundedScalarArray, and FixedScalarArray will be removed unless they are fixed.

View File

@@ -33,8 +33,6 @@ using std::string;
namespace epics { namespace pvData {
static DebugLevel debugLevel = lowDebug;
size_t Field::num_instances;
@@ -405,9 +403,7 @@ StructureArray::StructureArray(StructureConstPtr const & structure)
{
}
StructureArray::~StructureArray() {
if(debugLevel==highDebug) printf("~StructureArray\n");
}
StructureArray::~StructureArray() {}
string StructureArray::getID() const
{
@@ -444,9 +440,7 @@ UnionArray::UnionArray(UnionConstPtr const & _punion)
{
}
UnionArray::~UnionArray() {
if(debugLevel==highDebug) printf("~UnionArray\n");
}
UnionArray::~UnionArray() {}
string UnionArray::getID() const
{

View File

@@ -11,6 +11,7 @@
#include <stdexcept>
#include <epicsMutex.h>
#include <epicsThread.h>
#define epicsExportSharedSymbols
#include <pv/lock.h>
@@ -22,32 +23,85 @@ using std::string;
namespace epics { namespace pvData {
static
StructureConstPtr buildValueAlarm(ScalarType vtype)
{
return FieldBuilder::begin()
->setId("valueAlarm_t")
->add("active", pvBoolean)
->add("lowAlarmLimit", vtype)
->add("lowWarningLimit", vtype)
->add("highWarningLimit", vtype)
->add("highAlarmLimit", vtype)
->add("lowAlarmSeverity", pvInt)
->add("lowWarningSeverity", pvInt)
->add("highWarningSeverity", pvInt)
->add("highAlarmSeverity", pvInt)
->add("hysteresis", pvByte)
->createStructure();
}
StandardField::StandardField()
: fieldCreate(getFieldCreate()),
notImplemented("not implemented"),
valueFieldName("value")
{}
:fieldCreate(getFieldCreate())
,notImplemented("not implemented")
,valueFieldName("value")
void StandardField::init()
{
createAlarm();
createTimeStamp();
createDisplay();
createControl();
createBooleanAlarm();
createByteAlarm();
createShortAlarm();
createIntAlarm();
createLongAlarm();
createUByteAlarm();
createUShortAlarm();
createUIntAlarm();
createULongAlarm();
createFloatAlarm();
createDoubleAlarm();
createEnumeratedAlarm();
}
,alarmField(FieldBuilder::begin()
->setId("alarm_t")
->add("severity", pvInt)
->add("status", pvInt)
->add("message", pvString)
->createStructure())
,timeStampField(FieldBuilder::begin()
->setId("time_t")
->add("secondsPastEpoch", pvLong)
->add("nanoseconds", pvInt)
->add("userTag", pvInt)
->createStructure())
,displayField(FieldBuilder::begin()
->setId("display_t")
->add("limitLow", pvDouble)
->add("limitHigh", pvDouble)
->add("description", pvString)
->add("format", pvString)
->add("units", pvString)
->createStructure())
,controlField(FieldBuilder::begin()
->setId("control_t")
->add("limitLow", pvDouble)
->add("limitHigh", pvDouble)
->add("minStep", pvDouble)
->createStructure())
,booleanAlarmField(FieldBuilder::begin()
->setId("valueAlarm_t")
->add("active", pvBoolean)
->add("falseSeverity", pvInt)
->add("trueSeverity", pvInt)
->add("changeStateSeverity", pvInt)
->createStructure())
,byteAlarmField(buildValueAlarm(pvByte))
,shortAlarmField(buildValueAlarm(pvShort))
,intAlarmField(buildValueAlarm(pvInt))
,longAlarmField(buildValueAlarm(pvLong))
,ubyteAlarmField(buildValueAlarm(pvUByte))
,ushortAlarmField(buildValueAlarm(pvUShort))
,uintAlarmField(buildValueAlarm(pvUInt))
,ulongAlarmField(buildValueAlarm(pvULong))
,floatAlarmField(buildValueAlarm(pvFloat))
,doubleAlarmField(buildValueAlarm(pvDouble))
,enumeratedAlarmField(FieldBuilder::begin()
->setId("valueAlarm_t")
->add("active", pvBoolean)
->add("stateSeverity", pvInt)
->add("changeStateSeverity", pvInt)
->createStructure())
{}
StandardField::~StandardField(){}
@@ -145,361 +199,6 @@ StructureConstPtr StandardField::createProperties(string id,FieldConstPtr field,
return fieldCreate->createStructure(id,names,fields);
}
void StandardField::createAlarm() {
size_t num = 3;
FieldConstPtrArray fields(num);
StringArray names(num);
names[0] = "severity";
names[1] = "status";
names[2] = "message";
fields[0] = fieldCreate->createScalar(pvInt);
fields[1] = fieldCreate->createScalar(pvInt);
fields[2] = fieldCreate->createScalar(pvString);
alarmField = fieldCreate->createStructure("alarm_t",names,fields);
}
void StandardField::createTimeStamp() {
size_t num = 3;
FieldConstPtrArray fields(num);
StringArray names(num);
names[0] = "secondsPastEpoch";
names[1] = "nanoseconds";
names[2] = "userTag";
fields[0] = fieldCreate->createScalar(pvLong);
fields[1] = fieldCreate->createScalar(pvInt);
fields[2] = fieldCreate->createScalar(pvInt);
timeStampField = fieldCreate->createStructure("time_t",names,fields);
}
void StandardField::createDisplay() {
size_t num = 5;
FieldConstPtrArray fields(num);
StringArray names(num);
names[0] = "limitLow";
names[1] = "limitHigh";
names[2] = "description";
names[3] = "format";
names[4] = "units";
fields[0] = fieldCreate->createScalar(pvDouble);
fields[1] = fieldCreate->createScalar(pvDouble);
fields[2] = fieldCreate->createScalar(pvString);
fields[3] = fieldCreate->createScalar(pvString);
fields[4] = fieldCreate->createScalar(pvString);
displayField = fieldCreate->createStructure("display_t",names,fields);
}
void StandardField::createControl() {
size_t num = 3;
FieldConstPtrArray fields(num);
StringArray names(num);
names[0] = "limitLow";
names[1] = "limitHigh";
names[2] = "minStep";
fields[0] = fieldCreate->createScalar(pvDouble);
fields[1] = fieldCreate->createScalar(pvDouble);
fields[2] = fieldCreate->createScalar(pvDouble);
controlField = fieldCreate->createStructure("control_t",names,fields);
}
void StandardField::createBooleanAlarm() {
size_t numFields = 4;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "falseSeverity";
names[2] = "trueSeverity";
names[3] = "changeStateSeverity";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvInt);
fields[2] = fieldCreate->createScalar(pvInt);
fields[3] = fieldCreate->createScalar(pvInt);
booleanAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createByteAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvByte);
fields[2] = fieldCreate->createScalar(pvByte);
fields[3] = fieldCreate->createScalar(pvByte);
fields[4] = fieldCreate->createScalar(pvByte);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvByte);
byteAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createShortAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvShort);
fields[2] = fieldCreate->createScalar(pvShort);
fields[3] = fieldCreate->createScalar(pvShort);
fields[4] = fieldCreate->createScalar(pvShort);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvShort);
shortAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createIntAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvInt);
fields[2] = fieldCreate->createScalar(pvInt);
fields[3] = fieldCreate->createScalar(pvInt);
fields[4] = fieldCreate->createScalar(pvInt);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvInt);
intAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createLongAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvLong);
fields[2] = fieldCreate->createScalar(pvLong);
fields[3] = fieldCreate->createScalar(pvLong);
fields[4] = fieldCreate->createScalar(pvLong);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvLong);
longAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createUByteAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvUByte);
fields[2] = fieldCreate->createScalar(pvUByte);
fields[3] = fieldCreate->createScalar(pvUByte);
fields[4] = fieldCreate->createScalar(pvUByte);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvUByte);
ubyteAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createUShortAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvUShort);
fields[2] = fieldCreate->createScalar(pvUShort);
fields[3] = fieldCreate->createScalar(pvUShort);
fields[4] = fieldCreate->createScalar(pvUShort);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvUShort);
ushortAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createUIntAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvUInt);
fields[2] = fieldCreate->createScalar(pvUInt);
fields[3] = fieldCreate->createScalar(pvUInt);
fields[4] = fieldCreate->createScalar(pvUInt);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvUInt);
uintAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createULongAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvULong);
fields[2] = fieldCreate->createScalar(pvULong);
fields[3] = fieldCreate->createScalar(pvULong);
fields[4] = fieldCreate->createScalar(pvULong);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvULong);
ulongAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createFloatAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvFloat);
fields[2] = fieldCreate->createScalar(pvFloat);
fields[3] = fieldCreate->createScalar(pvFloat);
fields[4] = fieldCreate->createScalar(pvFloat);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvFloat);
floatAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createDoubleAlarm() {
size_t numFields = 10;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "lowAlarmLimit";
names[2] = "lowWarningLimit";
names[3] = "highWarningLimit";
names[4] = "highAlarmLimit";
names[5] = "lowAlarmSeverity";
names[6] = "lowWarningSeverity";
names[7] = "highWarningSeverity";
names[8] = "highAlarmSeverity";
names[9] = "hysteresis";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalar(pvDouble);
fields[2] = fieldCreate->createScalar(pvDouble);
fields[3] = fieldCreate->createScalar(pvDouble);
fields[4] = fieldCreate->createScalar(pvDouble);
fields[5] = fieldCreate->createScalar(pvInt);
fields[6] = fieldCreate->createScalar(pvInt);
fields[7] = fieldCreate->createScalar(pvInt);
fields[8] = fieldCreate->createScalar(pvInt);
fields[9] = fieldCreate->createScalar(pvDouble);
doubleAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
void StandardField::createEnumeratedAlarm() {
size_t numFields = 3;
FieldConstPtrArray fields(numFields);
StringArray names(numFields);
names[0] = "active";
names[1] = "stateSeverity";
names[2] = "changeStateSeverity";
fields[0] = fieldCreate->createScalar(pvBoolean);
fields[1] = fieldCreate->createScalarArray(pvInt);
fields[2] = fieldCreate->createScalar(pvInt);
enumeratedAlarmField = fieldCreate->createStructure("valueAlarm_t",names,fields);
}
StructureConstPtr StandardField::scalar(
ScalarType type,string const &properties)
{
@@ -564,98 +263,21 @@ StructureConstPtr StandardField::enumerated(string const &properties)
return createProperties("epics:nt/NTEnum:1.0",field,properties);
}
StructureConstPtr StandardField::alarm()
{
return alarmField;
}
static StandardFieldPtr *stdFieldGbl;
StructureConstPtr StandardField::timeStamp()
{
return timeStampField;
}
static epicsThreadOnceId stdFieldGblOnce = EPICS_THREAD_ONCE_INIT;
StructureConstPtr StandardField::display()
void StandardField::once(void*)
{
return displayField;
}
StructureConstPtr StandardField::control()
{
return controlField;
}
StructureConstPtr StandardField::booleanAlarm()
{
return booleanAlarmField;
}
StructureConstPtr StandardField::byteAlarm()
{
return byteAlarmField;
}
StructureConstPtr StandardField::ubyteAlarm()
{
return ubyteAlarmField;
}
StructureConstPtr StandardField::shortAlarm()
{
return shortAlarmField;
}
StructureConstPtr StandardField::ushortAlarm()
{
return ushortAlarmField;
}
StructureConstPtr StandardField::intAlarm()
{
return intAlarmField;
}
StructureConstPtr StandardField::uintAlarm()
{
return uintAlarmField;
}
StructureConstPtr StandardField::longAlarm()
{
return longAlarmField;
}
StructureConstPtr StandardField::ulongAlarm()
{
return ulongAlarmField;
}
StructureConstPtr StandardField::floatAlarm()
{
return floatAlarmField;
}
StructureConstPtr StandardField::doubleAlarm()
{
return doubleAlarmField;
}
StructureConstPtr StandardField::enumeratedAlarm()
{
return enumeratedAlarmField;
stdFieldGbl = new StandardFieldPtr;
stdFieldGbl->reset(new StandardField);
}
const StandardFieldPtr &StandardField::getStandardField()
{
static StandardFieldPtr standardFieldCreate;
static Mutex mutex;
Lock xx(mutex);
epicsThreadOnce(&stdFieldGblOnce, &StandardField::once, 0);
if(standardFieldCreate.get()==0)
{
standardFieldCreate = StandardFieldPtr(new StandardField());
standardFieldCreate->init();
}
return standardFieldCreate;
return *stdFieldGbl;
}
}}

View File

@@ -254,7 +254,7 @@ epicsParseFloat(const char *str, float *to, char **units)
#endif
// Sometimes we have to provide our own copy of strtoll()
#if defined(_WIN32) && !defined(_MINGW)
#if defined(_MSC_VER) && _MSC_VER < 1800
// On Windows with MSVC, Base-3.15 provides strtoll()
# define NEED_OLL_FUNCS (EPICS_VERSION_INT < VERSION_INT(3,15,0,1))
#elif defined(vxWorks)

View File

@@ -180,10 +180,11 @@ public:
/** Return typed reference to wrapped value. Non-const reference allows value modification
*
* @throws bad_cast when the requested type does not match the stored type
@code
AnyScalar v(42);
v.ref<uint32>() = 42;
assert(v.ref<uint32>() = 43);
v.ref<uint32>() = 43;
assert(v.ref<uint32>() == 43);
@endcode
*/
template<typename T>
@@ -201,9 +202,10 @@ public:
/** Return typed reference to wrapped value. Const reference does not allow modification.
*
* @throws bad_cast when the requested type does not match the stored type
@code
AnyScalar v(42);
assert(v.ref<uint32>() = 42);
const AnyScalar v(42);
assert(v.ref<uint32>() == 42);
@endcode
*/
template<typename T>
@@ -219,7 +221,10 @@ public:
return reinterpret_cast<typename meta::decorate_const<TT>::type&>(_wrap.blob);
}
/** copy out wrapped value, with a value conversion. */
/** copy out wrapped value, with a value conversion.
*
* @throws bad_cast when empty()==true
*/
template<typename T>
inline
T as() const {

View File

@@ -803,8 +803,8 @@ private:
assert(n<=getRemaining());
if (reverse<T>()) {
for(std::size_t i=0; i<n; i+=sizeof(T)) {
detail::store_unaligned(_position+i, swap<T>(values[i]));
for(std::size_t i=0; i<count; i++) {
detail::store_unaligned(_position+i*sizeof(T), swap<T>(values[i]));
}
} else {
memcpy(_position, values, n);
@@ -819,8 +819,8 @@ private:
assert(n<=getRemaining());
if (reverse<T>()) {
for(std::size_t i=0; i<n; i+=sizeof(T)) {
values[i] = swap<T>(detail::load_unaligned<T>(_position+i));
for(std::size_t i=0; i<count; i++) {
values[i] = swap<T>(detail::load_unaligned<T>(_position+i*sizeof(T)));
}
} else {
memcpy(values, _position, n);

View File

@@ -28,7 +28,7 @@
public:
...
};
@code
@endcode
*
* @note This macro contains 'private:'.
*/

View File

@@ -61,6 +61,7 @@ typedef std::tr1::shared_ptr<StandardField> StandardFieldPtr;
* }
*/
class epicsShareClass StandardField {
static void once(void*);
public:
/**
* getStandardField returns the singleton.
@@ -131,123 +132,105 @@ public:
* create an alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr alarm();
inline const StructureConstPtr& alarm() const { return alarmField; }
/**
* create a timeStamp structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr timeStamp();
inline const StructureConstPtr& timeStamp() const { return timeStampField; }
/**
* create a display structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr display();
inline const StructureConstPtr& display() const { return displayField; }
/**
* create a control structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr control();
inline const StructureConstPtr& control() const { return controlField; }
/**
* create a boolean alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr booleanAlarm();
inline const StructureConstPtr& booleanAlarm() const { return booleanAlarmField; }
/**
* create a byte alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr byteAlarm();
inline const StructureConstPtr& byteAlarm() const { return byteAlarmField; }
/**
* create a unsigned byte alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr ubyteAlarm();
inline const StructureConstPtr& ubyteAlarm() const { return ubyteAlarmField; }
/**
* create a short alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr shortAlarm();
inline const StructureConstPtr& shortAlarm() const { return shortAlarmField; }
/**
* create a unsigned short alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr ushortAlarm();
inline const StructureConstPtr& ushortAlarm() const { return ushortAlarmField; }
/**
* create an int alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr intAlarm();
inline const StructureConstPtr& intAlarm() const { return intAlarmField; }
/**
* create a unsigned int alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr uintAlarm();
inline const StructureConstPtr& uintAlarm() const { return uintAlarmField; }
/**
* create a long alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr longAlarm();
inline const StructureConstPtr& longAlarm() const { return longAlarmField; }
/**
* create a unsigned long alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr ulongAlarm();
inline const StructureConstPtr& ulongAlarm() const { return ulongAlarmField; }
/**
* create a float alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr floatAlarm();
inline const StructureConstPtr& floatAlarm() const { return floatAlarmField; }
/**
* create a double alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr doubleAlarm();
inline const StructureConstPtr& doubleAlarm() const { return doubleAlarmField; }
/**
* create an enumerated alarm structure
* @return The const shared pointer to the structure.
*/
StructureConstPtr enumeratedAlarm();
inline const StructureConstPtr& enumeratedAlarm() const { return enumeratedAlarmField; }
private:
StandardField();
void init();
StructureConstPtr createProperties(
std::string id,FieldConstPtr field,std::string properties);
FieldCreatePtr fieldCreate;
std::string notImplemented;
std::string valueFieldName;
StructureConstPtr alarmField;
StructureConstPtr timeStampField;
StructureConstPtr displayField;
StructureConstPtr controlField;
StructureConstPtr booleanAlarmField;
StructureConstPtr byteAlarmField;
StructureConstPtr shortAlarmField;
StructureConstPtr intAlarmField;
StructureConstPtr longAlarmField;
StructureConstPtr ubyteAlarmField;
StructureConstPtr ushortAlarmField;
StructureConstPtr uintAlarmField;
StructureConstPtr ulongAlarmField;
StructureConstPtr floatAlarmField;
StructureConstPtr doubleAlarmField;
StructureConstPtr enumeratedAlarmField;
void createAlarm();
void createTimeStamp();
void createDisplay();
void createControl();
void createBooleanAlarm();
void createByteAlarm();
void createShortAlarm();
void createIntAlarm();
void createLongAlarm();
void createUByteAlarm();
void createUShortAlarm();
void createUIntAlarm();
void createULongAlarm();
void createFloatAlarm();
void createDoubleAlarm();
void createEnumeratedAlarm();
//friend StandardFieldPtr getStandardField();
const FieldCreatePtr fieldCreate;
const std::string notImplemented;
const std::string valueFieldName;
const StructureConstPtr alarmField;
const StructureConstPtr timeStampField;
const StructureConstPtr displayField;
const StructureConstPtr controlField;
const StructureConstPtr booleanAlarmField;
const StructureConstPtr byteAlarmField;
const StructureConstPtr shortAlarmField;
const StructureConstPtr intAlarmField;
const StructureConstPtr longAlarmField;
const StructureConstPtr ubyteAlarmField;
const StructureConstPtr ushortAlarmField;
const StructureConstPtr uintAlarmField;
const StructureConstPtr ulongAlarmField;
const StructureConstPtr floatAlarmField;
const StructureConstPtr doubleAlarmField;
const StructureConstPtr enumeratedAlarmField;
};
FORCE_INLINE const StandardFieldPtr& getStandardField() {

View File

@@ -14,15 +14,13 @@
#include <cstring>
#include <memory>
#include <epicsUnitTest.h>
#include <testMain.h>
#include <pv/pvUnitTest.h>
#include <pv/byteBuffer.h>
#include <pv/pvIntrospect.h>
using namespace epics::pvData;
using std::string;
using std::cout;
static
void testBasicOperations() {
@@ -175,7 +173,7 @@ void testBasicOperations() {
testOk1(buff->getPosition()==6);
testOk1(strncmp(&src[2],&dst[2],6)==0);
cout<<"# First 10 characters of destination: >>"<<string(dst, 10)<<"<<\n";
testShow()<<"First 10 characters of destination: >>"<<std::string(dst, 10)<<"<<\n";
}
static const char expect_be[] = "abcdef";
@@ -253,14 +251,68 @@ void testUnaligned()
testOk1(memcmp(buf.getBuffer(), "\x42\x12\x34\x56\x78\x90\xab\xcd\xef\x41\x41\x41", 8)==0);
}
static
void testArrayLE()
{
testDiag("testArray() LE");
ByteBuffer buf(8, EPICS_ENDIAN_LITTLE);
std::vector<uint32> vals;
vals.push_back(0x12345678);
vals.push_back(0x01020304);
buf.putArray(&vals[0], vals.size());
testEqual(buf.getPosition(), 8);
testOk1(memcmp(buf.getBuffer(), "\x78\x56\x34\x12\x04\x03\x02\x01", 8)==0);
buf.clear();
buf.put("\x40\x30\x20\x10\xa4\xa3\xa2\xa1", 0, 8);
buf.flip();
buf.getArray(&vals[0], 2);
testEqual(vals[0], 0x10203040);
testEqual(vals[1], 0xa1a2a3a4);
}
static
void testArrayBE()
{
testDiag("testArray() BE");
ByteBuffer buf(8, EPICS_ENDIAN_BIG);
std::vector<uint32> vals;
vals.push_back(0x12345678);
vals.push_back(0x01020304);
buf.putArray(&vals[0], vals.size());
testEqual(buf.getPosition(), 8);
testOk1(memcmp(buf.getBuffer(), "\x12\x34\x56\x78\x01\x02\x03\x04", 8)==0);
buf.clear();
buf.put("\x10\x20\x30\x40\xa1\xa2\xa3\xa4", 0, 8);
buf.flip();
buf.getArray(&vals[0], 2);
testEqual(vals[0], 0x10203040);
testEqual(vals[1], 0xa1a2a3a4);
}
MAIN(testByteBuffer)
{
testPlan(96);
testPlan(104);
testDiag("Tests byteBuffer");
testBasicOperations();
testInverseEndianness(EPICS_ENDIAN_BIG, expect_be);
testInverseEndianness(EPICS_ENDIAN_LITTLE, expect_le);
testSwap();
testUnaligned();
testArrayLE();
testArrayBE();
return testDone();
}

View File

@@ -17,15 +17,14 @@
#include "pv/sharedVector.h"
using std::string;
using namespace epics::pvData;
namespace {
namespace pvd = epics::pvData;
void testEmpty()
{
testDiag("Test empty vector");
epics::pvData::shared_vector<int32> empty, empty2, empty3(0u);
pvd::shared_vector<pvd::int32> empty, empty2, empty3(0u);
testOk1(empty.size()==0);
testOk1(empty.empty());
@@ -47,7 +46,7 @@ void testInternalAlloc()
{
testDiag("Test vector alloc w/ new[]");
epics::pvData::shared_vector<int32> internal(5);
pvd::shared_vector<pvd::int32> internal(5);
testOk1(internal.size()==5);
testOk1(!internal.empty());
@@ -62,7 +61,7 @@ void testInternalAlloc()
internal[2] = 42;
testOk1(internal[2]==42);
epics::pvData::shared_vector<int32> internal2(15, 500);
pvd::shared_vector<pvd::int32> internal2(15, 500);
testOk1(internal2.size()==15);
testOk1(internal2[1]==500);
@@ -83,8 +82,8 @@ void testInternalAlloc()
//Note: STL shared_ptr requires that deletors be copy constructable
template<typename E>
struct callCounter {
std::tr1::shared_ptr<int32> count;
callCounter():count(new int32){*count=0;}
std::tr1::shared_ptr<pvd::int32> count;
callCounter():count(new pvd::int32){*count=0;}
callCounter(const callCounter& o):count(o.count) {}
callCounter& operator=(const callCounter& o){count=o.count;}
void operator()(E){(*count)++;}
@@ -95,8 +94,8 @@ void testExternalAlloc()
testDiag("Test vector external alloc");
// Simulate a failed malloc() or similar
int32 *oops=0;
epics::pvData::shared_vector<int32> nullPtr(oops, 42, 100);
pvd::int32 *oops=0;
pvd::shared_vector<pvd::int32> nullPtr(oops, 42, 100);
testOk1(nullPtr.size()==0);
testOk1(nullPtr.empty());
@@ -105,8 +104,8 @@ void testExternalAlloc()
testOk1(nullPtr.data()==NULL);
int32 *raw=new int32[5];
epics::pvData::shared_vector<int32> newData(raw, 1, 4);
pvd::int32 *raw=new pvd::int32[5];
pvd::shared_vector<pvd::int32> newData(raw, 1, 4);
testOk1(newData.size()==4);
testOk1(!newData.empty());
@@ -116,11 +115,11 @@ void testExternalAlloc()
testOk1(newData[0]==14);
// Check use of custom deleter
int32 localVar[4] = {1,2,3,4};
callCounter<int32*> tracker;
pvd::int32 localVar[4] = {1,2,3,4};
callCounter<pvd::int32*> tracker;
testOk1(*tracker.count==0);
epics::pvData::shared_vector<int32> locvar(localVar,
pvd::shared_vector<pvd::int32> locvar(localVar,
tracker,
0, 4);
@@ -140,8 +139,8 @@ void testShare()
{
testDiag("Test vector Sharing");
epics::pvData::shared_vector<int32> one, two(15);
epics::pvData::shared_vector<int32> three(two);
pvd::shared_vector<pvd::int32> one, two(15);
pvd::shared_vector<pvd::int32> three(two);
testOk1(one.unique());
testOk1(!two.unique());
@@ -202,22 +201,22 @@ void testConst()
{
testDiag("Test constant vector");
epics::pvData::shared_vector<int32> writable(15, 100);
pvd::shared_vector<pvd::int32> writable(15, 100);
epics::pvData::shared_vector<int32>::reference wr = writable[0];
epics::pvData::shared_vector<int32>::const_reference ror = writable[0];
pvd::shared_vector<pvd::int32>::reference wr = writable[0];
pvd::shared_vector<pvd::int32>::const_reference ror = writable[0];
testOk1(wr==ror);
int32 *compare = writable.data();
pvd::int32 *compare = writable.data();
testOk1(writable.unique());
// can re-target container, but data is R/O
epics::pvData::shared_vector<const int32> rodata(freeze(writable));
pvd::shared_vector<const pvd::int32> rodata(freeze(writable));
epics::pvData::shared_vector<const int32>::reference wcr = rodata[0];
epics::pvData::shared_vector<const int32>::const_reference rocr = rodata[0];
pvd::shared_vector<const pvd::int32>::reference wcr = rodata[0];
pvd::shared_vector<const pvd::int32>::const_reference rocr = rodata[0];
testOk1(wcr==rocr);
@@ -230,7 +229,7 @@ void testConst()
testOk1(rodata.data()==compare);
epics::pvData::shared_vector<const int32> rodata2(rodata);
pvd::shared_vector<const pvd::int32> rodata2(rodata);
testOk1(rodata.data()==rodata2.data());
@@ -243,9 +242,9 @@ void testSlice()
{
testDiag("Test vector slicing");
epics::pvData::shared_vector<int32> original(10, 100);
pvd::shared_vector<pvd::int32> original(10, 100);
epics::pvData::shared_vector<int32> half1(original), half2(original), half2a(original);
pvd::shared_vector<pvd::int32> half1(original), half2(original), half2a(original);
half1.slice(0, 5);
half2.slice(5, 5);
@@ -293,9 +292,9 @@ void testCapacity()
{
testDiag("Test vector capacity");
epics::pvData::shared_vector<int32> vect(10, 100);
pvd::shared_vector<pvd::int32> vect(10, 100);
int32 *peek = vect.dataPtr().get();
pvd::int32 *peek = vect.dataPtr().get();
vect.slice(0, 5);
@@ -333,7 +332,7 @@ void testCapacity()
void testPush()
{
epics::pvData::shared_vector<int32> vect;
pvd::shared_vector<pvd::int32> vect;
testDiag("Test push_back optimizations");
@@ -360,16 +359,16 @@ void testVoid()
{
testDiag("Test vector cast to/from void");
epics::pvData::shared_vector<int32> IV(4);
pvd::shared_vector<pvd::int32> IV(4);
epics::pvData::shared_vector<void> VV(epics::pvData::static_shared_vector_cast<void>(IV));
pvd::shared_vector<void> VV(pvd::static_shared_vector_cast<void>(IV));
testOk1(IV.dataPtr().get()==VV.dataPtr().get());
testOk1(IV.size()*sizeof(int)==VV.size());
testOk1(IV.size()*sizeof(pvd::int32)==VV.size());
VV.slice(sizeof(int), 2*sizeof(int));
VV.slice(sizeof(pvd::int32), 2*sizeof(pvd::int32));
IV = epics::pvData::static_shared_vector_cast<int32>(VV);
IV = pvd::static_shared_vector_cast<pvd::int32>(VV);
testOk1(IV.dataOffset()==1);
testOk1(IV.size()==2);
@@ -380,23 +379,23 @@ void testConstVoid()
{
testDiag("Test vector cast to/from const void");
epics::pvData::shared_vector<const int32> CIV(4);
pvd::shared_vector<const pvd::int32> CIV(4);
epics::pvData::shared_vector<const void> CVV(epics::pvData::static_shared_vector_cast<const void>(CIV));
pvd::shared_vector<const void> CVV(pvd::static_shared_vector_cast<const void>(CIV));
// case const void to const void
epics::pvData::shared_vector<const void> CVV2(epics::pvData::static_shared_vector_cast<const void>(CVV));
pvd::shared_vector<const void> CVV2(pvd::static_shared_vector_cast<const void>(CVV));
testOk1(CIV.dataPtr().get()==CVV2.dataPtr().get());
testOk1(CIV.size()*sizeof(int)==CVV2.size());
CVV2.slice(sizeof(int), 2*sizeof(int));
CIV = epics::pvData::static_shared_vector_cast<const int32>(CVV2);
CIV = pvd::static_shared_vector_cast<const pvd::int32>(CVV2);
testOk1(CIV.dataOffset()==1);
testOk1(CIV.size()==2);
epics::pvData::shared_vector<void> VV;
pvd::shared_vector<void> VV;
// not possible to thaw() void as shared_vector<void> has no make_unique()
//VV = thaw(CVV);
CVV = freeze(VV);
@@ -408,8 +407,8 @@ void testNonPOD()
{
testDiag("Test vector of non-POD types");
epics::pvData::shared_vector<string> strings(6);
epics::pvData::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs(5);
pvd::shared_vector<std::string> strings(6);
pvd::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs(5);
testOk1(strings[0].empty());
testOk1(structs[0].get()==NULL);
@@ -417,7 +416,7 @@ void testNonPOD()
structs[1].reset(new dummyStruct);
dummyStruct *temp = structs[1].get();
epics::pvData::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs2(structs);
pvd::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs2(structs);
testOk1(!structs.unique());
testOk1(structs[1].unique());
@@ -436,22 +435,22 @@ void testVectorConvert()
{
testDiag("Test shared_vector_convert");
epics::pvData::shared_vector<int32> ints(6, 42), moreints;
epics::pvData::shared_vector<float> floats;
epics::pvData::shared_vector<string> strings;
epics::pvData::shared_vector<void> voids;
pvd::shared_vector<pvd::int32> ints(6, 42), moreints;
pvd::shared_vector<float> floats;
pvd::shared_vector<std::string> strings;
pvd::shared_vector<void> voids;
testOk1(ints.unique());
// no-op convert. Just returns another reference
moreints = epics::pvData::shared_vector_convert<int32>(ints);
moreints = pvd::shared_vector_convert<pvd::int32>(ints);
testOk1(!ints.unique());
moreints.clear();
// conversion when both types are known.
// returns a new vector
floats = epics::pvData::shared_vector_convert<float>(ints);
floats = pvd::shared_vector_convert<float>(ints);
testOk1(ints.unique());
testOk1(floats.size()==ints.size());
@@ -459,16 +458,16 @@ void testVectorConvert()
// convert to void is static_shared_vector_cast<void>()
// returns a reference
voids = epics::pvData::shared_vector_convert<void>(ints);
voids = pvd::shared_vector_convert<void>(ints);
testOk1(!ints.unique());
testOk1(voids.size()==ints.size()*sizeof(int32));
testOk1(voids.size()==ints.size()*sizeof(pvd::int32));
// convert from void uses shared_vector<void>::original_type()
// to find that the actual type is 'int32'.
// returns a new vector
testOk1(voids.original_type()==epics::pvData::pvInt);
strings = epics::pvData::shared_vector_convert<string>(voids);
testOk1(voids.original_type()==pvd::pvInt);
strings = pvd::shared_vector_convert<std::string>(voids);
voids.clear();
@@ -481,11 +480,11 @@ void testWeak()
{
testDiag("Test weak_ptr counting");
epics::pvData::shared_vector<int32> data(6);
pvd::shared_vector<pvd::int32> data(6);
testOk1(data.unique());
std::tr1::shared_ptr<int32> pdata(data.dataPtr());
std::tr1::shared_ptr<pvd::int32> pdata(data.dataPtr());
testOk1(!data.unique());
@@ -493,7 +492,7 @@ void testWeak()
testOk1(data.unique());
std::tr1::weak_ptr<int32> wdata(data.dataPtr());
std::tr1::weak_ptr<pvd::int32> wdata(data.dataPtr());
testOk1(data.unique()); // True, but I wish it wasn't!!!
@@ -506,16 +505,16 @@ void testICE()
{
testDiag("Test freeze and thaw");
epics::pvData::shared_vector<int32> A(6, 42), C;
epics::pvData::shared_vector<const int32> B, D;
pvd::shared_vector<pvd::int32> A(6, 42), C;
pvd::shared_vector<const pvd::int32> B, D;
int32 *check = A.data();
pvd::int32 *check = A.data();
// check freeze w/ unique reference
// clears A and moves reference to B
// no copy
B = epics::pvData::freeze(A);
B = pvd::freeze(A);
testOk1(A.unique());
testOk1(B.unique());
@@ -528,7 +527,7 @@ void testICE()
// clears D, but reference to B
// remains, so a copy is made
C = epics::pvData::thaw(D);
C = pvd::thaw(D);
testOk1(B.unique());
testOk1(C.unique());
@@ -542,7 +541,7 @@ void testICE()
// clears B and moves reference to A
// no copy
A = epics::pvData::thaw(B);
A = pvd::thaw(B);
testOk1(A.unique());
testOk1(B.unique());
@@ -559,7 +558,7 @@ void testICE()
// would clear A, but remaining reference C
// fails operation. A not cleared
// and exception thrown
B = epics::pvData::freeze(A);
B = pvd::freeze(A);
testFail("Froze non-unique vector!");
} catch(std::runtime_error& e) {
testPass("freeze of non-unique throws runtime_error as expected");
@@ -568,12 +567,12 @@ void testICE()
void testBad()
{
epics::pvData::shared_vector<int> I;
epics::pvData::shared_vector<const int> CI;
epics::pvData::shared_vector<float> F;
epics::pvData::shared_vector<const float> CF;
epics::pvData::shared_vector<void> V;
epics::pvData::shared_vector<const void> CV;
pvd::shared_vector<int> I;
pvd::shared_vector<const int> CI;
pvd::shared_vector<float> F;
pvd::shared_vector<const float> CF;
pvd::shared_vector<void> V;
pvd::shared_vector<const void> CV;
(void)I;
(void)CI;
(void)F;
@@ -588,38 +587,38 @@ void testBad()
// No copy from const to non-const
//CI = I;
//I = CI;
//epics::pvData::shared_vector<const int> CI2(I);
//epics::pvData::shared_vector<int> I2(CI);
//pvd::shared_vector<const int> CI2(I);
//pvd::shared_vector<int> I2(CI);
// shared_vector_convert can't thaw()
//I = epics::pvData::shared_vector_convert<int>(CI);
//V = epics::pvData::shared_vector_convert<void>(CV);
//I = pvd::shared_vector_convert<int>(CI);
//V = pvd::shared_vector_convert<void>(CV);
// shared_vector_convert can't freeze()
//CI = epics::pvData::shared_vector_convert<const int>(I);
//CV = epics::pvData::shared_vector_convert<const void>(V);
//CI = pvd::shared_vector_convert<const int>(I);
//CV = pvd::shared_vector_convert<const void>(V);
// static_shared_vector_cast can't thaw()
//I = epics::pvData::static_shared_vector_cast<int>(CI);
//V = epics::pvData::static_shared_vector_cast<void>(CV);
//I = pvd::static_shared_vector_cast<int>(CI);
//V = pvd::static_shared_vector_cast<void>(CV);
// static_shared_vector_cast can't freeze()
//CI = epics::pvData::static_shared_vector_cast<const int>(I);
//CV = epics::pvData::static_shared_vector_cast<const void>(V);
//CI = pvd::static_shared_vector_cast<const int>(I);
//CV = pvd::static_shared_vector_cast<const void>(V);
// freeze() can't change type.
// the error here will be with the assignment
//I = epics::pvData::freeze(CV);
//I = epics::pvData::freeze(CF);
//CI = epics::pvData::freeze(V);
//CI = epics::pvData::freeze(F);
//I = pvd::freeze(CV);
//I = pvd::freeze(CF);
//CI = pvd::freeze(V);
//CI = pvd::freeze(F);
// that() can't change type.
// the error here will be with the assignment
//CI = epics::pvData::thaw(V);
//CI = epics::pvData::thaw(F);
//I = epics::pvData::thaw(CV);
//I = epics::pvData::that(CF);
//CI = pvd::thaw(V);
//CI = pvd::thaw(F);
//I = pvd::thaw(CV);
//I = pvd::that(CF);
}
void testAutoSwap()
@@ -636,8 +635,8 @@ void testCXX11Move()
{
#if __cplusplus>=201103L
testDiag("Check std::move()");
shared_vector<int32> A(4, 42),
B(std::move(A));
pvd::shared_vector<pvd::int32> A(4, 42),
B(std::move(A));
testOk1(A.unique());
testOk1(B.unique());
@@ -653,8 +652,8 @@ void testCXX11Move()
testOk1(A.size()==4);
testOk1(!A.empty() && A[0]==42);
shared_vector<void> C(shared_vector_convert<void>(A)),
D(std::move(C));
pvd::shared_vector<void> C(pvd::shared_vector_convert<void>(A)),
D(std::move(C));
A.clear();
testOk1(C.unique());
@@ -678,11 +677,11 @@ void testCXX11Init()
#if __cplusplus>=201103L
testDiag("Check c++11 style array initialization");
shared_vector<const int32> A = {1.0, 2.0, 3.0};
pvd::shared_vector<const pvd::int32> A = {1.0, 2.0, 3.0};
testOk1(A.size()==3);
int32 sum = 0;
pvd::int32 sum = 0;
for (auto V: A) {
sum += V;
}
@@ -699,8 +698,8 @@ MAIN(testSharedVector)
testPlan(191);
testDiag("Tests for shared_vector");
testDiag("sizeof(shared_vector<int32>)=%lu",
(unsigned long)sizeof(epics::pvData::shared_vector<int32>));
testDiag("sizeof(shared_vector<pvd::int32>)=%lu",
(unsigned long)sizeof(pvd::shared_vector<pvd::int32>));
testEmpty();
testInternalAlloc();

View File

@@ -15,6 +15,7 @@
#include <epicsUnitTest.h>
#include <testMain.h>
#include <pv/pvUnitTest.h>
#include <pv/pvIntrospect.h>
#include <pv/pvData.h>
#include <pv/convert.h>
@@ -29,9 +30,7 @@ static StandardFieldPtr standardField = getStandardField();
static void print(const string& name, FieldConstPtr const & f)
{
std::ostringstream strm;
strm << std::endl << name << std::endl << f << std::endl;
testDiag("%s", strm.str().c_str());
testShow()<<name<<'\n'<<format::indent_level(1)<<f;
}
MAIN(testStandardField)