Compare commits
102 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e67486c319 | ||
|
|
4f1da262d2 | ||
|
|
65c31491d9 | ||
|
|
5450f564dc | ||
|
|
453c267c9b | ||
| 7a2d264f2c | |||
| 03f9c1ab07 | |||
|
|
6d41566b40 | ||
|
|
1250a3c236 | ||
|
|
28e5defc9b | ||
|
|
fbe1a1135f | ||
|
|
b75f942d5a | ||
|
|
e83ce61bf6 | ||
|
|
86d8b5deec | ||
|
|
abbcf486b8 | ||
|
|
e286d32716 | ||
|
|
ba33c7443c | ||
|
|
c6168a7477 | ||
|
|
dd2aa1863d | ||
|
|
66737740ef | ||
|
|
54bddc9942 | ||
|
|
02151964a9 | ||
|
|
d366cc9682 | ||
|
|
1cac2ccd7e | ||
|
|
9702b68d72 | ||
|
|
6a163d7fd4 | ||
|
|
1832c417e6 | ||
|
|
148cfef572 | ||
|
|
31050952b6 | ||
|
|
e0d422ffd9 | ||
|
|
452f2379a1 | ||
|
|
e2d95128a3 | ||
|
|
3a178ea5c4 | ||
|
|
24489f6535 | ||
|
|
28ca7ac1ab | ||
|
|
5a0b42fec7 | ||
|
|
35bf9dcb13 | ||
|
|
f22b5d5b7b | ||
|
|
9923459c4b | ||
|
|
50a7208174 | ||
|
|
7e7949b1fa | ||
|
|
76c00b78c9 | ||
|
|
1676192dd1 | ||
|
|
b76c91a885 | ||
|
|
2d186d40d5 | ||
|
|
e803240fbf | ||
|
|
54c07f705f | ||
|
|
fa23ddd370 | ||
|
|
41d56fdf89 | ||
|
|
a65fc3ef30 | ||
|
|
b69bc44974 | ||
|
|
a90f0173a7 | ||
|
|
83342beb7e | ||
|
|
f6e6cf037f | ||
|
|
80920ae0b0 | ||
|
|
1f7667b22d | ||
|
|
e15e84fb14 | ||
|
|
ba2e1c8a1d | ||
|
|
fb6873e9a3 | ||
|
|
2f4c0eea9d | ||
|
|
a2b635c2fe | ||
|
|
abd029aa71 | ||
|
|
57c6d07a93 | ||
|
|
91c5136883 | ||
|
|
5e151c3b7a | ||
|
|
fc4b51cb49 | ||
|
|
fc703958b3 | ||
|
|
1b156c92cd | ||
|
|
2c75f1d1e9 | ||
|
|
e03096c35e | ||
|
|
4b0970ffcb | ||
|
|
048d6ef737 | ||
|
|
4768444b8a | ||
|
|
0ce3613acc | ||
|
|
d13696f943 | ||
|
|
e6597bc2f0 | ||
|
|
3d4083221d | ||
|
|
6b64adc150 | ||
|
|
c35e78b797 | ||
|
|
08234150dc | ||
|
|
5dfc4ffd16 | ||
|
|
ff4b88754f | ||
|
|
8794d5b6c0 | ||
|
|
00aab51203 | ||
|
|
df023e6103 | ||
|
|
e07a42fb48 | ||
|
|
6dd63a74a6 | ||
|
|
f90549aba8 | ||
|
|
4f3f6784d4 | ||
|
|
cfe939ca7a | ||
|
|
eb440e4662 | ||
|
|
bd5d0dee12 | ||
|
|
3b645933f5 | ||
|
|
5cca3a10ac | ||
|
|
bab0d964ab | ||
|
|
51d4d270cd | ||
|
|
3aa1f533bf | ||
|
|
cebc68474d | ||
|
|
a1ac2f41b4 | ||
|
|
d8eb50bff8 | ||
|
|
e93d1c5c42 | ||
|
|
8e97c2e8bd |
10
.ci/travis-build.sh
Executable file
10
.ci/travis-build.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -e -x
|
||||
|
||||
make -j2 $EXTRA
|
||||
|
||||
if [ "$TEST" != "NO" ]
|
||||
then
|
||||
make -j2 tapfiles
|
||||
make -j2 -s test-results
|
||||
fi
|
||||
107
.ci/travis-prepare.sh
Executable file
107
.ci/travis-prepare.sh
Executable file
@@ -0,0 +1,107 @@
|
||||
#!/bin/sh
|
||||
set -e -x
|
||||
|
||||
CURDIR="$PWD"
|
||||
|
||||
cat << EOF > $CURDIR/configure/RELEASE.local
|
||||
EPICS_BASE=$HOME/.source/epics-base
|
||||
EOF
|
||||
|
||||
install -d "$HOME/.source"
|
||||
cd "$HOME/.source"
|
||||
|
||||
add_gh_flat() {
|
||||
MODULE=$1
|
||||
REPOOWNER=$2
|
||||
REPONAME=$3
|
||||
BRANCH=$4
|
||||
MODULE_UC=$(echo $MODULE | tr 'a-z' 'A-Z')
|
||||
( git clone --quiet --depth 5 --branch $BRANCH https://github.com/$REPOOWNER/$REPONAME.git $MODULE && \
|
||||
cd $MODULE && git log -n1 )
|
||||
cat < $CURDIR/configure/RELEASE.local > $MODULE/configure/RELEASE.local
|
||||
cat << EOF >> $CURDIR/configure/RELEASE.local
|
||||
${MODULE_UC}=$HOME/.source/$MODULE
|
||||
EOF
|
||||
}
|
||||
|
||||
# not recursive
|
||||
git clone --quiet --depth 5 --branch "$BRBASE" https://github.com/${REPOBASE:-epics-base}/epics-base.git epics-base
|
||||
(cd epics-base && git log -n1 )
|
||||
add_gh_flat pvData ${REPOPVD:-epics-base} pvDataCPP ${BRPVD:-master}
|
||||
|
||||
if [ -e $CURDIR/configure/RELEASE.local ]
|
||||
then
|
||||
cat $CURDIR/configure/RELEASE.local
|
||||
fi
|
||||
|
||||
EPICS_HOST_ARCH=`sh epics-base/startup/EpicsHostArch`
|
||||
|
||||
# requires wine and g++-mingw-w64-i686
|
||||
if [ "$WINE" = "32" ]
|
||||
then
|
||||
echo "Cross mingw32"
|
||||
sed -i -e '/CMPLR_PREFIX/d' epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw
|
||||
cat << EOF >> epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw
|
||||
CMPLR_PREFIX=i686-w64-mingw32-
|
||||
EOF
|
||||
cat << EOF >> epics-base/configure/CONFIG_SITE
|
||||
CROSS_COMPILER_TARGET_ARCHS+=win32-x86-mingw
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ "$STATIC" = "YES" ]
|
||||
then
|
||||
echo "Build static libraries/executables"
|
||||
cat << EOF >> epics-base/configure/CONFIG_SITE
|
||||
SHARED_LIBRARIES=NO
|
||||
STATIC_BUILD=YES
|
||||
EOF
|
||||
fi
|
||||
|
||||
case "$CMPLR" in
|
||||
clang)
|
||||
echo "Host compiler is clang"
|
||||
cat << EOF >> epics-base/configure/os/CONFIG_SITE.Common.$EPICS_HOST_ARCH
|
||||
GNU = NO
|
||||
CMPLR_CLASS = clang
|
||||
CC = clang
|
||||
CCC = clang++
|
||||
EOF
|
||||
|
||||
# hack
|
||||
sed -i -e 's/CMPLR_CLASS = gcc/CMPLR_CLASS = clang/' epics-base/configure/CONFIG.gnuCommon
|
||||
|
||||
clang --version
|
||||
;;
|
||||
*)
|
||||
echo "Host compiler is default"
|
||||
gcc --version
|
||||
;;
|
||||
esac
|
||||
|
||||
cat <<EOF >> epics-base/configure/CONFIG_SITE
|
||||
USR_CPPFLAGS += $USR_CPPFLAGS
|
||||
USR_CFLAGS += $USR_CFLAGS
|
||||
USR_CXXFLAGS += $USR_CXXFLAGS
|
||||
EOF
|
||||
|
||||
# set RTEMS to eg. "4.9" or "4.10"
|
||||
# requires qemu, bison, flex, texinfo, install-info
|
||||
if [ -n "$RTEMS" ]
|
||||
then
|
||||
echo "Cross RTEMS${RTEMS} for pc386"
|
||||
curl -L "https://github.com/mdavidsaver/rsb/releases/download/20171203-${RTEMS}/i386-rtems${RTEMS}-trusty-20171203-${RTEMS}.tar.bz2" \
|
||||
| tar -C / -xmj
|
||||
|
||||
sed -i -e '/^RTEMS_VERSION/d' -e '/^RTEMS_BASE/d' epics-base/configure/os/CONFIG_SITE.Common.RTEMS
|
||||
cat << EOF >> epics-base/configure/os/CONFIG_SITE.Common.RTEMS
|
||||
RTEMS_VERSION=$RTEMS
|
||||
RTEMS_BASE=$HOME/.rtems
|
||||
EOF
|
||||
cat << EOF >> epics-base/configure/CONFIG_SITE
|
||||
CROSS_COMPILER_TARGET_ARCHS += RTEMS-pc386-qemu
|
||||
EOF
|
||||
fi
|
||||
|
||||
make -j2 -C epics-base $EXTRA
|
||||
make -j2 -C pvData $EXTRA
|
||||
23
.gitignore
vendored
23
.gitignore
vendored
@@ -1,9 +1,14 @@
|
||||
bin/
|
||||
include/
|
||||
lib/
|
||||
db/
|
||||
dbd/
|
||||
configure/*.local
|
||||
html/
|
||||
**/O.*
|
||||
**/**/O.*
|
||||
/cfg/
|
||||
/bin/
|
||||
/lib/
|
||||
/db/
|
||||
/dbd/
|
||||
/html/
|
||||
/include/
|
||||
/templates/
|
||||
/configure/*.local
|
||||
O.*/
|
||||
/QtC-*
|
||||
*.orig
|
||||
*.log
|
||||
.*.swp
|
||||
|
||||
17
.readthedocs.yml
Normal file
17
.readthedocs.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
# .readthedocs.yml
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Build documentation in the documentation/ directory with Sphinx
|
||||
sphinx:
|
||||
configuration: documentation/conf.py
|
||||
|
||||
# Build documentation with MkDocs
|
||||
#mkdocs:
|
||||
# configuration: mkdocs.yml
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF and ePub
|
||||
formats: all
|
||||
31
.travis.yml
Normal file
31
.travis.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
sudo: false
|
||||
dist: trusty
|
||||
language: c++
|
||||
compiler:
|
||||
- gcc
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libreadline6-dev
|
||||
- libncurses5-dev
|
||||
- perl
|
||||
- clang
|
||||
- g++-mingw-w64-i686
|
||||
- qemu-system-x86
|
||||
install:
|
||||
- ./.ci/travis-prepare.sh
|
||||
script:
|
||||
- ./.ci/travis-build.sh
|
||||
env:
|
||||
- BRBASE=7.0
|
||||
- BRBASE=7.0 CMPLR=clang
|
||||
- BRBASE=7.0 EXTRA="CMD_CXXFLAGS=-std=c++98"
|
||||
- BRBASE=7.0 EXTRA="CMD_CXXFLAGS=-std=c++11"
|
||||
- BRBASE=7.0 CMPLR=clang EXTRA="CMD_CXXFLAGS=-std=c++11"
|
||||
- BRBASE=7.0 WINE=32 TEST=NO STATIC=YES
|
||||
- BRBASE=7.0 WINE=32 TEST=NO STATIC=NO
|
||||
- BRBASE=7.0 RTEMS=4.10 TEST=NO
|
||||
- BRBASE=7.0 RTEMS=4.9 TEST=NO
|
||||
- BRBASE=3.16
|
||||
- BRBASE=3.15
|
||||
- BRBASE=3.14
|
||||
31
COPYRIGHT
31
COPYRIGHT
@@ -1,31 +0,0 @@
|
||||
This software is in part copyrighted by the various organizations and
|
||||
individuals listed below. Permission to use it is set out in the file
|
||||
LICENSE that accompanies the software.
|
||||
|
||||
In no event shall any copyright holder 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 they have been advised of the possibility of such
|
||||
damage.
|
||||
|
||||
The copyright holders specifically disclaim 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 the copyright holders have no
|
||||
obligation either collectively or individually to provide maintenance,
|
||||
support, updates, enhancements, or modifications.
|
||||
|
||||
Copyright (c) 2006 - 2015 All rights reserved
|
||||
|
||||
Martin R. Kraimer
|
||||
The University of Chicago, as Operator of Argonne National Laboratory.
|
||||
Deutsches Elektronen-Synchroton, Member of the Helmholtz Association,
|
||||
(DESY), HAMBURG, GERMANY,
|
||||
BERLINER SPEICHERRING GESELLSCHAFT FUER SYNCHROTRONSTRAHLUNG M.B.H.
|
||||
(BESSY), BERLIN, GERMANY.
|
||||
COSYLAB (Control System Laboratory), Ljubljana, Slovenia.
|
||||
Brookhaven Science Associates, as Operator of Brookhaven
|
||||
National Laboratory.
|
||||
Diamond Light Source Ltd., Didcot, United Kingdom.
|
||||
|
||||
|
||||
6
Doxyfile
6
Doxyfile
@@ -38,7 +38,7 @@ PROJECT_NAME = normativeTypesCPP
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER =
|
||||
PROJECT_NUMBER = 6.0.2
|
||||
|
||||
# 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
|
||||
@@ -743,7 +743,7 @@ WARN_LOGFILE =
|
||||
# spaces.
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = include
|
||||
INPUT = src
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
@@ -1008,7 +1008,7 @@ GENERATE_HTML = YES
|
||||
# The default directory is: html.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_OUTPUT = documentation/html
|
||||
HTML_OUTPUT = html/doxygen
|
||||
|
||||
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
|
||||
# generated HTML page (for example: .htm, .php, .asp).
|
||||
|
||||
109
LICENSE
109
LICENSE
@@ -1,14 +1,16 @@
|
||||
Copyright and License Terms
|
||||
---------------------------
|
||||
|
||||
Copyright (c) 2006-2015 Martin R. Kraimer
|
||||
Copyright (c) 2006 The University of Chicago, as Operator of Argonne
|
||||
Copyright (c) 2006-2016 Martin R. Kraimer
|
||||
Copyright (c) 2006-2016 UChicago Argonne LLC, as Operator of Argonne
|
||||
National Laboratory.
|
||||
Copyright (c) 2006 Deutsches Elektronen-Synchrotron,
|
||||
Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
|
||||
Copyright (c) 2007-2015 Control System Laboratory,
|
||||
Copyright (c) 2007-2016 Control System Laboratory,
|
||||
(COSYLAB) Ljubljana Slovenia
|
||||
Copyright (c) 2010-2015 Brookhaven Science Associates, as Operator of Brookhaven
|
||||
National Laboratory
|
||||
Copyright (c) 2011-2015 Diamond Light Source Limited,
|
||||
Copyright (c) 2010-2016 Brookhaven Science Associates, as Operator
|
||||
of Brookhaven National Laboratory
|
||||
Copyright (c) 2011-2016 Diamond Light Source Limited,
|
||||
(DLS) Didcot, United Kingdom
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
@@ -34,81 +36,30 @@ OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
________________________________________________________________________
|
||||
|
||||
This software is in part copyrighted by the University of Chicago (UofC)
|
||||
Additional Disclaimers
|
||||
----------------------
|
||||
|
||||
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.
|
||||
This software is copyright in part by these institutions:
|
||||
|
||||
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.
|
||||
* Brookhaven Science Associates, as Operator of Brookhaven
|
||||
National Laboratory, New York, USA
|
||||
* Control System Laboratory, Ljubljana, Slovenia
|
||||
* Deutsches Elektronen-Synchroton, Member of the Helmholtz
|
||||
Association, Hamburg, Germany
|
||||
* Diamond Light Source Limited, Didcot, United Kingdom
|
||||
* Helmholtz-Zentrum Berlin fuer Materialien und Energie m.b.H.,
|
||||
Berlin, Germany.
|
||||
* UChicage Argonne LLC, as Operator of Argonne National Laboratory,
|
||||
Illinois, USA
|
||||
|
||||
________________________________________________________________________
|
||||
In no event shall these institutions 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 advised of the possibility of such damage.
|
||||
|
||||
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.
|
||||
|
||||
______________________________________________________________________
|
||||
|
||||
This software is in part copyrighted by the 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 Diamond Light Source Limited (DLS)
|
||||
|
||||
In no event shall DLS 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
|
||||
DLS has been advised of the possibility of such damage.
|
||||
|
||||
DLS 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 DLS has no obligation to provide maintenance, support,
|
||||
updates, enhancements, or modifications.
|
||||
|
||||
________________________________________________________________________
|
||||
These institutions specifically disclaim 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 these institutions have no obligation to provide
|
||||
maintenance, support, updates, enhancements, or modifications.
|
||||
|
||||
|
||||
4
README
4
README
@@ -1,4 +0,0 @@
|
||||
Since the Normative Types specification is not yet at Public Working Draft level,
|
||||
any implementation must be considered alpha. The implementations of helpers under
|
||||
this repo must be considered alpha level.
|
||||
|
||||
17
README.md
Normal file
17
README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# normativeTypesCPP
|
||||
|
||||
The EPICS **Normative Types** are a set of standard high-level data types, designed to aid interoperability between EPICS PVA applications.
|
||||
|
||||
This normativeTypesCPP module is a part of the EPICS software toolkit that provides C++ helper classes which implement the EPICS Normative Types.
|
||||
|
||||
## Links
|
||||
|
||||
- General information about EPICS can be found at the
|
||||
[EPICS Controls website](https://epics-controls.org).
|
||||
- API documentation for this module can be found in its
|
||||
documentation directory, in particular the file
|
||||
normativeTypesCPP.html
|
||||
|
||||
## Building
|
||||
|
||||
This module is included as a submodule of a full EPICS 7 release and will be compiled during builds of that software.
|
||||
12
configure/CONFIG_NTYPES_VERSION
Normal file
12
configure/CONFIG_NTYPES_VERSION
Normal file
@@ -0,0 +1,12 @@
|
||||
# Version number for the Normative Types API and shared library
|
||||
|
||||
EPICS_NTYPES_MAJOR_VERSION = 6
|
||||
EPICS_NTYPES_MINOR_VERSION = 0
|
||||
EPICS_NTYPES_MAINTENANCE_VERSION = 2
|
||||
|
||||
# Development flag, set to zero for release versions
|
||||
|
||||
EPICS_NTYPES_DEVELOPMENT_FLAG = 0
|
||||
|
||||
# Immediately after a release the MAINTENANCE_VERSION
|
||||
# will be incremented and the DEVELOPMENT_FLAG set to 1
|
||||
@@ -29,9 +29,8 @@ USR_CPPFLAGS += --coverage
|
||||
USR_LDFLAGS += --coverage
|
||||
endif
|
||||
|
||||
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
|
||||
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
|
||||
|
||||
-include $(TOP)/../CONFIG_SITE.local
|
||||
-include $(TOP)/configure/CONFIG_SITE.local
|
||||
|
||||
# MSVC - skip defining min()/max() macros
|
||||
USR_CPPFLAGS_WIN32 += -DNOMINMAX
|
||||
|
||||
@@ -10,6 +10,8 @@ include $(TOP)/configure/CONFIG
|
||||
# but continue the build even if conflicts are found.
|
||||
CHECK_RELEASE = YES
|
||||
|
||||
CFG += CONFIG_NTYPES_VERSION
|
||||
|
||||
TARGETS = $(CONFIG_TARGETS)
|
||||
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
|
||||
|
||||
|
||||
@@ -1,32 +1,40 @@
|
||||
#RELEASE Location of external products
|
||||
# RELEASE - Location of external support modules
|
||||
#
|
||||
# IF YOU MAKE ANY CHANGES to this file you MUST at least run
|
||||
# "gnumake" in this directory afterwards; you usually need
|
||||
# to run "gnumake rebuild" in the application's top level
|
||||
# directory each time this file is changed.
|
||||
# IF YOU CHANGE ANY PATHS in this file or make API changes to
|
||||
# any modules it refers to, you should do a "make rebuild" in
|
||||
# this application's top level directory.
|
||||
#
|
||||
# NOTE: The build does not check dependencies against files
|
||||
# that are outside this application, thus you should run
|
||||
# "gnumake distclean install" in the top directory each time
|
||||
# EPICS_BASE, SNCSEQ, or any other external module defined
|
||||
# in the RELEASE file is rebuilt.
|
||||
# The EPICS build process does not check dependencies against
|
||||
# any files from outside the application, so it is safest to
|
||||
# rebuild it completely if any modules it depends on change.
|
||||
#
|
||||
# Host/target specific settings can be specified in files named
|
||||
# Host- or target-specific settings can be given in files named
|
||||
# RELEASE.$(EPICS_HOST_ARCH).Common
|
||||
# RELEASE.Common.$(T_A)
|
||||
# RELEASE.$(EPICS_HOST_ARCH).$(T_A)
|
||||
#
|
||||
# This file is parsed by both GNUmake and an EPICS Perl script,
|
||||
# so it may ONLY contain definititions of paths to other support
|
||||
# modules, variable definitions that are used in module paths,
|
||||
# and include statements that pull in other RELEASE files.
|
||||
# Variables may be used before their values have been set.
|
||||
# Build variables that are NOT used in paths should be set in
|
||||
# the CONFIG_SITE file.
|
||||
|
||||
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
|
||||
# Variables and paths to dependent modules:
|
||||
#MODULES = /path/to/modules
|
||||
#MYMODULE = $(MODULES)/my-module
|
||||
|
||||
#If using the sequencer, point SNCSEQ at its top directory:
|
||||
#SNCSEQ=$(EPICS_BASE)/../modules/soft/seq
|
||||
# If building the EPICS modules individually, set these:
|
||||
#EPICS_PVDATA = $(MODULES)/pvData-7.0.0
|
||||
#EPICS_LIBCOM = $(MODULES)/libcom-3.17.0
|
||||
#EPICS_BASE = $(MODULES)/core-7.0.1
|
||||
|
||||
# EPICS_BASE usually appears last so other apps can override stuff:
|
||||
#EPICS_BASE=/opt/epics/base
|
||||
|
||||
#Capfast users may need the following definitions
|
||||
#CAPFAST_TEMPLATES=
|
||||
#SCH2EDIF_PATH=
|
||||
# Set RULES here if you want to use build rules from elsewhere:
|
||||
#RULES = $(MODULES)/build-rules
|
||||
|
||||
# These allow developers to override the RELEASE variable settings
|
||||
# without having to modify the configure/RELEASE file itself.
|
||||
-include $(TOP)/../RELEASE.local
|
||||
-include $(TOP)/../RELEASE.$(EPICS_HOST_ARCH).local
|
||||
-include $(TOP)/configure/RELEASE.local
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<h1>Release 4.0 IN DEVELOPMENT</h1>
|
||||
<p>This is the first release of normativeTypesCPP that is part of an official
|
||||
EPICS V4 release.
|
||||
It is a major rewrite of the previous versions of normativeTypesCPP.</p>
|
||||
@@ -1,7 +1,164 @@
|
||||
Release 4.0 IN DEVELOPMENT
|
||||
===========
|
||||
# normativeTypes Module
|
||||
|
||||
This document summarizes the changes to the module between releases.
|
||||
|
||||
## Release 6.0.2 (EPICS 7.0.10, December 2025)
|
||||
|
||||
- Fix potential NULL pointer dereference in `NTNDArray::getValueSize()`
|
||||
|
||||
## Release 6.0.1 (EPICS 7.0.3.1, October 2019)
|
||||
|
||||
- Doxygen updates and read-the-docs integration.
|
||||
|
||||
## Release 6.0.0 (EPICS 7.0.3, July 2019)
|
||||
|
||||
- Reimplement `isCompatible()` methods to use a new internal validation API in
|
||||
order to make the implementation uniform, less repetitive and less strict.
|
||||
|
||||
The new implementation is less strict in the sense that it considers types that
|
||||
can be converted into one another compatible with each other.
|
||||
For example, any `Scalar` is considered compatible with any other `Scalar`,
|
||||
regardless of the underlying type.
|
||||
Normative Types users are advised to use `getAs()` and `putFrom()` when
|
||||
getting/putting data from/into `PVScalar`s and `PVScalarArray`s.
|
||||
|
||||
Also, `isCompatible()` methods now disregard field order and extra fields that
|
||||
are not part of the specification.
|
||||
|
||||
This change is not expected to break any current server or client, but it will
|
||||
break existing clients that rely on the previous `isCompatible()` strictness
|
||||
once servers start to take advantage of `isCompatible()` now being less strict.
|
||||
|
||||
## Release 5.2.2
|
||||
|
||||
- Fix `NTTable::getColumnNames()`.
|
||||
|
||||
## Release 5.2.1 (EPICS 7.0.2, Dec 2018)
|
||||
|
||||
- No functional changes.
|
||||
- Removal of declaration for unimplemented `PVNTField::createAlarmLimit()` and
|
||||
elimination of unused variables.
|
||||
|
||||
|
||||
## Release 5.2.0 (EPICS 7.0.1, Dec 2017)
|
||||
|
||||
This release contains bug fixes and minor source updates needed to
|
||||
build against the latest version of pvData.
|
||||
|
||||
|
||||
## Release 5.1.2 (EPICS V4.6, Aug 2016)
|
||||
|
||||
The main changes since release 5.1.1 are:
|
||||
|
||||
- NTUnionBuilder: Add missing `value()` function
|
||||
- Updated document: Now document all Normative Types
|
||||
|
||||
|
||||
## Release 5.1.1
|
||||
|
||||
The main changes since release 5.0 are:
|
||||
|
||||
- Linux shared library version added
|
||||
- Headers and source locations have changed
|
||||
- Missing `is_a()` implementations added
|
||||
- `NTAttribute::addTags()` is now non-virtual
|
||||
- New license file replaces LICENSE and COPYRIGHT
|
||||
|
||||
### Shared library version added
|
||||
|
||||
Linux shared library version numbers have been added by setting `SHRLIB_VERSION`
|
||||
(to 5.1 in this case).
|
||||
The shared object will be `libnt.so.5.1` instead of `libnt.so`.
|
||||
|
||||
### Headers and source locations have changed
|
||||
|
||||
Source has moved out of nt directory directly into src.
|
||||
|
||||
Headers have been moved into a pv directory.
|
||||
This facilitates using some IDEs such as Qt Creator.
|
||||
|
||||
- `src/nt/ntscalar.cpp -> src/ntscalar.cpp`
|
||||
- `src/nt/ntscalar.h -> src/pv/ntscalar.h`
|
||||
|
||||
### Missing `is_a()` implementations added
|
||||
|
||||
`is_a(PVStructurePtr const &)` implementation has been added for each type.
|
||||
|
||||
|
||||
## Release 5.0 (EPICS V4.5, Oct 2015)
|
||||
|
||||
This release adds support through wrapper classes and builders for the
|
||||
remaining Normative Types:
|
||||
|
||||
- NTEnum
|
||||
- NTMatrix
|
||||
- NTURI
|
||||
- NTAttribute
|
||||
- NTContinuum
|
||||
- NTHistogram
|
||||
- NTAggregate
|
||||
- NTUnion
|
||||
- NTScalarMultiChannel
|
||||
|
||||
Release 5.0 therefore fully implements the 16 Mar 2015 version of the
|
||||
normativeTypes specification.
|
||||
|
||||
Each wrapper class has an extended API:
|
||||
|
||||
- `is_a()` now has a convenience overload taking a PVStructure.
|
||||
- `isCompatible()`, reporting introspection type compatibility, now has an
|
||||
overload taking a Structure.
|
||||
The PVStructure version is retained as a convenience method and for backwards
|
||||
compatibility.
|
||||
- An `isValid()` function now reports validity of a compatible PVStructure's
|
||||
data with respect to the specification.
|
||||
|
||||
Other changes are:
|
||||
|
||||
- Support for NTAttributes extended as required by NTNDArray
|
||||
(NTNDArrayAttributes).
|
||||
- A new class for parsing NT IDs (NTID).
|
||||
- Resolution of the confusion between column names and labels in NTTable and
|
||||
improved API.
|
||||
Function for adding columns is now `addColumn()` rather than `add()`.
|
||||
A new `getColumnNames()` function provided.
|
||||
- `isConnected()` is treated as an optional rather than a required field in
|
||||
NTMultiChannelArray.
|
||||
`isConnected()` and `addIsConnected()` functions added to wrapper and builder
|
||||
respectively.
|
||||
|
||||
- Unit tests for all new classes.
|
||||
|
||||
## Release 4.0 (EPICS V4.4, Dec 2014)
|
||||
|
||||
This is the first release of normativeTypesCPP that is part of an official
|
||||
EPICS V4 release.
|
||||
It is a major rewrite of the previous versions of normativeTypesCPP.
|
||||
|
||||
This release provides support through wrapper classes and builders for the
|
||||
following Normative Types:
|
||||
|
||||
- NTScalar
|
||||
- NTScalarArray
|
||||
- NTNameValue
|
||||
- NTTable
|
||||
- NTMultiChannel
|
||||
- NTNDArray
|
||||
|
||||
Each type has a wrapper class of the same name which has functions for checking
|
||||
compatibility of existing PVStructures (`isCompatible()`) and the reported types
|
||||
of Structures (`is_a()`),
|
||||
wraps existing PVStructures (`wrap()`, `wrapUnsafe()`) and provides a convenient
|
||||
interface to all required and optional fields.
|
||||
|
||||
Each type has a builder which can create a Structure, a PVStructure or a
|
||||
wrapper around a new PVStructure.
|
||||
In each case optional or extra fields can be added and options such as choice of
|
||||
scalar type can be made.
|
||||
|
||||
Additional features are:
|
||||
|
||||
- Utility classes NTField and NTPVField for standard structure fields and
|
||||
NTUtils for type IDs.
|
||||
- Unit tests for the implemented classes.
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<h1>TODO</h1>
|
||||
<h2>NTScalarArray</h2>
|
||||
<p>NTScalarArrayBuilder::arrayValue</p>
|
||||
<p>Should this be:</p>
|
||||
<p>NTScalarArrayBuilder::value</p>
|
||||
<p>This makes NTScalarArray consistent with other NTTypes.</p>
|
||||
<h2>NTNameValue</h2>
|
||||
<p>This does not have a value field like all the other NTTypes.
|
||||
Perhaps instead of</p>
|
||||
<pre><code>NTNameValue
|
||||
string[] name
|
||||
string[] value
|
||||
</code></pre>
|
||||
<p>It should be</p>
|
||||
<pre><code>NTNameValue
|
||||
value
|
||||
string[] name
|
||||
string[] value
|
||||
</code></pre>
|
||||
<h2>NTTable</h2>
|
||||
<p>Should lables be label?
|
||||
Compare with name,value from NTNameValue.</p>
|
||||
@@ -1,37 +1,5 @@
|
||||
TODO
|
||||
===========
|
||||
====
|
||||
|
||||
NTScalarArray
|
||||
------------
|
||||
Documentation for recently added types.
|
||||
|
||||
NTScalarArrayBuilder::arrayValue
|
||||
|
||||
Should this be:
|
||||
|
||||
NTScalarArrayBuilder::value
|
||||
|
||||
This makes NTScalarArray consistent with other NTTypes.
|
||||
|
||||
|
||||
NTNameValue
|
||||
------------
|
||||
|
||||
This does not have a value field like all the other NTTypes.
|
||||
Perhaps instead of
|
||||
|
||||
NTNameValue
|
||||
string[] name
|
||||
string[] value
|
||||
|
||||
It should be
|
||||
|
||||
NTNameValue
|
||||
value
|
||||
string[] name
|
||||
string[] value
|
||||
|
||||
NTTable
|
||||
----------
|
||||
|
||||
Should lables be label?
|
||||
Compare with name,value from NTNameValue.
|
||||
|
||||
7
documentation/_static/css/custom.css
Normal file
7
documentation/_static/css/custom.css
Normal file
@@ -0,0 +1,7 @@
|
||||
.wy-side-nav-search {
|
||||
background-color: #18334B;
|
||||
}
|
||||
|
||||
.wy-side-nav-search input[type="text"] {
|
||||
border-color: #18334b;
|
||||
}
|
||||
77
documentation/conf.py
Normal file
77
documentation/conf.py
Normal file
@@ -0,0 +1,77 @@
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file only contains a selection of the most common options. For a full
|
||||
# list see the documentation:
|
||||
# http://www.sphinx-doc.org/en/master/config
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'normativeTypes (C++)'
|
||||
copyright = '2019, EPICS Controls.'
|
||||
author = 'EPICS'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.intersphinx',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
# Intersphinx links to subprojects
|
||||
intersphinx_mapping = {
|
||||
}
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
html_css_files = [
|
||||
'css/custom.css',
|
||||
]
|
||||
|
||||
master_doc = 'index'
|
||||
|
||||
html_theme_options = {
|
||||
'logo_only': True,
|
||||
}
|
||||
html_logo = "images/EPICS_white_logo_v02.png"
|
||||
|
||||
html_extra_path = ['../html']
|
||||
|
||||
|
||||
# -- Run Doxygen ------------------------------------------------------------
|
||||
|
||||
import subprocess
|
||||
subprocess.call('cd ..; mkdir -p html/doxygen; doxygen', shell=True)
|
||||
BIN
documentation/images/EPICS_white_logo_v02.png
Normal file
BIN
documentation/images/EPICS_white_logo_v02.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
17
documentation/index.rst
Normal file
17
documentation/index.rst
Normal file
@@ -0,0 +1,17 @@
|
||||
NormativeTypes (C++) Library
|
||||
============================
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
EPICS Website <https://epics-controls.org>
|
||||
EPICS Documentation Home <https://docs.epics-controls.org>
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: normativeTypesCPP
|
||||
|
||||
Reference Manual <ntCPP>
|
||||
API Documentation <https://docs.epics-controls.org/projects/normativetypes-cpp/en/latest/doxygen>
|
||||
Source Code Repository on GitHub <https://github.com/epics-base/normativeTypesCPP>
|
||||
File diff suppressed because it is too large
Load Diff
3270
documentation/ntCPP.rst
Normal file
3270
documentation/ntCPP.rst
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,289 +0,0 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
||||
<title>EPICS pvDataCPP</title>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="http://epics-pvdata.sourceforge.net/base.css" />
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="http://epics-pvdata.sourceforge.net/epicsv4.css" />
|
||||
<style type="text/css">
|
||||
/*<![CDATA[*/
|
||||
.about { margin-left: 3em; margin-right: 3em; font-size: .83em}
|
||||
table { margin-left: auto; margin-right: auto }
|
||||
.diagram { text-align: center; margin: 2.5em 0 }
|
||||
span.opt { color: grey }
|
||||
span.nterm { font-style:italic }
|
||||
span.term { font-family:courier }
|
||||
span.user { font-family:courier }
|
||||
span.user:before { content:"<" }
|
||||
span.user:after { content:">" }
|
||||
.nonnorm { font-style:italic }
|
||||
p.ed { color: #AA0000 }
|
||||
span.ed { color: #AA0000 }
|
||||
p.ed.priv { display: inline; }
|
||||
span.ed.priv { display: inline; }
|
||||
/*]]>*/</style>
|
||||
<!-- Script that generates the Table of Contents -->
|
||||
<script type="text/javascript"
|
||||
src="http://epics-pvdata.sourceforge.net/script/tocgen.js">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="head">
|
||||
<h1>EPICS pvDataCPP</h1>
|
||||
<!-- Maturity: Working Draft or Request for Comments, or Recommendation, and date. -->
|
||||
|
||||
<h2 class="nocount">EPICS v4 Working Group, Working Draft, 23-July-2014</h2>
|
||||
|
||||
<dl>
|
||||
<dt>Latest version:</dt>
|
||||
<dd><a
|
||||
href="ntCPP.html">ntCPP.html</a>
|
||||
</dd>
|
||||
<dt>This version:</dt>
|
||||
<dd><a
|
||||
href="ntCPP_20140723.html">ntCPP_20140723.html</a>
|
||||
</dd>
|
||||
<dt>Previous version:</dt>
|
||||
<dd>None</dd>
|
||||
<dt>Editors:</dt>
|
||||
<dd>Marty Kraimer, BNL</dd>
|
||||
<dd>Michael Davidsaver, BNL</dd>
|
||||
<dd>Matej Sekoranja, CosyLab</dd>
|
||||
</dl>
|
||||
|
||||
<p class="copyright">This product is made available subject to acceptance of the <a
|
||||
href="http://epics-pvdata.sourceforge.net/LICENSE.html">EPICS open source
|
||||
license.</a></p>
|
||||
<hr />
|
||||
</div>
|
||||
<h2 class="nocount">Abstract</h2>
|
||||
|
||||
<p>EPICS Version 4 provides efficient
|
||||
storage, access, and communication, of memory resident structured data.
|
||||
pvData is the storage compoment.
|
||||
pvDataCPP is the C++ implementation of pvData.
|
||||
It is one part of the set of related products in the EPICS
|
||||
V4 control system programming environment:<br />
|
||||
<a href="http://epics-pvdata.sourceforge.net/relatedDocumentsV4.html">relatedDocumentsV4.html</a>
|
||||
</p>
|
||||
|
||||
|
||||
<h2 class="nocount">Status of this Document</h2>
|
||||
|
||||
<p>For now this is a working copy so it is not the same as "This version" shown above.</p>
|
||||
|
||||
<p>This is the 23-July-2014 version of the C++ implementation of pvData.
|
||||
</p>
|
||||
|
||||
<p>RELEASE_NOTES.md provides changes since the last release.
|
||||
TODO.md describes things to do before the next release.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<div id="toc">
|
||||
<h2 class="nocount" style="page-break-before: always">Table of Contents</h2>
|
||||
</div>
|
||||
<div id="contents" class="contents">
|
||||
|
||||
<body>
|
||||
<h1 style="text-align: center">EPICS normative type C++ implementation
|
||||
</h1>
|
||||
|
||||
<h2 class="nocount" id="L50">Draft, 4-Nov-2012</h2>
|
||||
<dl>
|
||||
<dt>This version:</dt>
|
||||
<dd><a href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/normativeTypesCPP/raw-file/tip/documentation/ntCPP.html">ntCPP.html</a></dd>
|
||||
<dt>Editors:</dt>
|
||||
<dd>Matej Sekoranja, CosyLab<br>
|
||||
Marty Kraimer, BNL
|
||||
</dd>
|
||||
</dl>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<h2>Introduction</h2>
|
||||
|
||||
<p>This section describes the C++ implemmentation of normative types. Two (2) helper classes are implemented,
|
||||
ntNameValue and NTTable respectively. </p>
|
||||
|
||||
<h3>Normative Type Fields.</h3>
|
||||
|
||||
<p>These are helper classes for creating standard fields for normative types.
|
||||
There is a single instance of this class, which is obtained via NTField::get().
|
||||
</p>
|
||||
<pre>class NTField: NoDefaultMethods {
|
||||
public:
|
||||
static NTFieldPtr get();
|
||||
~NTField() {}
|
||||
|
||||
PVStructurePtr createEnumerated(StringArray const & choices);
|
||||
PVStructurePtr createTimeStamp();
|
||||
PVStructurePtr createAlarm();
|
||||
PVStructurePtr createDisplay();
|
||||
PVStructurePtr createAlarmLimit();
|
||||
PVStructurePtr createControl();
|
||||
|
||||
PVStructureArrayPtr createEnumeratedArray();
|
||||
PVStructureArrayPtr createTimeStampArray();
|
||||
PVStructureArrayPtr createAlarmArray();
|
||||
};</pre>
|
||||
|
||||
<p>where</p>
|
||||
<dl>
|
||||
<dt>createEnumerated</dt>
|
||||
<dd>Create an introspection interface for an enumerated structure.</dd>
|
||||
<dt>createTimeStamp</dt>
|
||||
<dd>Create an interspection interface for a timeStamp structure.</dd>
|
||||
<dt>createAlarm</dt>
|
||||
<dd>Create an interspection interface for an alarm structure.</dd>
|
||||
<dt>createDisplay</dt>
|
||||
<dd>Create an introsepecion interface for a display structure.</dd>
|
||||
<dt>createAlarmLimit</dt>
|
||||
<dd>Create an introspection interface for an alarm limit structure.</dd>
|
||||
<dt>createControl</dt>
|
||||
<dd>Create an introspection interface for a control structure.</dd>
|
||||
<dt>createEnumeratedArray</dt>
|
||||
<dd>Create an introspection interface for an structureArray of enumerated
|
||||
structures.</dd>
|
||||
<dt>createTimeStampArray</dt>
|
||||
<dd>Create an introspection interface for an structureArray of timeStamp
|
||||
structures.</dd>
|
||||
<dt>createAlarmArray</dt>
|
||||
<dd>Create an introspection interface for an structureArray of alarm
|
||||
structures.</dd>
|
||||
</dl>
|
||||
|
||||
<h3>NTNameValue</h3>
|
||||
|
||||
<p>These are helper classes for NTNameValue</p>
|
||||
<pre>class NTNameValue : private NoDefaultMethods
|
||||
{
|
||||
public:
|
||||
static bool isNTNameValue(PVStructurePtr const & pvStructure);
|
||||
static NTNameValuePtr create(
|
||||
bool hasFunction,bool hasTimeStamp, bool hasAlarm);
|
||||
static NTNameValuePtr create(
|
||||
PVStructurePtr const & pvStructure);
|
||||
~NTNameValue();
|
||||
PVStringPtr getFunction();
|
||||
void attachTimeStamp(PVTimeStamp &pvTimeStamp);
|
||||
void attachAlarm(PVAlarm &pvAlarm);
|
||||
PVStructurePtr getPVStructure();
|
||||
PVStructurePtr getTimeStamp();
|
||||
PVStructurePtr getAlarm();
|
||||
PVStringArrayPtr getNames();
|
||||
PVStringArrayPtr getValues();
|
||||
};</pre>
|
||||
|
||||
<p>where</p>
|
||||
<dl>
|
||||
<dt>isNTNameValue</dt>
|
||||
<dd>Is the structure a NTNameValue structure?</dd>
|
||||
<dt>create</dt>
|
||||
<dd>Create an NTNameValue that has the associated fields.</dd>
|
||||
<dt>~NTNameValue</dt>
|
||||
<dd>The destructor.</dd>
|
||||
<dt>getFunction</dt>
|
||||
<dd>Get the function field. This can be null.</dd>
|
||||
<dt>attachTimeStamp</dt>
|
||||
<dd>The timeStamp field of the NTNameValue is atttached to the
|
||||
pvTimeStamp.</dd>
|
||||
<dt>attachAlarm</dt>
|
||||
<dd>The alarm field of the NTNameValue is atttached to the alarm.</dd>
|
||||
<dt>getPVStructure</dt>
|
||||
<dd>Get the pvStructure that this NTNameValue contains.</dd>
|
||||
<dt>getTimeStamp</dt>
|
||||
<dd>Get the timeStamp field.</dd>
|
||||
<dt>getAlarm</dt>
|
||||
<dd>Get the alarm field.</dd>
|
||||
<dt>getNames</dt>
|
||||
<dd>Get the names field.</dd>
|
||||
<dt>getValues</dt>
|
||||
<dd>Get the values field.</dd>
|
||||
</dl>
|
||||
|
||||
<h3>NTTable</h3>
|
||||
|
||||
<p>These are helper classes for NTTable</p>
|
||||
<pre>class NTTable: private NoDefaultMethods
|
||||
{
|
||||
public:
|
||||
static bool isNTTable(PVStructurePtr const & pvStructure);
|
||||
static PVStructure::shared_pointer create(
|
||||
bool hasFunction,bool hasTimeStamp, bool hasAlarm,
|
||||
int numberValues,
|
||||
FieldConstPtrArray valueFields);
|
||||
static NTTablePtr create(
|
||||
bool hasFunction,bool hasTimeStamp, bool hasAlarm,
|
||||
StringArray const & valueNames,
|
||||
FieldConstPtrArray const &valueFields);
|
||||
static NTTablePtr clone(PVStructurePtr const &);
|
||||
~NTTable();
|
||||
PVStringPtr getFunction();
|
||||
void attachTimeStamp(PVTimeStamp &pvTimeStamp);
|
||||
void attachAlarm(PVAlarm &pvAlarm);
|
||||
PVStructurePtr getPVStructure();
|
||||
PVStructurePtr getTimeStamp();
|
||||
PVStructurePtr getAlarm();
|
||||
PVStringArrayPtr getLabel();
|
||||
size_t getNumberValues();
|
||||
FieldConstPtr getField(int index);
|
||||
PVFieldPtr getPVField(int index);
|
||||
};</pre>
|
||||
|
||||
<p>where</p>
|
||||
<dl>
|
||||
<dt>isNTTable</dt>
|
||||
<dd>y</dd>
|
||||
<dt>create</dt>
|
||||
<dd>Create an NTTable that has the associated fields.</dd>
|
||||
<dt>~NTTable</dt>
|
||||
<dd>The destructor.</dd>
|
||||
<dt>getFunction</dt>
|
||||
<dd>Get the function field. This can be null.</dd>
|
||||
<dt>attachTimeStamp</dt>
|
||||
<dd>The timeStamp field of the NTTable is atttached to the pvTimeStamp.</dd>
|
||||
<dt>attachAlarm</dt>
|
||||
<dd>The alarm field of the NTTable is atttached to the alarm.</dd>
|
||||
<dt>getPVStructure</dt>
|
||||
<dd>Get the pvStructure that this NTTable contains.</dd>
|
||||
<dt>getTimeStamp</dt>
|
||||
<dd>Get the timeStamp field.</dd>
|
||||
<dt>getAlarm</dt>
|
||||
<dd>Get the alarm field.</dd>
|
||||
<dt>getLabel</dt>
|
||||
<dd>Get the label field.</dd>
|
||||
<dt>getNumberValues</dt>
|
||||
<dd>Get the number of value fields.</dd>
|
||||
<dt>getField</dt>
|
||||
<dd>Get the introspection interface for the specified field.</dd>
|
||||
<dt>getPVField</dt>
|
||||
<dd>Get the data field for the specified field.</dd>
|
||||
</dl>
|
||||
|
||||
<h2>MTMultiChannel</h2>
|
||||
<pre>
|
||||
structure NTMultiChannel
|
||||
union_t[] value
|
||||
string[] channelName
|
||||
time_t timeStamp :opt // time when data collected
|
||||
alarm_t alarm :opt // alarm associated with data collection
|
||||
int[] severity :opt // alarm severity for each value
|
||||
int[] status :opt // alarm status for each value
|
||||
string[] message :opt // alarm message for each value
|
||||
long[] secondsPastEpoch :opt // seconds for each value.
|
||||
int[] nanoseconds :opt // nanoseconds for each value
|
||||
string descriptor :opt // descriptor data
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6,20 +6,35 @@
|
||||
#
|
||||
# Author: Ralph Lange <ralph.lange@gmx.de>
|
||||
# Copyright (C) 2013 Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
|
||||
# Copyright (C) 2014-2015 ITER Organization.
|
||||
# Copyright (C) 2014-2016 ITER Organization.
|
||||
# All rights reserved. Use is subject to license terms.
|
||||
|
||||
installTool () {
|
||||
local module=$1
|
||||
local version=$2
|
||||
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/${module}-${version}_Build/lastSuccessfulBuild/artifact/${module,,}-${version}.CB-dist.tar.gz
|
||||
tar -xzf ${module,,}-${version}.CB-dist.tar.gz
|
||||
}
|
||||
|
||||
installE4 () {
|
||||
local module=$1
|
||||
local branch=$2
|
||||
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/e4-cpp-${module}-${branch}-build/BASE=${BASE}/lastSuccessfulBuild/artifact/${module}.CB-dist.tar.gz
|
||||
tar -xzf ${module}.CB-dist.tar.gz
|
||||
}
|
||||
|
||||
###########################################
|
||||
# Determine EPICS Base version
|
||||
# Defaults for EPICS Base
|
||||
|
||||
DEFAULT_BASE=3.14.12.5
|
||||
DEFAULT_BASE=3.15.4
|
||||
BASE=${BASE:-${DEFAULT_BASE}}
|
||||
|
||||
BASE=${1:-${DEFAULT_BASE}}
|
||||
USE_MB=${2:-"MB_NO"}
|
||||
###########################################
|
||||
# Dependent module branches
|
||||
|
||||
# Dependent module branches (empty = master)
|
||||
PVCOMMON_BRANCH=""
|
||||
PVDATA_BRANCH=""
|
||||
PVDATA_BRANCH="master"
|
||||
|
||||
###########################################
|
||||
# Fetch and unpack dependencies
|
||||
@@ -30,15 +45,10 @@ rm -fr ${STUFF}
|
||||
mkdir -p ${STUFF}
|
||||
cd ${STUFF}
|
||||
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/Base-${BASE}_Build/lastSuccessfulBuild/artifact/base-${BASE}.CB-dist.tar.gz
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/pvDataCPP_${PVDATA_BRANCH}Build/BASE=${BASE},USE_MB=MB_NO/lastSuccessfulBuild/artifact/pvData.CB-dist.tar.gz
|
||||
tar -xzf base-${BASE}.CB-dist.tar.gz
|
||||
tar -xzf pvData.CB-dist.tar.gz
|
||||
installTool Boost 1.61.0
|
||||
installTool Base ${BASE}
|
||||
|
||||
if [ "${USE_MB}" = "MB_YES" ]; then
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/pvCommonCPP_${PVCOMMON_BRANCH}Build/BASE=${BASE},USE_MB=MB_YES/lastSuccessfulBuild/artifact/pvCommon.CB-dist.tar.gz
|
||||
tar -xzf pvCommon.CB-dist.tar.gz
|
||||
fi
|
||||
installE4 pvData ${PVDATA_BRANCH}
|
||||
|
||||
###########################################
|
||||
# Build
|
||||
@@ -62,6 +72,6 @@ make distclean all
|
||||
make runtests
|
||||
|
||||
###########################################
|
||||
# Create distribution
|
||||
# Create cache
|
||||
|
||||
tar --exclude=test* -czf normativeTypes.CB-dist.tar.gz lib include
|
||||
|
||||
@@ -6,15 +6,31 @@
|
||||
#
|
||||
# Author: Ralph Lange <ralph.lange@gmx.de>
|
||||
# Copyright (C) 2013 Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
|
||||
# Copyright (C) 2014-2015 ITER Organization.
|
||||
# Copyright (C) 2014-2016 ITER Organization.
|
||||
# All rights reserved. Use is subject to license terms.
|
||||
|
||||
installTool () {
|
||||
local module=$1
|
||||
local version=$2
|
||||
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/${module}-${version}_Build/lastSuccessfulBuild/artifact/${module,,}-${version}.CB-dist.tar.gz
|
||||
tar -xzf ${module,,}-${version}.CB-dist.tar.gz
|
||||
}
|
||||
|
||||
installE4 () {
|
||||
local module=$1
|
||||
local branch=$2
|
||||
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/e4-cpp-${module}-${branch}-build/BASE=${BASE}/lastSuccessfulBuild/artifact/${module}.CB-dist.tar.gz
|
||||
tar -xzf ${module}.CB-dist.tar.gz
|
||||
}
|
||||
|
||||
###########################################
|
||||
# Determine EPICS Base version
|
||||
# Defaults for EPICS Base and parameters
|
||||
|
||||
DEFAULT_BASE=3.14.12.5
|
||||
|
||||
BASE=${1:-${DEFAULT_BASE}}
|
||||
BASE=3.15.4
|
||||
PUBLISH=${PUBLISH:-NO}
|
||||
BRANCH=${BRANCH:-master}
|
||||
|
||||
###########################################
|
||||
# Fetch and unpack dependencies
|
||||
@@ -25,16 +41,14 @@ rm -fr ${STUFF}
|
||||
mkdir -p ${STUFF}
|
||||
cd ${STUFF}
|
||||
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/Doxygen-1.8.3_Build/lastSuccessfulBuild/artifact/doxygen-1.8.3.CB-dist.tar.gz
|
||||
tar -xzf doxygen-1.8.3.CB-dist.tar.gz
|
||||
installTool Doxygen 1.8.11
|
||||
|
||||
###########################################
|
||||
# Generate
|
||||
|
||||
cd ${WORKSPACE}
|
||||
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/normativeTypesCPP_Build/BASE=${BASE},USE_MB=MB_NO/lastSuccessfulBuild/artifact/normativeTypes.CB-dist.tar.gz
|
||||
tar -xzf normativeTypes.CB-dist.tar.gz
|
||||
installE4 normativeTypes ${BRANCH}
|
||||
|
||||
export PATH=${STUFF}/bin:${PATH}
|
||||
|
||||
@@ -43,4 +57,10 @@ doxygen
|
||||
###########################################
|
||||
# Publish
|
||||
|
||||
rsync -aqP --delete -e ssh documentation epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/normativeTypesCPP/tip
|
||||
if [ "${PUBLISH}" != "DONT" ]; then
|
||||
# Upload explicit dummy to ensure target directory exists
|
||||
echo "Created by CloudBees Jenkins upload job. Should be deleted as part of the job." > DUMMY
|
||||
rsync -q -e ssh DUMMY epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/normativeTypesCPP/${PUBLISH}/
|
||||
|
||||
rsync -aqP --delete -e ssh documentation epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/normativeTypesCPP/${PUBLISH}/
|
||||
fi
|
||||
|
||||
47
src/Makefile
47
src/Makefile
@@ -1,30 +1,26 @@
|
||||
TOP = ..
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
SRC = $(TOP)/src
|
||||
|
||||
SRC_DIRS += $(SRC)/nt
|
||||
|
||||
INC += nt.h
|
||||
INC += ntutils.h
|
||||
INC += ntid.h
|
||||
INC += ntfield.h
|
||||
INC += ntscalar.h
|
||||
INC += ntscalarArray.h
|
||||
INC += ntnameValue.h
|
||||
INC += nttable.h
|
||||
INC += ntmultiChannel.h
|
||||
INC += ntscalarMultiChannel.h
|
||||
INC += ntndarray.h
|
||||
INC += ntmatrix.h
|
||||
INC += ntenum.h
|
||||
INC += ntunion.h
|
||||
INC += ntaggregate.h
|
||||
INC += ntattribute.h
|
||||
INC += ntcontinuum.h
|
||||
INC += nthistogram.h
|
||||
INC += nturi.h
|
||||
INC += ntndarrayAttribute.h
|
||||
INC += pv/nt.h
|
||||
INC += pv/ntutils.h
|
||||
INC += pv/ntid.h
|
||||
INC += pv/ntfield.h
|
||||
INC += pv/ntscalar.h
|
||||
INC += pv/ntscalarArray.h
|
||||
INC += pv/ntnameValue.h
|
||||
INC += pv/nttable.h
|
||||
INC += pv/ntmultiChannel.h
|
||||
INC += pv/ntscalarMultiChannel.h
|
||||
INC += pv/ntndarray.h
|
||||
INC += pv/ntmatrix.h
|
||||
INC += pv/ntenum.h
|
||||
INC += pv/ntunion.h
|
||||
INC += pv/ntaggregate.h
|
||||
INC += pv/ntattribute.h
|
||||
INC += pv/ntcontinuum.h
|
||||
INC += pv/nthistogram.h
|
||||
INC += pv/nturi.h
|
||||
INC += pv/ntndarrayAttribute.h
|
||||
|
||||
LIBSRCS += ntutils.cpp
|
||||
LIBSRCS += ntid.cpp
|
||||
@@ -50,5 +46,8 @@ LIBRARY = nt
|
||||
|
||||
nt_LIBS += pvData Com
|
||||
|
||||
# shared library ABI version.
|
||||
SHRLIB_VERSION ?= $(EPICS_NTYPES_MAJOR_VERSION).$(EPICS_NTYPES_MINOR_VERSION).$(EPICS_NTYPES_MAINTENANCE_VERSION)
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
||||
|
||||
@@ -1,267 +0,0 @@
|
||||
/* ntattribute.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
#ifndef NTATTRIBUTE_H
|
||||
#define NTATTRIBUTE_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntattributeEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef ntattributeEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntattributeEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTAttribute;
|
||||
typedef std::tr1::shared_ptr<NTAttribute> NTAttributePtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTAttribute.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTAttributeBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTAttributeBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTAttributeBuilder);
|
||||
|
||||
/**
|
||||
* Add tags field to the NTAttribute.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
virtual shared_pointer addTags();
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTAttribute.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTAttribute.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTAttribute.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTAttribute.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTAttribute.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTAttribute</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTAttribute</b>.
|
||||
*/
|
||||
NTAttributePtr create();
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
protected://private:
|
||||
NTAttributeBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool tags;
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTAttribute;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTAttributeBuilder> NTAttributeBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTAttribute
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTAttribute
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTAttribute);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTAttribute.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTAttribute.
|
||||
* @return NTAttribute instance on success, nullptr otherwise.
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTAttribute without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTAttribute.
|
||||
* @return NTAttribute instance.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTAttribute.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTAttribute.
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTAttribute.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTAttribute.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTAttribute.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTAttribute.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTAttribute.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTAttribute.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTAttribute.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTAttribute
|
||||
* @return (false,true) if (is not, is) a valid NTAttribute.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTAttribute builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTAttributeBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTAttribute() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the name field.
|
||||
* @return The PVString for the name.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getName() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* @return The PVUnion for the values.
|
||||
*/
|
||||
epics::pvData::PVUnionPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the tags field.
|
||||
* @return The PVStringArray for the tags, which may be null.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getTags() const;
|
||||
|
||||
private:
|
||||
NTAttribute(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTAttribute;
|
||||
epics::pvData::PVUnionPtr pvValue;
|
||||
|
||||
friend class detail::NTAttributeBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTATTRIBUTE_H */
|
||||
@@ -1,262 +0,0 @@
|
||||
/* ntcontinuum.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
#ifndef NTCONTINUUM_H
|
||||
#define NTCONTINUUM_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntcontinuumEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef ntcontinuumEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntcontinuumEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTContinuum;
|
||||
typedef std::tr1::shared_ptr<NTContinuum> NTContinuumPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTContinuum.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTContinuumBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTContinuumBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTContinuumBuilder);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTContinuum.
|
||||
* @return this instance of <b>NTContinuumBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTContinuum.
|
||||
* @return this instance of <b>NTContinuumBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTContinuum.
|
||||
* @return this instance of <b>NTContinuumBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTContinuum.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTContinuum.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTContinuum</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTContinuum</b>.
|
||||
*/
|
||||
NTContinuumPtr create();
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* @return this instance of <b>NTContinuumBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTContinuumBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool dim;
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTContinuum;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTContinuumBuilder> NTContinuumBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTContinuum
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTContinuum
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTContinuum);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTContinuum.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTContinuum.
|
||||
* @return NTContinuum instance on success, nullptr otherwise.
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTContinuum without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTContinuum.
|
||||
* @return NTContinuum instance.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTContinuum.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTContinuum.
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTContinuum.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTContinuum.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTContinuum.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTContinuum.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTContinuum.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTContinuum.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTContinuum.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTContinuum
|
||||
* @return (false,true) if (is not, is) a valid NTContinuum.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTContinuum builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTContinuumBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTContinuum() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the base field.
|
||||
* @return The PVDoubleArray for the base.
|
||||
*/
|
||||
epics::pvData::PVDoubleArrayPtr getBase() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* @return The PVDoubleArray for the values.
|
||||
*/
|
||||
epics::pvData::PVDoubleArrayPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the units field.
|
||||
* @return The PVStringArray for the units.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getUnits() const;
|
||||
|
||||
private:
|
||||
NTContinuum(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTContinuum;
|
||||
epics::pvData::PVDoubleArrayPtr pvValue;
|
||||
|
||||
friend class detail::NTContinuumBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTCONTINUUM_H */
|
||||
@@ -1,343 +0,0 @@
|
||||
/* ntfield.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
|
||||
#include <pv/lock.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
using std::tr1::static_pointer_cast;
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
NTFieldPtr NTField::get()
|
||||
{
|
||||
static Mutex mutex;
|
||||
static NTFieldPtr ntstructureField;
|
||||
Lock xx(mutex);
|
||||
if(ntstructureField.get()==NULL) {
|
||||
ntstructureField = NTFieldPtr(new NTField());
|
||||
}
|
||||
return ntstructureField;
|
||||
}
|
||||
|
||||
NTField::NTField()
|
||||
: fieldCreate(getFieldCreate()),
|
||||
standardField(getStandardField())
|
||||
{
|
||||
}
|
||||
|
||||
bool NTField::isEnumerated(FieldConstPtr const & field)
|
||||
{
|
||||
if(field->getType()!=structure) return false;
|
||||
StructureConstPtr structurePtr = static_pointer_cast<const Structure>(field);
|
||||
FieldConstPtrArray fields = structurePtr->getFields();
|
||||
StringArray names = structurePtr->getFieldNames();
|
||||
size_t n = structurePtr->getNumberFields();
|
||||
if(n!=2) return false;
|
||||
FieldConstPtr f = fields[0];
|
||||
if(names[0].compare("index")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
ScalarConstPtr s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvInt) return false;
|
||||
f = fields[1];
|
||||
if(names[1].compare("choices")!=0) return false;
|
||||
if(f->getType()!=scalarArray) return false;
|
||||
ScalarConstPtr sa = static_pointer_cast<const Scalar>(f);
|
||||
if(sa->getScalarType()!=pvString) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NTField::isTimeStamp(FieldConstPtr const & field)
|
||||
{
|
||||
if(field->getType()!=structure) return false;
|
||||
StructureConstPtr structurePtr = static_pointer_cast<const Structure>(field);
|
||||
FieldConstPtrArray fields = structurePtr->getFields();
|
||||
StringArray names = structurePtr->getFieldNames();
|
||||
size_t n = structurePtr->getNumberFields();
|
||||
if(n!=3) return false;
|
||||
FieldConstPtr f = fields[0];
|
||||
if(names[0].compare("secondsPastEpoch")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
ScalarConstPtr s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvLong) return false;
|
||||
f = fields[1];
|
||||
if(names[1].compare("nanoseconds")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvInt) return false;
|
||||
f = fields[2];
|
||||
if(names[2].compare("userTag")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvInt) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NTField::isAlarm(FieldConstPtr const & field)
|
||||
{
|
||||
if(field->getType()!=structure) return false;
|
||||
StructureConstPtr structurePtr = static_pointer_cast<const Structure>(field);
|
||||
FieldConstPtrArray fields = structurePtr->getFields();
|
||||
StringArray names = structurePtr->getFieldNames();
|
||||
size_t n = structurePtr->getNumberFields();
|
||||
if(n!=3) return false;
|
||||
FieldConstPtr f = fields[0];
|
||||
if(names[0].compare("severity")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
ScalarConstPtr s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvInt) return false;
|
||||
f = fields[1];
|
||||
if(names[1].compare("status")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvInt) return false;
|
||||
f = fields[2];
|
||||
if(names[2].compare("message")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvString) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NTField::isDisplay(FieldConstPtr const & field)
|
||||
{
|
||||
if(field->getType()!=structure) return false;
|
||||
StructureConstPtr structurePtr = static_pointer_cast<const Structure>(field);
|
||||
FieldConstPtrArray fields = structurePtr->getFields();
|
||||
StringArray names = structurePtr->getFieldNames();
|
||||
size_t n = structurePtr->getNumberFields();
|
||||
if(n!=5) return false;
|
||||
FieldConstPtr f = fields[0];
|
||||
if(names[0].compare("limitLow")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
ScalarConstPtr s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvDouble) return false;
|
||||
f = fields[1];
|
||||
if(names[1].compare("limitHigh")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvDouble) return false;
|
||||
f = fields[2];
|
||||
if(names[2].compare("description")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvString) return false;
|
||||
f = fields[3];
|
||||
if(names[3].compare("format")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvString) return false;
|
||||
f = fields[4];
|
||||
if(names[4].compare("units")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvString) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NTField::isAlarmLimit(FieldConstPtr const & field)
|
||||
{
|
||||
if(field->getType()!=structure) return false;
|
||||
StructureConstPtr structurePtr = static_pointer_cast<const Structure>(field);
|
||||
FieldConstPtrArray fields = structurePtr->getFields();
|
||||
StringArray names = structurePtr->getFieldNames();
|
||||
size_t n = structurePtr->getNumberFields();
|
||||
if(n!=10) return false;
|
||||
FieldConstPtr f = fields[0];
|
||||
if(names[0].compare("active")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
ScalarConstPtr s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvBoolean) return false;
|
||||
f = fields[1];
|
||||
if(names[1].compare("lowAlarmLimit")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvDouble) return false;
|
||||
f = fields[2];
|
||||
if(names[2].compare("lowWarningLimit")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvDouble) return false;
|
||||
f = fields[3];
|
||||
if(names[3].compare("highWarningLimit")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvDouble) return false;
|
||||
f = fields[4];
|
||||
if(names[4].compare("highAlarmLimit")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvDouble) return false;
|
||||
f = fields[5];
|
||||
if(names[5].compare("lowAlarmSeverity")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvInt) return false;
|
||||
f = fields[6];
|
||||
if(names[6].compare("lowWarningSeverity")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvInt) return false;
|
||||
f = fields[7];
|
||||
if(names[7].compare("highWarningSeverity")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvInt) return false;
|
||||
f = fields[8];
|
||||
if(names[8].compare("highAlarmSeverity")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvInt) return false;
|
||||
f = fields[9];
|
||||
if(names[9].compare("hysteresis")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NTField::isControl(FieldConstPtr const & field)
|
||||
{
|
||||
if(field->getType()!=structure) return false;
|
||||
StructureConstPtr structurePtr = static_pointer_cast<const Structure>(field);
|
||||
FieldConstPtrArray fields = structurePtr->getFields();
|
||||
StringArray names = structurePtr->getFieldNames();
|
||||
size_t n = structurePtr->getNumberFields();
|
||||
if(n!=3) return false;
|
||||
FieldConstPtr f = fields[0];
|
||||
if(names[0].compare("limitLow")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
ScalarConstPtr s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvDouble) return false;
|
||||
f = fields[1];
|
||||
if(names[1].compare("limitHigh")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvDouble) return false;
|
||||
f = fields[2];
|
||||
if(names[2].compare("minStep")!=0) return false;
|
||||
if(f->getType()!=scalar) return false;
|
||||
s = static_pointer_cast<const Scalar>(f);
|
||||
if(s->getScalarType()!=pvDouble) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createEnumerated()
|
||||
{
|
||||
return standardField->enumerated();
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createTimeStamp()
|
||||
{
|
||||
return standardField->timeStamp();
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createAlarm()
|
||||
{
|
||||
return standardField->alarm();
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createDisplay()
|
||||
{
|
||||
return standardField->display();
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createControl()
|
||||
{
|
||||
return standardField->control();
|
||||
}
|
||||
|
||||
StructureArrayConstPtr NTField::createEnumeratedArray()
|
||||
{
|
||||
return fieldCreate->createStructureArray(createEnumerated());
|
||||
}
|
||||
|
||||
StructureArrayConstPtr NTField::createTimeStampArray()
|
||||
{
|
||||
StructureConstPtr st = createTimeStamp();
|
||||
return fieldCreate->createStructureArray(st);
|
||||
}
|
||||
|
||||
StructureArrayConstPtr NTField::createAlarmArray()
|
||||
{
|
||||
StructureConstPtr st = createAlarm();
|
||||
return fieldCreate->createStructureArray(st);
|
||||
}
|
||||
|
||||
PVNTFieldPtr PVNTField::get()
|
||||
{
|
||||
static Mutex mutex;
|
||||
static PVNTFieldPtr pvntstructureField;
|
||||
Lock xx(mutex);
|
||||
if(pvntstructureField.get()==NULL) {
|
||||
pvntstructureField = PVNTFieldPtr(new PVNTField());
|
||||
}
|
||||
return pvntstructureField;
|
||||
}
|
||||
|
||||
PVNTField::PVNTField()
|
||||
: pvDataCreate(getPVDataCreate()),
|
||||
standardField(getStandardField()),
|
||||
standardPVField(getStandardPVField()),
|
||||
ntstructureField(NTField::get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PVStructurePtr PVNTField::createEnumerated(
|
||||
StringArray const & choices)
|
||||
{
|
||||
return standardPVField->enumerated(choices);
|
||||
}
|
||||
|
||||
PVStructurePtr PVNTField::createTimeStamp()
|
||||
{
|
||||
StructureConstPtr timeStamp = standardField->timeStamp();
|
||||
return pvDataCreate->createPVStructure(timeStamp);
|
||||
}
|
||||
|
||||
PVStructurePtr PVNTField::createAlarm()
|
||||
{
|
||||
StructureConstPtr alarm = standardField->alarm();
|
||||
return pvDataCreate->createPVStructure(alarm);
|
||||
}
|
||||
|
||||
PVStructurePtr PVNTField::createDisplay()
|
||||
{
|
||||
StructureConstPtr display = standardField->display();
|
||||
return pvDataCreate->createPVStructure(display);
|
||||
}
|
||||
|
||||
|
||||
PVStructurePtr PVNTField::createControl()
|
||||
{
|
||||
StructureConstPtr control = standardField->control();
|
||||
return pvDataCreate->createPVStructure(control);
|
||||
}
|
||||
|
||||
PVStructureArrayPtr PVNTField::createEnumeratedArray()
|
||||
{
|
||||
StructureArrayConstPtr sa =
|
||||
ntstructureField->createEnumeratedArray();
|
||||
return pvDataCreate->createPVStructureArray(sa);
|
||||
}
|
||||
|
||||
PVStructureArrayPtr PVNTField::createTimeStampArray()
|
||||
{
|
||||
StructureArrayConstPtr sa =
|
||||
ntstructureField->createTimeStampArray();
|
||||
return pvDataCreate->createPVStructureArray(sa);
|
||||
}
|
||||
|
||||
PVStructureArrayPtr PVNTField::createAlarmArray()
|
||||
{
|
||||
StructureArrayConstPtr sa = ntstructureField->createAlarmArray();
|
||||
return pvDataCreate->createPVStructureArray(sa);
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -1,277 +0,0 @@
|
||||
/* nthistogram.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
#ifndef NTHISTOGRAM_H
|
||||
#define NTHISTOGRAM_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define nthistogramEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef nthistogramEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef nthistogramEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTHistogram;
|
||||
typedef std::tr1::shared_ptr<NTHistogram> NTHistogramPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTHistogram.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTHistogramBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTHistogramBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTHistogramBuilder);
|
||||
|
||||
/**
|
||||
* Set a scalar type of value field array.
|
||||
* @param scalarType the value type.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer value(epics::pvData::ScalarType scalarType);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTHistogram.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTHistogram.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTHistogram.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTHistogram.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTHistogram.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTHistogram</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTHistogram</b>.
|
||||
*/
|
||||
NTHistogramPtr create();
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTHistogramBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool valueTypeSet;
|
||||
epics::pvData::ScalarType valueType;
|
||||
|
||||
bool dim;
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTHistogram;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTHistogramBuilder> NTHistogramBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTHistogram
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTHistogram
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTHistogram);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTHistogram.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTHistogram.
|
||||
* @return NTHistogram instance on success, nullptr otherwise.
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTHistogram without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTHistogram.
|
||||
* @return NTHistogram instance.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTHistogram.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTHistogram.
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTHistogram.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTHistogram.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTHistogram.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTHistogram.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTHistogram.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTHistogram.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTHistogram.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTHistogram
|
||||
* @return (false,true) if (is not, is) a valid NTHistogram.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTHistogram builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTHistogramBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTHistogram() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the base field.
|
||||
* @return The PVDoubleArray for the base.
|
||||
*/
|
||||
epics::pvData::PVDoubleArrayPtr getRanges() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* @return The PVScalarArray for the values.
|
||||
*/
|
||||
epics::pvData::PVScalarArrayPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the value field of a specified type (e.g. PVIntArray).
|
||||
* @return The <PVT> field for the values.
|
||||
*/
|
||||
template<typename PVT>
|
||||
std::tr1::shared_ptr<PVT> getValue() const
|
||||
{
|
||||
return std::tr1::dynamic_pointer_cast<PVT>(pvValue);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
NTHistogram(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTHistogram;
|
||||
epics::pvData::PVScalarArrayPtr pvValue;
|
||||
|
||||
friend class detail::NTHistogramBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTHISTOGRAM_H */
|
||||
@@ -1,285 +0,0 @@
|
||||
/* ntmatrix.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
#ifndef NTMATRIX_H
|
||||
#define NTMATRIX_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntmatrixEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/pvDisplay.h>
|
||||
|
||||
#ifdef ntmatrixEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntmatrixEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTMatrix;
|
||||
typedef std::tr1::shared_ptr<NTMatrix> NTMatrixPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTMatrix.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTMatrixBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTMatrixBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTMatrixBuilder);
|
||||
|
||||
/**
|
||||
* Add dimensionfield to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDim();
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Add display structure to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDisplay();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTMatrix.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTMatrix.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTMatrix</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTMatrix</b>.
|
||||
*/
|
||||
NTMatrixPtr create();
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTMatrixBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool dim;
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
bool display;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTMatrix;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTMatrixBuilder> NTMatrixBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTMatrix
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTMatrix
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTMatrix);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTMatrix.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTMatrix.
|
||||
* @return NTMatrix instance on success, nullptr otherwise.
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTMatrix without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTMatrix.
|
||||
* @return NTMatrix instance.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTMatrix.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTMatrix.
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTMatrix.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTMatrix.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTMatrix.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTMatrix.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTMatrix.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTMatrix.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTMatrix.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTMatrix
|
||||
* @return (false,true) if (is not, is) a valid NTMatrix.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTMatrix builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTMatrixBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTMatrix() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Attach an pvDisplay.
|
||||
* @param pvDisplay The pvDisplay that will be attached.
|
||||
* Does nothing if no display.
|
||||
* @return true if the operation was successfull (i.e. this instance has a display field), otherwise false.
|
||||
*/
|
||||
bool attachDisplay(epics::pvData::PVDisplay &pvDisplay) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the display.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getDisplay() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* @return The PVDoubleArray for the values.
|
||||
*/
|
||||
epics::pvData::PVDoubleArrayPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the dim field.
|
||||
* @return The PVIntArray for the dim which may be null.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getDim() const;
|
||||
|
||||
private:
|
||||
NTMatrix(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTMatrix;
|
||||
epics::pvData::PVDoubleArrayPtr pvValue;
|
||||
|
||||
friend class detail::NTMatrixBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTMATRIX_H */
|
||||
@@ -1,319 +0,0 @@
|
||||
/* ntndarray.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
#ifndef NTNDARRAY_H
|
||||
#define NTNDARRAY_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntscalarArrayEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/pvDisplay.h>
|
||||
#include <pv/pvControl.h>
|
||||
|
||||
#ifdef ntscalarArrayEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntscalarArrayEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTNDArray;
|
||||
typedef std::tr1::shared_ptr<NTNDArray> NTNDArrayPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTNDArray.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author mse
|
||||
*/
|
||||
class epicsShareClass NTNDArrayBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTNDArrayBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTNDArrayBuilder);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTNDArray.
|
||||
* @return this instance of <b>NTNDArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTNDArray.
|
||||
* @return this instance of <b>NTNDArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTNDArray.
|
||||
* @return this instance of <b>NTNDArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Add display structure to the NTNDArray.
|
||||
* @return this instance of <b>NTNDArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDisplay();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTNDArray.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTNDArray.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTNDArray</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTNDArray</b>
|
||||
*/
|
||||
NTNDArrayPtr create();
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* @return this instance of a <b>NTArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTNDArrayBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool descriptor;
|
||||
bool timeStamp;
|
||||
bool alarm;
|
||||
bool display;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTNDArray;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTNDArrayBuilder> NTNDArrayBuilderPtr;
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTNDArray
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTNDArray
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTNDArray);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTNDArray.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTNDArray.
|
||||
* @return NTNDArray instance on success, nullptr otherwise.
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTNDArray without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTNDArray.
|
||||
* @return NTNDArray instance.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTNDArray.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTNDArray.
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTNDArray.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTNDArray.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTNDArray.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTNDArray.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTNDArray.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTNDArray.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTNDArray.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTNDArray
|
||||
* @return (false,true) if (is not, is) a valid NTNDArray.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTNDArrayBuilder instance
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTNDArrayBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTNDArray() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp to timeStamp field.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp to dataTimeStamp field.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachDataTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* @return The PVField for the values.
|
||||
*/
|
||||
epics::pvData::PVUnionPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the codec field.
|
||||
* @return the PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getCodec() const;
|
||||
|
||||
/**
|
||||
* Get the compressedDataSize field.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVLongPtr getCompressedDataSize() const;
|
||||
|
||||
/**
|
||||
* Get the uncompressedDataSize field.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVLongPtr getUncompressedDataSize() const;
|
||||
|
||||
/**
|
||||
* Get the dimension field.
|
||||
* @return the PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructureArrayPtr getDimension() const;
|
||||
|
||||
/**
|
||||
* Get the uniqueId field.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVIntPtr getUniqueId() const;
|
||||
|
||||
/**
|
||||
* Get the data timeStamp field.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getDataTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the attribute field.
|
||||
* @return the PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructureArrayPtr getAttribute() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp field.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm field.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the display field.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getDisplay() const;
|
||||
|
||||
private:
|
||||
NTNDArray(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
epics::pvData::int64 getExpectedUncompressedSize();
|
||||
epics::pvData::int64 getValueSize();
|
||||
epics::pvData::int64 getValueTypeSize();
|
||||
|
||||
epics::pvData::PVStructurePtr pvNTNDArray;
|
||||
|
||||
friend class detail::NTNDArrayBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTNDARRAY_H */
|
||||
@@ -1,279 +0,0 @@
|
||||
/* ntndarrayAttribute.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
#ifndef NTNDARRAYATTRIBUTE_H
|
||||
#define NTNDARRAYATTRIBUTE_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntndarrayAttributeEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef ntndarrayAttributeEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntndarrayAttributeEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTNDArrayAttribute;
|
||||
typedef std::tr1::shared_ptr<NTNDArrayAttribute> NTNDArrayAttributePtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTAttribute extended as required by NTNDArray
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTNDArrayAttributeBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTNDArrayAttributeBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTNDArrayAttributeBuilder);
|
||||
|
||||
/**
|
||||
* Add tags field to the NTNDArrayAttribute.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
virtual shared_pointer addTags();
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTNDArrayAttribute.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTNDArrayAttribute.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTNDArrayAttribute.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTNDArrayAttribute.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTNDArrayAttribute.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTNDArrayAttribute</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTNDArrayAttribute</b>.
|
||||
*/
|
||||
NTNDArrayAttributePtr create();
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
protected://private:
|
||||
NTNDArrayAttributeBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool tags;
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTNDArrayAttribute;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTNDArrayAttributeBuilder> NTNDArrayAttributeBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @briVIntPtref Convenience Class for NTNDArrayAttribute
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTNDArrayAttribute
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTNDArrayAttribute);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTNDArrayAttribute.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTNDArrayAttribute.
|
||||
* @return NTNDArrayAttribute instance on success, nullptr otherwise.
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTNDArrayAttribute without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTNDArrayAttribute.
|
||||
* @return NTNDArrayAttribute instance.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTNDArrayAttribute.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTNDArrayAttribute.
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTNDArrayAttribute.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTNDArrayAttribute.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTNDArrayAttribute.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTNDArrayAttribute.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTNDArrayAttribute.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTNDArrayAttribute.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTNDArrayAttribute.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTNDArrayAttribute
|
||||
* @return (false,true) if (is not, is) a valid NTNDArrayAttribute.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTNDArrayAttribute builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTNDArrayAttributeBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTNDArrayAttribute() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the name field.
|
||||
* @return The PVString for the name.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getName() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* @return The PVUnion for the values.
|
||||
*/
|
||||
epics::pvData::PVUnionPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the tags field.
|
||||
* @return The PVStringArray for the tags, which may be null.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getTags() const;
|
||||
|
||||
/**
|
||||
* Get the sourceType field.
|
||||
* @return The PVInt for the sourceType field.
|
||||
*/
|
||||
epics::pvData::PVIntPtr getSourceType() const;
|
||||
|
||||
/**
|
||||
* Get the source field.
|
||||
* @return The PVString for the source field, which may be null.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getSource() const;
|
||||
|
||||
private:
|
||||
NTNDArrayAttribute(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTNDArrayAttribute;
|
||||
epics::pvData::PVUnionPtr pvValue;
|
||||
|
||||
friend class detail::NTNDArrayAttributeBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTNDARRAYATTRIBUTE_H */
|
||||
250
src/nt/ntunion.h
250
src/nt/ntunion.h
@@ -1,250 +0,0 @@
|
||||
/* ntunion.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
#ifndef NTUNION_H
|
||||
#define NTUNION_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntunionEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef ntunionEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntunionEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTUnion;
|
||||
typedef std::tr1::shared_ptr<NTUnion> NTUnionPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTUnion.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTUnionBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTUnionBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTUnionBuilder);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTUnion.
|
||||
* @return this instance of <b>NTUnionBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTUnion.
|
||||
* @return this instance of <b>NTUnionBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTUnion.
|
||||
* @return this instance of <b>NTUnionBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTUnion.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTUnion.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTUnion</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTUnion</b>.
|
||||
*/
|
||||
NTUnionPtr create();
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* @return this instance of <b>NTUnionBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTUnionBuilder();
|
||||
|
||||
epics::pvData::UnionConstPtr valueType;
|
||||
|
||||
void reset();
|
||||
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTUnion;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTUnionBuilder> NTUnionBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTUnion
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTUnion
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTUnion);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTUnion.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTUnion.
|
||||
* @return NTUnion instance on success, nullptr otherwise.
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTUnion without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTUnion.
|
||||
* @return NTUnion instance.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTUnion.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTUnion.
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTUnion.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTUnion.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTUnion.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTUnion.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTUnion.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTUnion.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTUnion.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTUnion
|
||||
* @return (false,true) if (is not, is) a valid NTUnion.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTUnion builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTUnionBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTUnion() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* @return The PVUnion for the values.
|
||||
*/
|
||||
epics::pvData::PVUnionPtr getValue() const;
|
||||
|
||||
private:
|
||||
NTUnion(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTUnion;
|
||||
epics::pvData::PVUnionPtr pvValue;
|
||||
|
||||
friend class detail::NTUnionBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTUNION_H */
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntaggregate.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntaggregate.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -171,15 +172,15 @@ NTAggregateBuilder::shared_pointer NTAggregateBuilder::add(string const & name,
|
||||
|
||||
const std::string NTAggregate::URI("epics:nt/NTAggregate:1.0");
|
||||
|
||||
NTAggregate::shared_pointer NTAggregate::wrap(PVStructurePtr const & structure)
|
||||
NTAggregate::shared_pointer NTAggregate::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTAggregate::shared_pointer NTAggregate::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTAggregate::shared_pointer NTAggregate::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTAggregate(structure));
|
||||
return shared_pointer(new NTAggregate(pvStructure));
|
||||
}
|
||||
|
||||
bool NTAggregate::is_a(StructureConstPtr const & structure)
|
||||
@@ -187,85 +188,34 @@ bool NTAggregate::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTAggregate::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
|
||||
bool NTAggregate::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarConstPtr valueField = structure->getField<Scalar>("value");
|
||||
if (valueField.get() == 0 || valueField->getScalarType() != pvDouble)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
ScalarConstPtr nField = structure->getField<Scalar>("N");
|
||||
if (nField.get() == 0 || nField->getScalarType() != pvLong)
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
FieldConstPtr field = structure->getField("dispersion");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr dispersionField = structure->getField<Scalar>("dispersion");
|
||||
if (!dispersionField.get() || dispersionField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("first");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr firstField = structure->getField<Scalar>("first");
|
||||
if (!firstField.get() || firstField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("firstTimeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("last");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr lastField = structure->getField<Scalar>("last");
|
||||
if (!lastField.get() || lastField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("lastTimeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("max");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr maxField = structure->getField<Scalar>("max");
|
||||
if (!maxField.get() || maxField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("min");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr minField = structure->getField<Scalar>("min");
|
||||
if (!minField.get() || minField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<Scalar>("value")
|
||||
.has<Scalar>("N")
|
||||
.maybeHas<Scalar>("dispersion")
|
||||
.maybeHas<Scalar>("first")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("firstTimeStamp")
|
||||
.maybeHas<Scalar>("last")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("lastTimeStamp")
|
||||
.maybeHas<Scalar>("max")
|
||||
.maybeHas<Scalar>("min")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTAggregate::isCompatible(PVStructurePtr const & pvStructure)
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntattribute.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntattribute.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -108,15 +109,15 @@ NTAttributeBuilder::shared_pointer NTAttributeBuilder::add(string const & name,
|
||||
|
||||
const std::string NTAttribute::URI("epics:nt/NTAttribute:1.0");
|
||||
|
||||
NTAttribute::shared_pointer NTAttribute::wrap(PVStructurePtr const & structure)
|
||||
NTAttribute::shared_pointer NTAttribute::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTAttribute::shared_pointer NTAttribute::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTAttribute::shared_pointer NTAttribute::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTAttribute(structure));
|
||||
return shared_pointer(new NTAttribute(pvStructure));
|
||||
}
|
||||
|
||||
bool NTAttribute::is_a(StructureConstPtr const & structure)
|
||||
@@ -124,47 +125,28 @@ bool NTAttribute::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTAttribute::isCompatible(StructureConstPtr const & structure)
|
||||
bool NTAttribute::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarConstPtr nameField = structure->getField<Scalar>("name");
|
||||
if (nameField.get() == 0 || nameField->getScalarType() != pvString)
|
||||
return false;
|
||||
|
||||
UnionConstPtr valueField = structure->getField<Union>("value");
|
||||
if (valueField.get() == 0 || !valueField->isVariant())
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("tags");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr tagsField = structure->getField<ScalarArray>("tags");
|
||||
if (tagsField.get() == 0 || tagsField->getElementType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTAttribute::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
Result result(structure);
|
||||
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<Scalar>("name")
|
||||
.has<Union>("value")
|
||||
.maybeHas<ScalarArray>("tags")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTAttribute::isCompatible(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntcontinuum.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntcontinuum.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -100,15 +101,15 @@ NTContinuumBuilder::shared_pointer NTContinuumBuilder::add(string const & name,
|
||||
|
||||
const std::string NTContinuum::URI("epics:nt/NTContinuum:1.0");
|
||||
|
||||
NTContinuum::shared_pointer NTContinuum::wrap(PVStructurePtr const & structure)
|
||||
NTContinuum::shared_pointer NTContinuum::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTContinuum::shared_pointer NTContinuum::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTContinuum::shared_pointer NTContinuum::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTContinuum(structure));
|
||||
return shared_pointer(new NTContinuum(pvStructure));
|
||||
}
|
||||
|
||||
bool NTContinuum::is_a(StructureConstPtr const & structure)
|
||||
@@ -116,43 +117,28 @@ bool NTContinuum::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTContinuum::isCompatible(StructureConstPtr const & structure)
|
||||
bool NTContinuum::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarArrayConstPtr baseField = structure->getField<ScalarArray>("base");
|
||||
if (baseField.get() == 0 || baseField->getElementType() != pvDouble)
|
||||
return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (valueField.get() == 0 || valueField->getElementType() != pvDouble)
|
||||
return false;
|
||||
|
||||
ScalarArrayConstPtr unitsField = structure->getField<ScalarArray>("units");
|
||||
if (unitsField.get() == 0 || unitsField->getElementType() != pvString)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTContinuum::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
Result result(structure);
|
||||
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("base")
|
||||
.has<ScalarArray>("value")
|
||||
.has<ScalarArray>("units")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTContinuum::isCompatible(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntenum.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntenum.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -99,15 +100,15 @@ NTEnumBuilder::shared_pointer NTEnumBuilder::add(string const & name, FieldConst
|
||||
|
||||
const std::string NTEnum::URI("epics:nt/NTEnum:1.0");
|
||||
|
||||
NTEnum::shared_pointer NTEnum::wrap(PVStructurePtr const & structure)
|
||||
NTEnum::shared_pointer NTEnum::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTEnum::shared_pointer NTEnum::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTEnum::shared_pointer NTEnum::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTEnum(structure));
|
||||
return shared_pointer(new NTEnum(pvStructure));
|
||||
}
|
||||
|
||||
bool NTEnum::is_a(StructureConstPtr const & structure)
|
||||
@@ -115,35 +116,26 @@ bool NTEnum::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTEnum::isCompatible(StructureConstPtr const &structure)
|
||||
bool NTEnum::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
FieldConstPtr valueField = structure->getField("value");
|
||||
if (!valueField.get() || !ntField->isEnumerated(valueField))
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTEnum::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
Result result(structure);
|
||||
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<&NTField::isEnumerated, Structure>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTEnum::isCompatible(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
241
src/ntfield.cpp
Normal file
241
src/ntfield.cpp
Normal file
@@ -0,0 +1,241 @@
|
||||
/* ntfield.cpp */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <pv/lock.h>
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
using std::tr1::static_pointer_cast;
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
NTFieldPtr NTField::get()
|
||||
{
|
||||
static Mutex mutex;
|
||||
static NTFieldPtr ntstructureField;
|
||||
Lock xx(mutex);
|
||||
if(ntstructureField.get()==NULL) {
|
||||
ntstructureField = NTFieldPtr(new NTField());
|
||||
}
|
||||
return ntstructureField;
|
||||
}
|
||||
|
||||
NTField::NTField()
|
||||
: fieldCreate(getFieldCreate()),
|
||||
standardField(getStandardField())
|
||||
{
|
||||
}
|
||||
|
||||
Result& NTField::isEnumerated(Result& result)
|
||||
{
|
||||
return result
|
||||
.has<Scalar>("index")
|
||||
.has<ScalarArray>("choices");
|
||||
}
|
||||
|
||||
bool NTField::isEnumerated(FieldConstPtr const & field)
|
||||
{
|
||||
Result result(field);
|
||||
return isEnumerated(result.is<Structure>()).valid();
|
||||
}
|
||||
|
||||
Result& NTField::isTimeStamp(Result& result)
|
||||
{
|
||||
return result
|
||||
.has<Scalar>("secondsPastEpoch")
|
||||
.has<Scalar>("nanoseconds")
|
||||
.has<Scalar>("userTag");
|
||||
}
|
||||
|
||||
bool NTField::isTimeStamp(FieldConstPtr const & field)
|
||||
{
|
||||
Result result(field);
|
||||
return isTimeStamp(result.is<Structure>()).valid();
|
||||
}
|
||||
|
||||
Result& NTField::isAlarm(Result& result)
|
||||
{
|
||||
return result
|
||||
.has<Scalar>("severity")
|
||||
.has<Scalar>("status")
|
||||
.has<Scalar>("message");
|
||||
}
|
||||
|
||||
bool NTField::isAlarm(FieldConstPtr const & field)
|
||||
{
|
||||
Result result(field);
|
||||
return isAlarm(result.is<Structure>()).valid();
|
||||
}
|
||||
|
||||
Result& NTField::isDisplay(Result& result)
|
||||
{
|
||||
return result
|
||||
.has<Scalar>("limitLow")
|
||||
.has<Scalar>("limitHigh")
|
||||
.has<Scalar>("description")
|
||||
.has<Scalar>("format")
|
||||
.has<Scalar>("units");
|
||||
|
||||
}
|
||||
|
||||
bool NTField::isDisplay(FieldConstPtr const & field)
|
||||
{
|
||||
Result result(field);
|
||||
return isDisplay(result.is<Structure>()).valid();
|
||||
}
|
||||
|
||||
Result& NTField::isAlarmLimit(Result& result)
|
||||
{
|
||||
return result
|
||||
.has<Scalar>("active")
|
||||
.has<Scalar>("lowAlarmLimit")
|
||||
.has<Scalar>("lowWarningLimit")
|
||||
.has<Scalar>("highWarningLimit")
|
||||
.has<Scalar>("highAlarmLimit")
|
||||
.has<Scalar>("lowAlarmSeverity")
|
||||
.has<Scalar>("lowWarningSeverity")
|
||||
.has<Scalar>("highWarningSeverity")
|
||||
.has<Scalar>("highAlarmSeverity")
|
||||
.has<Scalar>("hysteresis");
|
||||
}
|
||||
|
||||
bool NTField::isAlarmLimit(FieldConstPtr const & field)
|
||||
{
|
||||
Result result(field);
|
||||
return isAlarmLimit(result.is<Structure>()).valid();
|
||||
}
|
||||
|
||||
Result& NTField::isControl(Result& result)
|
||||
{
|
||||
return result
|
||||
.has<Scalar>("limitLow")
|
||||
.has<Scalar>("limitHigh")
|
||||
.has<Scalar>("minStep");
|
||||
}
|
||||
|
||||
bool NTField::isControl(FieldConstPtr const & field)
|
||||
{
|
||||
Result result(field);
|
||||
return isControl(result.is<Structure>()).valid();
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createEnumerated()
|
||||
{
|
||||
return standardField->enumerated();
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createTimeStamp()
|
||||
{
|
||||
return standardField->timeStamp();
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createAlarm()
|
||||
{
|
||||
return standardField->alarm();
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createDisplay()
|
||||
{
|
||||
return standardField->display();
|
||||
}
|
||||
|
||||
StructureConstPtr NTField::createControl()
|
||||
{
|
||||
return standardField->control();
|
||||
}
|
||||
|
||||
StructureArrayConstPtr NTField::createEnumeratedArray()
|
||||
{
|
||||
return fieldCreate->createStructureArray(createEnumerated());
|
||||
}
|
||||
|
||||
StructureArrayConstPtr NTField::createTimeStampArray()
|
||||
{
|
||||
StructureConstPtr st = createTimeStamp();
|
||||
return fieldCreate->createStructureArray(st);
|
||||
}
|
||||
|
||||
StructureArrayConstPtr NTField::createAlarmArray()
|
||||
{
|
||||
StructureConstPtr st = createAlarm();
|
||||
return fieldCreate->createStructureArray(st);
|
||||
}
|
||||
|
||||
PVNTFieldPtr PVNTField::get()
|
||||
{
|
||||
static Mutex mutex;
|
||||
static PVNTFieldPtr pvntstructureField;
|
||||
Lock xx(mutex);
|
||||
if(pvntstructureField.get()==NULL) {
|
||||
pvntstructureField = PVNTFieldPtr(new PVNTField());
|
||||
}
|
||||
return pvntstructureField;
|
||||
}
|
||||
|
||||
PVNTField::PVNTField()
|
||||
: pvDataCreate(getPVDataCreate()),
|
||||
standardField(getStandardField()),
|
||||
standardPVField(getStandardPVField()),
|
||||
ntstructureField(NTField::get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PVStructurePtr PVNTField::createEnumerated(
|
||||
StringArray const & choices)
|
||||
{
|
||||
return standardPVField->enumerated(choices);
|
||||
}
|
||||
|
||||
PVStructurePtr PVNTField::createTimeStamp()
|
||||
{
|
||||
StructureConstPtr timeStamp = standardField->timeStamp();
|
||||
return pvDataCreate->createPVStructure(timeStamp);
|
||||
}
|
||||
|
||||
PVStructurePtr PVNTField::createAlarm()
|
||||
{
|
||||
StructureConstPtr alarm = standardField->alarm();
|
||||
return pvDataCreate->createPVStructure(alarm);
|
||||
}
|
||||
|
||||
PVStructurePtr PVNTField::createDisplay()
|
||||
{
|
||||
StructureConstPtr display = standardField->display();
|
||||
return pvDataCreate->createPVStructure(display);
|
||||
}
|
||||
|
||||
|
||||
PVStructurePtr PVNTField::createControl()
|
||||
{
|
||||
StructureConstPtr control = standardField->control();
|
||||
return pvDataCreate->createPVStructure(control);
|
||||
}
|
||||
|
||||
PVStructureArrayPtr PVNTField::createEnumeratedArray()
|
||||
{
|
||||
StructureArrayConstPtr sa =
|
||||
ntstructureField->createEnumeratedArray();
|
||||
return pvDataCreate->createPVStructureArray(sa);
|
||||
}
|
||||
|
||||
PVStructureArrayPtr PVNTField::createTimeStampArray()
|
||||
{
|
||||
StructureArrayConstPtr sa =
|
||||
ntstructureField->createTimeStampArray();
|
||||
return pvDataCreate->createPVStructureArray(sa);
|
||||
}
|
||||
|
||||
PVStructureArrayPtr PVNTField::createAlarmArray()
|
||||
{
|
||||
StructureArrayConstPtr sa = ntstructureField->createAlarmArray();
|
||||
return pvDataCreate->createPVStructureArray(sa);
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntcontinuum.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/nthistogram.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -113,15 +114,15 @@ NTHistogramBuilder::shared_pointer NTHistogramBuilder::add(string const & name,
|
||||
|
||||
const std::string NTHistogram::URI("epics:nt/NTHistogram:1.0");
|
||||
|
||||
NTHistogram::shared_pointer NTHistogram::wrap(PVStructurePtr const & structure)
|
||||
NTHistogram::shared_pointer NTHistogram::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTHistogram::shared_pointer NTHistogram::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTHistogram::shared_pointer NTHistogram::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTHistogram(structure));
|
||||
return shared_pointer(new NTHistogram(pvStructure));
|
||||
}
|
||||
|
||||
bool NTHistogram::is_a(StructureConstPtr const & structure)
|
||||
@@ -129,39 +130,26 @@ bool NTHistogram::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTHistogram::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTHistogram::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if(!structure.get()) return false;
|
||||
|
||||
ScalarArrayConstPtr rangesField = structure->getField<ScalarArray>("ranges");
|
||||
if(!rangesField.get() || rangesField->getElementType() != pvDouble) return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if(!valueField.get()) return false;
|
||||
|
||||
ScalarType scalarType = valueField->getElementType();
|
||||
if (scalarType != pvShort &&
|
||||
scalarType != pvInt &&
|
||||
scalarType != pvLong)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if(field)
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("ranges")
|
||||
.has<ScalarArray>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTHistogram::isCompatible(PVStructurePtr const & pvStructure)
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/* ntid.cpp */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <pv/ntid.h>
|
||||
#include <pv/typeCast.h>
|
||||
|
||||
namespace epics {
|
||||
namespace epics {
|
||||
|
||||
namespace nt {
|
||||
|
||||
const static std::string BAD_NAME = "?";
|
||||
const static std::string BAD_NAME = "?";
|
||||
|
||||
NTID::NTID(const std::string & id)
|
||||
: fullName(id),
|
||||
@@ -81,7 +81,7 @@ namespace nt {
|
||||
else
|
||||
{
|
||||
name = fullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ namespace nt {
|
||||
{
|
||||
endMajorIndex = fullName.find('.', versionSepIndex+1);
|
||||
majorVersionStr = (endMajorIndex != std::string::npos)
|
||||
? fullName.substr(versionSepIndex+1, endMajorIndex-(versionSepIndex+1)) :
|
||||
? fullName.substr(versionSepIndex+1, endMajorIndex-(versionSepIndex+1)) :
|
||||
fullName.substr(versionSepIndex+1);
|
||||
}
|
||||
else
|
||||
@@ -150,7 +150,7 @@ namespace nt {
|
||||
{
|
||||
endMinorIndex = fullName.find('.', endMajorIndex+1);
|
||||
minorVersionStr = (endMinorIndex != std::string::npos)
|
||||
? fullName.substr(endMajorIndex+1, endMinorIndex-(endMajorIndex+1)) :
|
||||
? fullName.substr(endMajorIndex+1, endMinorIndex-(endMajorIndex+1)) :
|
||||
fullName.substr(endMajorIndex+1);
|
||||
}
|
||||
else
|
||||
@@ -186,5 +186,3 @@ namespace nt {
|
||||
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntmatrix.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntmatrix.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -117,15 +118,15 @@ NTMatrixBuilder::shared_pointer NTMatrixBuilder::add(string const & name, FieldC
|
||||
|
||||
const std::string NTMatrix::URI("epics:nt/NTMatrix:1.0");
|
||||
|
||||
NTMatrix::shared_pointer NTMatrix::wrap(PVStructurePtr const & structure)
|
||||
NTMatrix::shared_pointer NTMatrix::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTMatrix::shared_pointer NTMatrix::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTMatrix::shared_pointer NTMatrix::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTMatrix(structure));
|
||||
return shared_pointer(new NTMatrix(pvStructure));
|
||||
}
|
||||
|
||||
bool NTMatrix::is_a(StructureConstPtr const & structure)
|
||||
@@ -133,45 +134,27 @@ bool NTMatrix::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTMatrix::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTMatrix::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (valueField.get() == 0 || valueField->getElementType() != pvDouble)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("dim");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr dimField = structure->getField<ScalarArray>("dim");
|
||||
if (dimField.get() == 0 || dimField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("display");
|
||||
if (field.get() && !ntField->isDisplay(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("value")
|
||||
.maybeHas<ScalarArray>("dim")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.maybeHas<&NTField::isDisplay, Structure>("display")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTMatrix::isCompatible(PVStructurePtr const & pvStructure)
|
||||
@@ -1,12 +1,13 @@
|
||||
/* ntmultiChannel.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntmultiChannel.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -14,7 +15,7 @@
|
||||
using namespace std;
|
||||
using namespace epics::pvData;
|
||||
|
||||
namespace epics { namespace nt {
|
||||
namespace epics { namespace nt {
|
||||
|
||||
|
||||
static FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
@@ -210,15 +211,15 @@ NTMultiChannelBuilder::shared_pointer NTMultiChannelBuilder::add(string const &
|
||||
|
||||
const std::string NTMultiChannel::URI("epics:nt/NTMultiChannel:1.0");
|
||||
|
||||
NTMultiChannel::shared_pointer NTMultiChannel::wrap(PVStructurePtr const & structure)
|
||||
NTMultiChannel::shared_pointer NTMultiChannel::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTMultiChannel::shared_pointer NTMultiChannel::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTMultiChannel::shared_pointer NTMultiChannel::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTMultiChannel(structure));
|
||||
return shared_pointer(new NTMultiChannel(pvStructure));
|
||||
}
|
||||
|
||||
bool NTMultiChannel::is_a(StructureConstPtr const &structure)
|
||||
@@ -226,89 +227,34 @@ bool NTMultiChannel::is_a(StructureConstPtr const &structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTMultiChannel::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTMultiChannel::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure.get()) return false;
|
||||
|
||||
UnionArrayConstPtr valueField = structure->getField<UnionArray>("value");
|
||||
if (!valueField.get()) return false;
|
||||
|
||||
ScalarArrayConstPtr channelNameField = structure->getField<ScalarArray>(
|
||||
"channelName");
|
||||
if (!channelNameField.get()) return false;
|
||||
if (channelNameField->getElementType() != pvString) return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("severity");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr severityField = structure->getField<ScalarArray>("severity");
|
||||
if (!severityField.get() || severityField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("status");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr statusField = structure->getField<ScalarArray>("status");
|
||||
if (!statusField.get() || statusField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("message");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr messageField = structure->getField<ScalarArray>("message");
|
||||
if (!messageField.get() || messageField->getElementType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("secondsPastEpoch");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr secondsPastEpochField = structure->getField<ScalarArray>("secondsPastEpoch");
|
||||
if (!secondsPastEpochField.get() || secondsPastEpochField->getElementType() != pvLong)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("nanoseconds");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr nanosecondsField = structure->getField<ScalarArray>("nanoseconds");
|
||||
if (!nanosecondsField.get() || nanosecondsField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("userTag");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr userTagField = structure->getField<ScalarArray>("userTag");
|
||||
if (!userTagField.get() || userTagField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<UnionArray>("value")
|
||||
.has<ScalarArray>("channelName")
|
||||
.maybeHas<ScalarArray>("severity")
|
||||
.maybeHas<ScalarArray>("status")
|
||||
.maybeHas<ScalarArray>("message")
|
||||
.maybeHas<ScalarArray>("secondsPastEpoch")
|
||||
.maybeHas<ScalarArray>("nanoseconds")
|
||||
.maybeHas<ScalarArray>("userTag")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
|
||||
bool NTMultiChannel::isCompatible(PVStructurePtr const &pvStructure)
|
||||
{
|
||||
if(!pvStructure.get()) return false;
|
||||
@@ -323,7 +269,7 @@ bool NTMultiChannel::isValid()
|
||||
if (getChannelName()->getLength() != valueLength) return false;
|
||||
|
||||
PVScalarArrayPtr arrayFields[] = {
|
||||
getSeverity(), getStatus(), getMessage(),
|
||||
getSeverity(), getStatus(), getMessage(),
|
||||
getSecondsPastEpoch(), getNanoseconds(), getUserTag()
|
||||
};
|
||||
size_t N = sizeof(arrayFields)/sizeof(arrayFields[0]);
|
||||
@@ -335,7 +281,7 @@ bool NTMultiChannel::isValid()
|
||||
if (arrayField.get() && arrayField->getLength() != valueLength)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntnameValue.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntnameValue.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -112,10 +113,10 @@ NTNameValueBuilder::shared_pointer NTNameValueBuilder::add(string const & name,
|
||||
|
||||
const std::string NTNameValue::URI("epics:nt/NTNameValue:1.0");
|
||||
|
||||
NTNameValue::shared_pointer NTNameValue::wrap(PVStructurePtr const & structure)
|
||||
NTNameValue::shared_pointer NTNameValue::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTNameValue::shared_pointer NTNameValue::wrapUnsafe(PVStructurePtr const & structure)
|
||||
@@ -128,37 +129,26 @@ bool NTNameValue::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTNameValue::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTNameValue::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarArrayConstPtr nameField = structure->getField<ScalarArray>("name");
|
||||
if (nameField.get() == 0 || nameField->getElementType() != pvString)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (valueField.get() == 0)
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("name")
|
||||
.has<ScalarArray>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTNameValue::isCompatible(PVStructurePtr const & pvStructure)
|
||||
@@ -1,12 +1,16 @@
|
||||
/* ntndarray.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <pv/lock.h>
|
||||
#include <pv/sharedPtr.h>
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntndarray.h>
|
||||
#include <pv/ntndarrayAttribute.h>
|
||||
@@ -17,9 +21,6 @@ using namespace epics::pvData;
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
static NTFieldPtr ntField = NTField::get();
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
static FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
@@ -70,7 +71,7 @@ StructureConstPtr NTNDArrayBuilder::createStructure()
|
||||
ScalarType st = static_cast<ScalarType>(i);
|
||||
fb->addArray(std::string(ScalarTypeFunc::name(st)) + "Value", st);
|
||||
}
|
||||
valueType = fb->createUnion();
|
||||
valueType = fb->createUnion();
|
||||
}
|
||||
|
||||
if (!codecStruc)
|
||||
@@ -126,7 +127,7 @@ StructureConstPtr NTNDArrayBuilder::createStructure()
|
||||
returnedStruc = fb->createStructure();
|
||||
|
||||
if (!isExtended)
|
||||
ntndarrayStruc[index] = returnedStruc;
|
||||
ntndarrayStruc[index] = returnedStruc;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -191,104 +192,20 @@ NTNDArrayBuilder::shared_pointer NTNDArrayBuilder::add(string const & name, Fiel
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const std::string NTNDArray::URI("epics:nt/NTNDArray:1.0");
|
||||
const std::string ntAttrStr("epics:nt/NTAttribute:1.0");
|
||||
|
||||
static FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
|
||||
|
||||
class NTValueType
|
||||
NTNDArray::shared_pointer NTNDArray::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
public:
|
||||
static bool isCompatible(UnionConstPtr const &u)
|
||||
{
|
||||
if(!u.get()) return false;
|
||||
|
||||
if (u->getID() != Union::defaultId()) return false;
|
||||
if (u->isVariant()) return false;
|
||||
|
||||
for (int i = pvBoolean; i != pvString; ++i)
|
||||
{
|
||||
ScalarType scalarType = static_cast<ScalarType>(i);
|
||||
std::string name(ScalarTypeFunc::name(scalarType));
|
||||
name += "Value";
|
||||
ScalarArrayConstPtr scalarField = u->getField<ScalarArray>(name);
|
||||
if (scalarField.get() == 0 ||
|
||||
scalarField->getElementType() != scalarType)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class NTCodec
|
||||
{
|
||||
public:
|
||||
static bool isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if(!structure.get()) return false;
|
||||
|
||||
if (structure->getID() != "codec_t") return false;
|
||||
|
||||
ScalarConstPtr scalarField = structure->getField<Scalar>("name");
|
||||
if (scalarField.get() == 0 || scalarField->getScalarType() != pvString)
|
||||
return false;
|
||||
|
||||
UnionConstPtr paramField = structure->getField<Union>("parameters");
|
||||
if (paramField.get() == 0 || !paramField->isVariant())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class NTDimension
|
||||
{
|
||||
public:
|
||||
static bool isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if(!structure.get()) return false;
|
||||
|
||||
if (structure->getID() != "dimension_t") return false;
|
||||
|
||||
ScalarConstPtr scalarField = structure->getField<Scalar>("size");
|
||||
if (scalarField.get() == 0 || scalarField->getScalarType() != pvInt)
|
||||
return false;
|
||||
|
||||
scalarField = structure->getField<Scalar>("offset");
|
||||
if (scalarField.get() == 0 || scalarField->getScalarType() != pvInt)
|
||||
return false;
|
||||
|
||||
scalarField = structure->getField<Scalar>("fullSize");
|
||||
if (scalarField.get() == 0 || scalarField->getScalarType() != pvInt)
|
||||
return false;
|
||||
|
||||
scalarField = structure->getField<Scalar>("binning");
|
||||
if (scalarField.get() == 0 || scalarField->getScalarType() != pvInt)
|
||||
return false;
|
||||
|
||||
scalarField = structure->getField<Scalar>("reverse");
|
||||
if (scalarField.get() == 0 || scalarField->getScalarType() != pvBoolean)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
NTNDArray::shared_pointer NTNDArray::wrap(PVStructurePtr const & structure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTNDArray::shared_pointer NTNDArray::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTNDArray::shared_pointer NTNDArray::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTNDArray(structure));
|
||||
return shared_pointer(new NTNDArray(pvStructure));
|
||||
}
|
||||
|
||||
bool NTNDArray::is_a(StructureConstPtr const & structure)
|
||||
@@ -296,84 +213,67 @@ bool NTNDArray::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTNDArray::isCompatible(StructureConstPtr const &structure)
|
||||
bool NTNDArray::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!structure.get()) return false;
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
UnionConstPtr valueField = structure->getField<Union>("value");
|
||||
if(!NTValueType::isCompatible(valueField)) return false;
|
||||
|
||||
StructureConstPtr codecField = structure->getField<Structure>("codec");
|
||||
if(!NTCodec::isCompatible(codecField)) return false;
|
||||
|
||||
ScalarConstPtr compressedSizeField = structure->getField<Scalar>("compressedSize");
|
||||
if (compressedSizeField.get() == 0)
|
||||
return false;
|
||||
|
||||
if (compressedSizeField->getScalarType() != pvLong)
|
||||
return false;
|
||||
|
||||
|
||||
ScalarConstPtr uncompressedSizeField = structure->getField<Scalar>("uncompressedSize");
|
||||
if (uncompressedSizeField.get() == 0)
|
||||
return false;
|
||||
|
||||
if (uncompressedSizeField->getScalarType() != pvLong)
|
||||
return false;
|
||||
|
||||
StructureArrayConstPtr dimensionField = structure->getField<StructureArray>("dimension");
|
||||
if (dimensionField.get() == 0)
|
||||
return false;
|
||||
StructureConstPtr dimElementStruc = dimensionField->getStructure();
|
||||
|
||||
if(!NTDimension::isCompatible(dimElementStruc))
|
||||
return false;
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
StructureConstPtr dataTimeStampField = structure->getField<Structure>(
|
||||
"dataTimeStamp");
|
||||
if (dataTimeStampField.get() == 0 || !ntField->isTimeStamp(dataTimeStampField))
|
||||
return false;
|
||||
|
||||
|
||||
ScalarConstPtr uniqueIdField = structure->getField<Scalar>("uniqueId");
|
||||
if (uniqueIdField.get() == 0)
|
||||
return false;
|
||||
|
||||
if (uniqueIdField->getScalarType() != pvInt)
|
||||
return false;
|
||||
|
||||
|
||||
StructureArrayConstPtr attributeField = structure->getField<StructureArray>( "attribute");
|
||||
|
||||
StructureConstPtr attributeElementStruc = attributeField->getStructure();
|
||||
|
||||
if (!NTNDArrayAttribute::isCompatible(attributeElementStruc))
|
||||
return false;
|
||||
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
namespace {
|
||||
Result& isValue(Result& result)
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
result.is<Union>(Union::defaultId());
|
||||
|
||||
for (int i = pvBoolean; i < pvString; ++i) {
|
||||
ScalarType type = static_cast<ScalarType>(i);
|
||||
string name(ScalarTypeFunc::name(type));
|
||||
result.has<ScalarArray>(name + "Value");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
Result& isCodec(Result& result)
|
||||
{
|
||||
return result
|
||||
.is<Structure>("codec_t")
|
||||
.has<Scalar>("name")
|
||||
.has<Union>("parameters");
|
||||
}
|
||||
|
||||
Result& isDimension(Result& result)
|
||||
{
|
||||
return result
|
||||
.is<StructureArray>("dimension_t[]")
|
||||
.has<Scalar>("size")
|
||||
.has<Scalar>("offset")
|
||||
.has<Scalar>("fullSize")
|
||||
.has<Scalar>("binning")
|
||||
.has<Scalar>("reverse");
|
||||
}
|
||||
}
|
||||
|
||||
bool NTNDArray::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
field = structure->getField("display");
|
||||
if (field.get() && !ntField->isDisplay(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<&isValue>("value")
|
||||
.has<&isCodec>("codec")
|
||||
.has<Scalar>("compressedSize")
|
||||
.has<Scalar>("uncompressedSize")
|
||||
.has<&isDimension>("dimension")
|
||||
.has<Scalar>("uniqueId")
|
||||
.has<&NTField::isTimeStamp, Structure>("dataTimeStamp")
|
||||
.has<&NTNDArrayAttribute::isAttribute, StructureArray>("attribute")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.maybeHas<&NTField::isDisplay, Structure>("display")
|
||||
.valid();
|
||||
}
|
||||
|
||||
|
||||
@@ -384,7 +284,6 @@ bool NTNDArray::isCompatible(PVStructurePtr const & pvStructure)
|
||||
return isCompatible(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
|
||||
bool NTNDArray::isValid()
|
||||
{
|
||||
int64 valueSize = getValueSize();
|
||||
@@ -428,10 +327,8 @@ int64 NTNDArray::getValueSize()
|
||||
{
|
||||
int64 size = 0;
|
||||
PVScalarArrayPtr storedValue = getValue()->get<PVScalarArray>();
|
||||
if (!storedValue.get())
|
||||
{
|
||||
if (storedValue.get())
|
||||
size = storedValue->getLength()*getValueTypeSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -506,6 +403,15 @@ bool NTNDArray::attachAlarm(PVAlarm &pvAlarm) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NTNDArray::attachDisplay(PVDisplay &pvDisplay) const
|
||||
{
|
||||
PVStructurePtr dp = getDisplay();
|
||||
if (dp)
|
||||
return pvDisplay.attach(dp);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
PVStructurePtr NTNDArray::getPVStructure() const
|
||||
{
|
||||
return pvNTNDArray;
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntndarrayAttribute.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntndarrayAttribute.h>
|
||||
#include <pv/ntattribute.h>
|
||||
@@ -94,6 +95,7 @@ NTNDArrayAttributeBuilder::NTNDArrayAttributeBuilder()
|
||||
|
||||
void NTNDArrayAttributeBuilder::reset()
|
||||
{
|
||||
tags = false;
|
||||
descriptor = false;
|
||||
alarm = false;
|
||||
timeStamp = false;
|
||||
@@ -111,15 +113,15 @@ NTNDArrayAttributeBuilder::shared_pointer NTNDArrayAttributeBuilder::add(string
|
||||
|
||||
const std::string NTNDArrayAttribute::URI("epics:nt/NTAttribute:1.0");
|
||||
|
||||
NTNDArrayAttribute::shared_pointer NTNDArrayAttribute::wrap(PVStructurePtr const & structure)
|
||||
NTNDArrayAttribute::shared_pointer NTNDArrayAttribute::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTNDArrayAttribute::shared_pointer NTNDArrayAttribute::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTNDArrayAttribute::shared_pointer NTNDArrayAttribute::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTNDArrayAttribute(structure));
|
||||
return shared_pointer(new NTNDArrayAttribute(pvStructure));
|
||||
}
|
||||
|
||||
bool NTNDArrayAttribute::is_a(StructureConstPtr const & structure)
|
||||
@@ -127,24 +129,30 @@ bool NTNDArrayAttribute::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTNDArrayAttribute::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
Result& NTNDArrayAttribute::isAttribute(Result& result) {
|
||||
return result
|
||||
.has<Scalar>("name")
|
||||
.has<Union>("value")
|
||||
.maybeHas<ScalarArray>("tags")
|
||||
.has<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.has<Scalar>("sourceType")
|
||||
.has<Scalar>("source");
|
||||
}
|
||||
|
||||
bool NTNDArrayAttribute::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!NTAttribute::isCompatible(structure)) return false;
|
||||
|
||||
// descriptor required field for attibute in an ndarray
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (descriptorField.get() == 0 || descriptorField->getScalarType() != pvString)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
ScalarConstPtr sourcedTypeField = structure->getField<Scalar>("sourceType");
|
||||
if (sourcedTypeField.get() == 0 || sourcedTypeField->getScalarType() != pvInt)
|
||||
return false;
|
||||
|
||||
ScalarConstPtr sourcedField = structure->getField<Scalar>("source");
|
||||
if (sourcedField.get() == 0 || sourcedField->getScalarType() != pvString)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
Result result(structure);
|
||||
return isAttribute(result.is<Structure>()).valid();
|
||||
}
|
||||
|
||||
bool NTNDArrayAttribute::isCompatible(PVStructurePtr const & pvStructure)
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntscalar.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntscalar.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -130,15 +131,15 @@ NTScalarBuilder::shared_pointer NTScalarBuilder::add(string const & name, FieldC
|
||||
|
||||
const std::string NTScalar::URI("epics:nt/NTScalar:1.0");
|
||||
|
||||
NTScalar::shared_pointer NTScalar::wrap(PVStructurePtr const & structure)
|
||||
NTScalar::shared_pointer NTScalar::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTScalar::shared_pointer NTScalar::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTScalar::shared_pointer NTScalar::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTScalar(structure));
|
||||
return shared_pointer(new NTScalar(pvStructure));
|
||||
}
|
||||
|
||||
bool NTScalar::is_a(StructureConstPtr const & structure)
|
||||
@@ -146,43 +147,28 @@ bool NTScalar::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTScalar::isCompatible(StructureConstPtr const &structure)
|
||||
bool NTScalar::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarConstPtr valueField = structure->getField<Scalar>("value");
|
||||
if (valueField.get() == 0)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("display");
|
||||
if (field.get() && !ntField->isDisplay(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("control");
|
||||
if (field.get() && !ntField->isControl(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTScalar::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
Result result(structure);
|
||||
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<Scalar>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.maybeHas<&NTField::isDisplay, Structure>("display")
|
||||
.maybeHas<&NTField::isControl, Structure>("control")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTScalar::isCompatible(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntscalarArray.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntscalarArray.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -18,6 +19,16 @@ static NTFieldPtr ntField = NTField::get();
|
||||
|
||||
namespace detail {
|
||||
|
||||
NTScalarArrayBuilder::shared_pointer NTScalarArrayBuilder::value(
|
||||
epics::pvData::ScalarType elementType
|
||||
)
|
||||
{
|
||||
valueType = elementType;
|
||||
valueTypeSet = true;
|
||||
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
NTScalarArrayBuilder::shared_pointer NTScalarArrayBuilder::arrayValue(
|
||||
epics::pvData::ScalarType elementType
|
||||
)
|
||||
@@ -129,15 +140,15 @@ NTScalarArrayBuilder::shared_pointer NTScalarArrayBuilder::add(string const & na
|
||||
|
||||
const std::string NTScalarArray::URI("epics:nt/NTScalarArray:1.0");
|
||||
|
||||
NTScalarArray::shared_pointer NTScalarArray::wrap(PVStructurePtr const & structure)
|
||||
NTScalarArray::shared_pointer NTScalarArray::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTScalarArray::shared_pointer NTScalarArray::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTScalarArray::shared_pointer NTScalarArray::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTScalarArray(structure));
|
||||
return shared_pointer(new NTScalarArray(pvStructure));
|
||||
}
|
||||
|
||||
bool NTScalarArray::is_a(StructureConstPtr const & structure)
|
||||
@@ -145,41 +156,27 @@ bool NTScalarArray::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTScalarArray::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTScalarArray::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (valueField.get() == 0)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("display");
|
||||
if (field.get() && !ntField->isDisplay(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("control");
|
||||
if (field.get() && !ntField->isControl(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.maybeHas<&NTField::isDisplay, Structure>("display")
|
||||
.maybeHas<&NTField::isControl, Structure>("control")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTScalarArray::isCompatible(PVStructurePtr const & pvStructure)
|
||||
@@ -1,11 +1,10 @@
|
||||
/* ntscalarMultiChannel.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntscalarMultiChannel.h>
|
||||
@@ -14,7 +13,7 @@
|
||||
using namespace std;
|
||||
using namespace epics::pvData;
|
||||
|
||||
namespace epics { namespace nt {
|
||||
namespace epics { namespace nt {
|
||||
|
||||
|
||||
static FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
@@ -207,15 +206,15 @@ NTScalarMultiChannelBuilder::shared_pointer NTScalarMultiChannelBuilder::add(str
|
||||
|
||||
const std::string NTScalarMultiChannel::URI("epics:nt/NTScalarMultiChannel:1.0");
|
||||
|
||||
NTScalarMultiChannel::shared_pointer NTScalarMultiChannel::wrap(PVStructurePtr const & structure)
|
||||
NTScalarMultiChannel::shared_pointer NTScalarMultiChannel::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTScalarMultiChannel::shared_pointer NTScalarMultiChannel::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTScalarMultiChannel::shared_pointer NTScalarMultiChannel::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTScalarMultiChannel(structure));
|
||||
return shared_pointer(new NTScalarMultiChannel(pvStructure));
|
||||
}
|
||||
|
||||
bool NTScalarMultiChannel::is_a(StructureConstPtr const &structure)
|
||||
@@ -223,89 +222,34 @@ bool NTScalarMultiChannel::is_a(StructureConstPtr const &structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTScalarMultiChannel::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTScalarMultiChannel::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure.get()) return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (!valueField.get()) return false;
|
||||
|
||||
ScalarArrayConstPtr channelNameField = structure->getField<ScalarArray>(
|
||||
"channelName");
|
||||
if (!channelNameField.get()) return false;
|
||||
if (channelNameField->getElementType() != pvString) return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("severity");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr severityField = structure->getField<ScalarArray>("severity");
|
||||
if (!severityField.get() || severityField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("status");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr statusField = structure->getField<ScalarArray>("status");
|
||||
if (!statusField.get() || statusField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("message");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr messageField = structure->getField<ScalarArray>("message");
|
||||
if (!messageField.get() || messageField->getElementType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("secondsPastEpoch");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr secondsPastEpochField = structure->getField<ScalarArray>("secondsPastEpoch");
|
||||
if (!secondsPastEpochField.get() || secondsPastEpochField->getElementType() != pvLong)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("nanoseconds");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr nanosecondsField = structure->getField<ScalarArray>("nanoseconds");
|
||||
if (!nanosecondsField.get() || nanosecondsField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("userTag");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr userTagField = structure->getField<ScalarArray>("userTag");
|
||||
if (!userTagField.get() || userTagField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("value")
|
||||
.has<ScalarArray>("channelName")
|
||||
.maybeHas<ScalarArray>("severity")
|
||||
.maybeHas<ScalarArray>("status")
|
||||
.maybeHas<ScalarArray>("message")
|
||||
.maybeHas<ScalarArray>("secondsPastEpoch")
|
||||
.maybeHas<ScalarArray>("nanoseconds")
|
||||
.maybeHas<ScalarArray>("userTag")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
|
||||
bool NTScalarMultiChannel::isCompatible(PVStructurePtr const &pvStructure)
|
||||
{
|
||||
if(!pvStructure.get()) return false;
|
||||
@@ -319,7 +263,7 @@ bool NTScalarMultiChannel::isValid()
|
||||
if (getChannelName()->getLength() != valueLength) return false;
|
||||
|
||||
PVScalarArrayPtr arrayFields[] = {
|
||||
getSeverity(), getStatus(), getMessage(),
|
||||
getSeverity(), getStatus(), getMessage(),
|
||||
getSecondsPastEpoch(), getNanoseconds(), getUserTag()
|
||||
};
|
||||
size_t N = sizeof(arrayFields)/sizeof(arrayFields[0]);
|
||||
@@ -331,7 +275,7 @@ bool NTScalarMultiChannel::isValid()
|
||||
if (arrayField.get() && arrayField->getLength() != valueLength)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
NTScalarMultiChannelBuilderPtr NTScalarMultiChannel::createBuilder()
|
||||
@@ -1,11 +1,11 @@
|
||||
/* nttable.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/nttable.h>
|
||||
@@ -127,15 +127,15 @@ NTTableBuilder::shared_pointer NTTableBuilder::add(string const & name, FieldCon
|
||||
|
||||
const std::string NTTable::URI("epics:nt/NTTable:1.0");
|
||||
|
||||
NTTable::shared_pointer NTTable::wrap(PVStructurePtr const & structure)
|
||||
NTTable::shared_pointer NTTable::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTTable::shared_pointer NTTable::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTTable::shared_pointer NTTable::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTTable(structure));
|
||||
return shared_pointer(new NTTable(pvStructure));
|
||||
}
|
||||
|
||||
bool NTTable::is_a(StructureConstPtr const & structure)
|
||||
@@ -143,44 +143,39 @@ bool NTTable::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTTable::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTTable::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure.get()) return false;
|
||||
|
||||
StructureConstPtr valueField = structure->getField<Structure>("value");
|
||||
if (!valueField.get())
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtrArray const & fields = valueField->getFields();
|
||||
for (FieldConstPtrArray::const_iterator it = fields.begin();
|
||||
it != fields.end(); ++it)
|
||||
{
|
||||
if ((*it)->getType() != scalarArray) return false;
|
||||
Result result(structure);
|
||||
|
||||
result
|
||||
.is<Structure>()
|
||||
.has<Structure>("value")
|
||||
.has<ScalarArray>("labels")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp");
|
||||
|
||||
StructureConstPtr value(structure->getField<Structure>("value"));
|
||||
if (value) {
|
||||
Result r(value);
|
||||
StringArray const & names(value->getFieldNames());
|
||||
StringArray::const_iterator it;
|
||||
|
||||
for (it = names.begin(); it != names.end(); ++it)
|
||||
r.has<ScalarArray>(*it);
|
||||
|
||||
result |= r;
|
||||
}
|
||||
|
||||
ScalarArrayConstPtr labelsField = structure->getField<ScalarArray>("labels");
|
||||
if (!labelsField.get() || labelsField->getElementType() != pvString)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result.valid();
|
||||
}
|
||||
|
||||
bool NTTable::isCompatible(PVStructurePtr const & pvStructure)
|
||||
@@ -193,7 +188,7 @@ bool NTTable::isCompatible(PVStructurePtr const & pvStructure)
|
||||
bool NTTable::isValid()
|
||||
{
|
||||
PVFieldPtrArray const & columns = pvValue->getPVFields();
|
||||
|
||||
|
||||
if (getLabels()->getLength() != columns.size()) return false;
|
||||
bool first = true;
|
||||
int length = 0;
|
||||
@@ -266,7 +261,7 @@ PVStringArrayPtr NTTable::getLabels() const
|
||||
|
||||
StringArray const & NTTable::getColumnNames() const
|
||||
{
|
||||
return pvNTTable->getStructure()->getFieldNames();
|
||||
return pvValue->getStructure()->getFieldNames();
|
||||
}
|
||||
|
||||
PVFieldPtr NTTable::getColumn(std::string const & columnName) const
|
||||
@@ -1,10 +1,11 @@
|
||||
/* ntunion.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntunion.h>
|
||||
#include <pv/ntutils.h>
|
||||
@@ -19,6 +20,12 @@ static NTFieldPtr ntField = NTField::get();
|
||||
namespace detail {
|
||||
|
||||
|
||||
NTUnionBuilder::shared_pointer NTUnionBuilder::value(UnionConstPtr unionType)
|
||||
{
|
||||
valueType = unionType;
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
StructureConstPtr NTUnionBuilder::createStructure()
|
||||
{
|
||||
FieldBuilderPtr builder =
|
||||
@@ -100,15 +107,15 @@ NTUnionBuilder::shared_pointer NTUnionBuilder::add(string const & name, FieldCon
|
||||
|
||||
const std::string NTUnion::URI("epics:nt/NTUnion:1.0");
|
||||
|
||||
NTUnion::shared_pointer NTUnion::wrap(PVStructurePtr const & structure)
|
||||
NTUnion::shared_pointer NTUnion::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTUnion::shared_pointer NTUnion::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTUnion::shared_pointer NTUnion::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTUnion(structure));
|
||||
return shared_pointer(new NTUnion(pvStructure));
|
||||
}
|
||||
|
||||
bool NTUnion::is_a(StructureConstPtr const & structure)
|
||||
@@ -116,33 +123,25 @@ bool NTUnion::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTUnion::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTUnion::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
UnionConstPtr valueField = structure->getField<Union>("value");
|
||||
if (valueField.get() == 0)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<Union>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTUnion::isCompatible(PVStructurePtr const & pvStructure)
|
||||
@@ -1,11 +1,11 @@
|
||||
/* nturi.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/nturi.h>
|
||||
@@ -127,15 +127,15 @@ NTURIBuilder::shared_pointer NTURIBuilder::add(string const & name, FieldConstPt
|
||||
|
||||
const std::string NTURI::URI("epics:nt/NTURI:1.0");
|
||||
|
||||
NTURI::shared_pointer NTURI::wrap(PVStructurePtr const & structure)
|
||||
NTURI::shared_pointer NTURI::wrap(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!isCompatible(structure)) return shared_pointer();
|
||||
return wrapUnsafe(structure);
|
||||
if(!isCompatible(pvStructure)) return shared_pointer();
|
||||
return wrapUnsafe(pvStructure);
|
||||
}
|
||||
|
||||
NTURI::shared_pointer NTURI::wrapUnsafe(PVStructurePtr const & structure)
|
||||
NTURI::shared_pointer NTURI::wrapUnsafe(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return shared_pointer(new NTURI(structure));
|
||||
return shared_pointer(new NTURI(pvStructure));
|
||||
}
|
||||
|
||||
bool NTURI::is_a(StructureConstPtr const & structure)
|
||||
@@ -143,47 +143,38 @@ bool NTURI::is_a(StructureConstPtr const & structure)
|
||||
return NTUtils::is_a(structure->getID(), URI);
|
||||
}
|
||||
|
||||
bool NTURI::is_a(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
return is_a(pvStructure->getStructure());
|
||||
}
|
||||
|
||||
bool NTURI::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure.get()) return false;
|
||||
|
||||
ScalarConstPtr schemeField = structure->getField<Scalar>("scheme");
|
||||
if (schemeField.get() == 0 || schemeField->getScalarType() != pvString)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
ScalarConstPtr pathField = structure->getField<Scalar>("path");
|
||||
if (pathField.get() == 0 || pathField->getScalarType() != pvString)
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
FieldConstPtr field = structure->getField("authority");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr authorityField = structure->getField<Scalar>("authority");
|
||||
if (!authorityField.get() || authorityField->getScalarType() != pvString)
|
||||
return false;
|
||||
result
|
||||
.is<Structure>()
|
||||
.has<Scalar>("scheme")
|
||||
.has<Scalar>("path")
|
||||
.maybeHas<Scalar>("authority")
|
||||
.maybeHas<Structure>("query");
|
||||
|
||||
StructureConstPtr query(structure->getField<Structure>("query"));
|
||||
if (query) {
|
||||
Result r(query);
|
||||
StringArray const & names(query->getFieldNames());
|
||||
StringArray::const_iterator it;
|
||||
|
||||
for (it = names.begin(); it != names.end(); ++it)
|
||||
r.has<ScalarArray>(*it);
|
||||
|
||||
result |= r;
|
||||
}
|
||||
|
||||
field = structure->getField("query");
|
||||
if (field.get())
|
||||
{
|
||||
StructureConstPtr queryField = structure->getField<Structure>("query");
|
||||
if (!queryField.get())
|
||||
return false;
|
||||
|
||||
FieldConstPtrArray const & fields = queryField->getFields();
|
||||
for (FieldConstPtrArray::const_iterator it = fields.begin();
|
||||
it != fields.end(); ++it)
|
||||
{
|
||||
if ((*it)->getType() != scalar) return false;
|
||||
ScalarType scalarType = std::tr1::dynamic_pointer_cast<const Scalar>(
|
||||
(*it))->getScalarType();
|
||||
if (scalarType != pvString &&
|
||||
scalarType != pvInt &&
|
||||
scalarType != pvDouble) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return result.valid();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntutils.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
@@ -1,8 +1,7 @@
|
||||
/* nt.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NT_H
|
||||
#define NT_H
|
||||
@@ -32,7 +31,7 @@
|
||||
|
||||
/** @page Overview Documentation
|
||||
*
|
||||
* <a href = "ntCPP.html">ntCPP.html</a>
|
||||
* <a href = "../ntCPP.html">Normative Types (C++) Reference</a>
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntaggregate.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTAGGREGATE_H
|
||||
#define NTAGGREGATE_H
|
||||
@@ -42,89 +41,90 @@ namespace detail {
|
||||
POINTER_DEFINITIONS(NTAggregateBuilder);
|
||||
|
||||
/**
|
||||
* Add dispersion field to the NTAggregate.
|
||||
* Adds dispersion field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDispersion();
|
||||
|
||||
/**
|
||||
* Add first field to the NTAggregate.
|
||||
* Adds first field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addFirst();
|
||||
|
||||
/**
|
||||
* Add firstTimeStamp field to the NTAggregate.
|
||||
* Adds firstTimeStamp field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addFirstTimeStamp();
|
||||
|
||||
/**
|
||||
* Add last field to the NTAggregate.
|
||||
* Adds last field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addLast();
|
||||
|
||||
/**
|
||||
* Add lastTimeStamp field to the NTAggregate.
|
||||
* Adds lastTimeStamp field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addLastTimeStamp();
|
||||
|
||||
/**
|
||||
* Add max field to the NTAggregate.
|
||||
* Adds max field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addMax();
|
||||
|
||||
/**
|
||||
* Add min field to the NTAggregate.
|
||||
* Adds min field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addMin();
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTAggregate.
|
||||
* Adds descriptor field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTAggregate.
|
||||
* Adds alarm field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTAggregate.
|
||||
* Adds timeStamp field to the NTAggregate.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTAggregate.
|
||||
* Creates a <b>Structure</b> that represents NTAggregate.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTAggregate.
|
||||
* Creates a <b>PVStructure</b> that represents NTAggregate.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTAggregate</b> instance.
|
||||
* Creates a <b>NTAggregate</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTAggregate</b>.
|
||||
*/
|
||||
NTAggregatePtr create();
|
||||
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTAggregateBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
@@ -171,65 +171,92 @@ public:
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTAggregate.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTAggregate.
|
||||
* @return NTAggregate instance on success, nullptr otherwise.
|
||||
* Creates an NTAggregate wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTAggregate
|
||||
* and if so returns an NTAggregate which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return the NTAggregate instance on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTAggregate without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTAggregate.
|
||||
* @return NTAggregate instance.
|
||||
* Creates an NTAggregate wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTAggregate or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return the NTAggregate instance
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTAggregate.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTAggregate.
|
||||
* Returns whether the specified Structure reports to be a compatible NTAggregate.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTAggregate through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTAggregate
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTAggregate.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTAggregate.
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTAggregate.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTAggregate through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test.
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTAggregate.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTAggregate.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTAggregate.
|
||||
* Returns whether the specified Structure is compatible with NTAggregate.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTAggregate through introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTAggregate
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTAggregate.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTAggregate.
|
||||
* Returns whether the specified PVStructure is compatible with NTAggregate.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTAggregate through introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTAggregate
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTAggregate.
|
||||
* Returns whether the wrapped PVStructure is valid with respect to this
|
||||
* version of NTAggregate.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value data as
|
||||
* well as the introspection data.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTAggregate
|
||||
* @return (false,true) if (is not, is) a valid NTAggregate.
|
||||
* @return (false,true) if wrapped PVStructure a valid NTAggregate
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTAggregate builder instance.
|
||||
* Creates an NTAggregate builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTAggregateBuilderPtr createBuilder();
|
||||
@@ -240,96 +267,96 @@ public:
|
||||
~NTAggregate() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* @return The PVDouble for the value.
|
||||
* Returns the value field.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVDoublePtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the N field.
|
||||
* @return The PVLong for the N field.
|
||||
* Returns the N field.
|
||||
* @return the N field.
|
||||
*/
|
||||
epics::pvData::PVLongPtr getN() const;
|
||||
|
||||
/**
|
||||
* Get the dispersion field.
|
||||
* @return The PVDouble for the dispersion which may be null
|
||||
* Returns the dispersion field.
|
||||
* @return the dispersion or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVDoublePtr getDispersion() const;
|
||||
|
||||
/**
|
||||
* Get the first field.
|
||||
* @return The PVDouble for the first field which may be null
|
||||
* Returns the first field.
|
||||
* @return the first field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVDoublePtr getFirst() const;
|
||||
|
||||
/**
|
||||
* Get the firstTimeStamp field.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the firstTimeStamp field.
|
||||
* @return the firstTimeStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getFirstTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the last field.
|
||||
* @return The PVDouble for the last field which may be null
|
||||
* Returns the last field.
|
||||
* @return the last field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVDoublePtr getLast() const;
|
||||
|
||||
/**
|
||||
* Get the lastTimeStamp field.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the lastTimeStamp field.
|
||||
* @return the lastTimeStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getLastTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the max field.
|
||||
* @return The PVDouble for the max field which may be null
|
||||
* Returns the max field.
|
||||
* @return the max field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVDoublePtr getMax() const;
|
||||
|
||||
/**
|
||||
* Get the min field.
|
||||
* @return The PVDouble for the max field which may be null
|
||||
* Returns the min field.
|
||||
* @return the min field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVDoublePtr getMin() const;
|
||||
|
||||
294
src/pv/ntattribute.h
Normal file
294
src/pv/ntattribute.h
Normal file
@@ -0,0 +1,294 @@
|
||||
/* ntattribute.h */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTATTRIBUTE_H
|
||||
#define NTATTRIBUTE_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntattributeEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef ntattributeEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntattributeEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTAttribute;
|
||||
typedef std::tr1::shared_ptr<NTAttribute> NTAttributePtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTAttribute.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTAttributeBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTAttributeBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTAttributeBuilder);
|
||||
|
||||
/**
|
||||
* Adds tags field to the NTAttribute.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTags();
|
||||
|
||||
/**
|
||||
* Adds descriptor field to the NTAttribute.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Adds alarm field to the NTAttribute.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Adds timeStamp field to the NTAttribute.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Creates a <b>Structure</b> that represents NTAttribute.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>PVStructure</b> that represents NTAttribute.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>NTAttribute</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTAttribute</b>.
|
||||
*/
|
||||
NTAttributePtr create();
|
||||
|
||||
/**
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
protected://private:
|
||||
NTAttributeBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool tags;
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTAttribute;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTAttributeBuilder> NTAttributeBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTAttribute
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTAttribute
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTAttribute);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Creates an NTAttribute wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTAttribute
|
||||
* and if so returns an NTAttribute which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTAttribute instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Creates an NTAttribute wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTAttribute or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTAttribute instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure reports to be a compatible NTAttribute.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTAttribute through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTAttribute
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTAttribute.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTAttribute through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTAttribute
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure is compatible with NTAttribute.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTAttribute through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTAttribute
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure is compatible with NTAttribute.
|
||||
* <p>
|
||||
* Checks if the specified tructure is compatible with this version
|
||||
* of NTAttribute through the introspection interface.
|
||||
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTAttribute
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the wrapped PVStructure is valid with respect to this
|
||||
* version of NTAttribute.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTAttribute
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Creates an NTAttribute builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTAttributeBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTAttribute() {}
|
||||
|
||||
/**
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Returns the name field.
|
||||
* @return the name field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getName() const;
|
||||
|
||||
/**
|
||||
* Returns the value field.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVUnionPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Returns the tags field.
|
||||
* @return the tags field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getTags() const;
|
||||
|
||||
private:
|
||||
NTAttribute(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTAttribute;
|
||||
epics::pvData::PVUnionPtr pvValue;
|
||||
|
||||
friend class detail::NTAttributeBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTATTRIBUTE_H */
|
||||
288
src/pv/ntcontinuum.h
Normal file
288
src/pv/ntcontinuum.h
Normal file
@@ -0,0 +1,288 @@
|
||||
/* ntcontinuum.h */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTCONTINUUM_H
|
||||
#define NTCONTINUUM_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntcontinuumEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef ntcontinuumEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntcontinuumEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTContinuum;
|
||||
typedef std::tr1::shared_ptr<NTContinuum> NTContinuumPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTContinuum.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTContinuumBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTContinuumBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTContinuumBuilder);
|
||||
|
||||
/**
|
||||
* Adds descriptor field to the NTContinuum.
|
||||
* @return this instance of <b>NTContinuumBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Adds alarm field to the NTContinuum.
|
||||
* @return this instance of <b>NTContinuumBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Adds timeStamp field to the NTContinuum.
|
||||
* @return this instance of <b>NTContinuumBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Creates a <b>Structure</b> that represents NTContinuum.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>PVStructure</b> that represents NTContinuum.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>NTContinuum</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTContinuum</b>.
|
||||
*/
|
||||
NTContinuumPtr create();
|
||||
|
||||
/**
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTContinuumBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTContinuumBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTContinuum;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTContinuumBuilder> NTContinuumBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTContinuum
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTContinuum
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTContinuum);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Creates an NTContinuum wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied structure is compatible with NTContinuum
|
||||
* and if so returns an NTContinuum which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTContinuum instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Creates an NTContinuum wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTContinuum or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTContinuum instance wrapping pvStructure.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure reports to be a compatible NTContinuum.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTContinuum through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTContinuum
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTContinuum.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTContinuum through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type
|
||||
*
|
||||
* @param pvStructure The PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTContinuum
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure is compatible with NTContinuum.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTContinuum through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTContinuum
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure is compatible with NTContinuum.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTContinuum through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTContinuum
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the wrapped structure is valid with respect to this
|
||||
* version of NTContinuum.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTContinuum
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Creates an NTContinuum builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTContinuumBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTContinuum() {}
|
||||
|
||||
/**
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Returns the base field.
|
||||
* @return the base field.
|
||||
*/
|
||||
epics::pvData::PVDoubleArrayPtr getBase() const;
|
||||
|
||||
/**
|
||||
* Returns the value field.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVDoubleArrayPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Returns the units field.
|
||||
* @return the units field.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getUnits() const;
|
||||
|
||||
private:
|
||||
NTContinuum(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTContinuum;
|
||||
epics::pvData::PVDoubleArrayPtr pvValue;
|
||||
|
||||
friend class detail::NTContinuumBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTCONTINUUM_H */
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntenum.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTENUM_H
|
||||
#define NTENUM_H
|
||||
@@ -42,47 +41,48 @@ namespace detail {
|
||||
POINTER_DEFINITIONS(NTEnumBuilder);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTEnum.
|
||||
* Adds descriptor field to the NTEnum.
|
||||
* @return this instance of <b>NTEnumBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTEnum.
|
||||
* Adds alarm field to the NTEnum.
|
||||
* @return this instance of <b>NTEnumBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTEnum.
|
||||
* Adds timeStamp field to the NTEnum.
|
||||
* @return this instance of <b>NTEnumBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTEnum.
|
||||
* Creates a <b>Structure</b> that represents NTEnum.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTEnum.
|
||||
* Creates a <b>PVStructure</b> that represents NTEnum.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTEnum</b> instance.
|
||||
* Creates a <b>NTEnum</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTEnum</b>.
|
||||
*/
|
||||
NTEnumPtr create();
|
||||
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTEnumBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
@@ -122,65 +122,90 @@ public:
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTEnum.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTEnum.
|
||||
* @return NTEnum instance on success, nullptr otherwise.
|
||||
* Creates an NTEnum wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTEnum or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTEnum instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTEnum without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTEnum.
|
||||
* @return NTEnum instance.
|
||||
* Creates an NTEnum wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTEnum or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTEnum instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTEnum.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTEnum.
|
||||
* Returns whether the specified Structure reports to be a compatible NTEnum.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTEnum through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test.
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTEnum.
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTEnum.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTEnum.
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTEnum.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTEnum through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTEnum
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTEnum.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTEnum.
|
||||
* Returns whether the specified Structure is compatible with NTEnum.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTEnum through the introspection interface.
|
||||
*
|
||||
* @param structure The Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTEnum
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTEnum.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTEnum.
|
||||
* Returns whether the specified PVStructure is compatible with NTEnum.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTEnum through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTEnum
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTEnum.
|
||||
* Returns whether the wrapped PVStructure is valid with respect to this
|
||||
* version of NTEnum.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTEnum
|
||||
* @return (false,true) if (is not, is) a valid NTEnum.
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTEnum
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTEnum builder instance.
|
||||
* Creates an NTEnum builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTEnumBuilderPtr createBuilder();
|
||||
@@ -191,48 +216,48 @@ public:
|
||||
~NTEnum() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* @return The PVStructure for the values.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getValue() const;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntfield.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTFIELD_H
|
||||
#define NTFIELD_H
|
||||
@@ -31,6 +30,8 @@
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
struct Result;
|
||||
|
||||
class NTField;
|
||||
typedef std::tr1::shared_ptr<NTField> NTFieldPtr;
|
||||
|
||||
@@ -47,7 +48,7 @@ class epicsShareClass NTField {
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTField);
|
||||
/**
|
||||
* get the single implementation of this class.
|
||||
* Gets the single implementation of this class.
|
||||
* @return the implementation
|
||||
*/
|
||||
static NTFieldPtr get();
|
||||
@@ -55,88 +56,125 @@ public:
|
||||
* destructor
|
||||
*/
|
||||
~NTField() {}
|
||||
|
||||
/**
|
||||
* Is field an enumerated structure.
|
||||
* @param field The field to test.
|
||||
* @param field the field to test.
|
||||
* @return (false,true) if field (is not,is) an enumerated structure.
|
||||
*/
|
||||
bool isEnumerated(epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
/**
|
||||
* Is field a timeStamp structure.
|
||||
* @param field The field to test.
|
||||
* @param field the field to test.
|
||||
* @return (false,true) if field (is not,is) a timeStamp structure.
|
||||
*/
|
||||
bool isTimeStamp(epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
/**
|
||||
* Is field an alarm structure.
|
||||
* @param field The field to test.
|
||||
* @param field the field to test.
|
||||
* @return (false,true) if field (is not,is) an alarm structure.
|
||||
*/
|
||||
bool isAlarm(epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
/**
|
||||
* Is field a display structure.
|
||||
* @param field The field to test.
|
||||
* @param field the field to test.
|
||||
* @return (false,true) if field (is not,is) a display structure.
|
||||
*/
|
||||
bool isDisplay(epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
/**
|
||||
* Is field an alarmLimit structure.
|
||||
* @param field The field to test.
|
||||
* @param field the field to test.
|
||||
* @return (false,true) if field (is not,is) an alarmLimit structure.
|
||||
*/
|
||||
bool isAlarmLimit(epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
/**
|
||||
* Is field a control structure.
|
||||
* @param field The field to test.
|
||||
* @param field the field to test.
|
||||
* @return (false,true) if field (is not,is) a control structure.
|
||||
*/
|
||||
bool isControl(epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
/**
|
||||
* Create an enumerated structure.
|
||||
* Creates an enumerated structure.
|
||||
* @return an enumerated structure.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createEnumerated();
|
||||
|
||||
/**
|
||||
* Create a timeStamp structure.
|
||||
* Creates a timeStamp structure.
|
||||
* @return a timeStamp structure.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createTimeStamp();
|
||||
|
||||
/**
|
||||
* Create an alarm structure.
|
||||
* Creates an alarm structure.
|
||||
* @return an alarm structure.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createAlarm();
|
||||
|
||||
/**
|
||||
* Create a display structure.
|
||||
* Creates a display structure.
|
||||
* @return a displayalarm structure.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createDisplay();
|
||||
|
||||
/**
|
||||
* Create a control structure.
|
||||
* Creates a control structure.
|
||||
* @return a control structure.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createControl();
|
||||
|
||||
/**
|
||||
* Create an array of enumerated structures.
|
||||
* Creates an array of enumerated structures.
|
||||
* @return an array of enumerated structures.
|
||||
*/
|
||||
epics::pvData::StructureArrayConstPtr createEnumeratedArray();
|
||||
|
||||
/**
|
||||
* Create an array of timeStamp structures.
|
||||
* Creates an array of timeStamp structures.
|
||||
* @return an array of timeStamp structures.
|
||||
*/
|
||||
epics::pvData::StructureArrayConstPtr createTimeStampArray();
|
||||
|
||||
/**
|
||||
* Create an array of alarm structures.
|
||||
* Creates an array of alarm structures.
|
||||
* @return an array of alarm structures.
|
||||
*/
|
||||
epics::pvData::StructureArrayConstPtr createAlarmArray();
|
||||
|
||||
private:
|
||||
NTField();
|
||||
epics::pvData::FieldCreatePtr fieldCreate;
|
||||
epics::pvData::StandardFieldPtr standardField;
|
||||
|
||||
// These won't be public just yet
|
||||
static Result& isEnumerated(Result&);
|
||||
static Result& isTimeStamp(Result&);
|
||||
static Result& isAlarm(Result&);
|
||||
static Result& isDisplay(Result&);
|
||||
static Result& isAlarmLimit(Result&);
|
||||
static Result& isControl(Result&);
|
||||
|
||||
friend class NTAggregate;
|
||||
friend class NTAttribute;
|
||||
friend class NTContinuum;
|
||||
friend class NTEnum;
|
||||
friend class NTHistogram;
|
||||
friend class NTMatrix;
|
||||
friend class NTMultiChannel;
|
||||
friend class NTNameValue;
|
||||
friend class NTNDArray;
|
||||
friend class NTNDArrayAttribute;
|
||||
friend class NTScalar;
|
||||
friend class NTScalarArray;
|
||||
friend class NTScalarMultiChannel;
|
||||
friend class NTTable;
|
||||
friend class NTUnion;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -149,62 +187,66 @@ class epicsShareClass PVNTField {
|
||||
public:
|
||||
POINTER_DEFINITIONS(PVNTField);
|
||||
/**
|
||||
* get the single implementation of this class.
|
||||
* Returns the single implementation of this class.
|
||||
* @return the implementation
|
||||
*/
|
||||
static PVNTFieldPtr get();
|
||||
|
||||
/**
|
||||
* destructor
|
||||
*/
|
||||
~PVNTField() {}
|
||||
|
||||
/**
|
||||
* Create an enumerated PVStructure.
|
||||
* Creates an enumerated PVStructure.
|
||||
* @param choices The array of choices.
|
||||
* @return an enumerated PVStructure..
|
||||
* @return an enumerated PVStructure.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createEnumerated(
|
||||
epics::pvData::StringArray const & choices);
|
||||
|
||||
/**
|
||||
* Create a timeStamp PVStructure.
|
||||
* @return a timeStamp PVStructure..
|
||||
* Creates a timeStamp PVStructure.
|
||||
* @return a timeStamp PVStructure.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createTimeStamp();
|
||||
|
||||
/**
|
||||
* Create an alarm PVStructure.
|
||||
* @return an alarm PVStructure..
|
||||
* Creates an alarm PVStructure.
|
||||
* @return an alarm PVStructure.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createAlarm();
|
||||
|
||||
/**
|
||||
* Create a display PVStructure.
|
||||
* @return a display PVStructure..
|
||||
* Creates a display PVStructure.
|
||||
* @return a display PVStructure.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createDisplay();
|
||||
|
||||
/**
|
||||
* Create an alarmLimit PVStructure.
|
||||
* @return an alarmLimit PVStructure..
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createAlarmLimit();
|
||||
/**
|
||||
* Create a control PVStructure.
|
||||
* @return a control PVStructure..
|
||||
* Creates a control PVStructure.
|
||||
* @return a control PVStructure.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createControl();
|
||||
|
||||
/**
|
||||
* Create an enumerated PVStructureArray.
|
||||
* @return an enumerated PVStructureArray..
|
||||
* Creates an enumerated PVStructureArray.
|
||||
* @return an enumerated PVStructureArray.
|
||||
*/
|
||||
epics::pvData::PVStructureArrayPtr createEnumeratedArray();
|
||||
|
||||
/**
|
||||
* Create a timeStamp PVStructureArray.
|
||||
* @return a timeStamp PVStructureArray
|
||||
* Creates a timeStamp PVStructureArray.
|
||||
* @return a timeStamp PVStructureArray.
|
||||
*/
|
||||
epics::pvData::PVStructureArrayPtr createTimeStampArray();
|
||||
|
||||
/**
|
||||
* Create an alarm PVStructureArray.
|
||||
* @return an alarm PVStructureArray..
|
||||
* Creates an alarm PVStructureArray.
|
||||
* @return an alarm PVStructureArray.
|
||||
*/
|
||||
epics::pvData::PVStructureArrayPtr createAlarmArray();
|
||||
|
||||
private:
|
||||
PVNTField();
|
||||
epics::pvData::PVDataCreatePtr pvDataCreate;
|
||||
305
src/pv/nthistogram.h
Normal file
305
src/pv/nthistogram.h
Normal file
@@ -0,0 +1,305 @@
|
||||
/* nthistogram.h */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTHISTOGRAM_H
|
||||
#define NTHISTOGRAM_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define nthistogramEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef nthistogramEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef nthistogramEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTHistogram;
|
||||
typedef std::tr1::shared_ptr<NTHistogram> NTHistogramPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTHistogram.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTHistogramBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTHistogramBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTHistogramBuilder);
|
||||
|
||||
/**
|
||||
* Sets the scalar type of the value field array.
|
||||
* @param scalarType the scalar type of the value field array.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer value(epics::pvData::ScalarType scalarType);
|
||||
|
||||
/**
|
||||
* Adds descriptor field to the NTHistogram.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Adds alarm field to the NTHistogram.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Adds timeStamp field to the NTHistogram.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Creates a <b>Structure</b> that represents NTHistogram.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>PVStructure</b> that represents NTHistogram.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>NTHistogram</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTHistogram</b>.
|
||||
*/
|
||||
NTHistogramPtr create();
|
||||
|
||||
/**
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTHistogramBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTHistogramBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool valueTypeSet;
|
||||
epics::pvData::ScalarType valueType;
|
||||
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTHistogram;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTHistogramBuilder> NTHistogramBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTHistogram
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTHistogram
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTHistogram);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Creates an NTHistogram wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTHistogram
|
||||
* and if so returns an NTHistogram which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTHistogram instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Creates an NTHistogram wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTHistogram or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped.
|
||||
* @return NTHistogram instance wrapping pvStructure.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure reports to be a compatible NTHistogram.
|
||||
* <p>
|
||||
* Checks whether the specified Structure reports compatibility with this
|
||||
* version of NTHistogram through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test.
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTHistogram
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTHistogram.
|
||||
* <p>
|
||||
* Checks whether the specified PVStructure reports compatibility with this
|
||||
* version of NTHistogram through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTHistogram
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure is compatible with NTHistogram.
|
||||
* <p>
|
||||
* Checks whether the specified Structure is compatible with this version
|
||||
* of NTHistogram through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTHistogram
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure is compatible with NTHistogram.
|
||||
* <p>
|
||||
* Checks whether the specified PVStructure is compatible with this version
|
||||
* of NTHistogram through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTHistogram
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the wrapped structure is valid with respect to this
|
||||
* version of NTHistogram.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTHistogram
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Creates an NTHistogram builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTHistogramBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTHistogram() {}
|
||||
|
||||
/**
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Returns the ranges field.
|
||||
* @return the ranges field.
|
||||
*/
|
||||
epics::pvData::PVDoubleArrayPtr getRanges() const;
|
||||
|
||||
/**
|
||||
* Returns the value field.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVScalarArrayPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Returns the value field of a specified type (e.g. PVIntArray).
|
||||
* @tparam PVT the expected type of the value field which should be
|
||||
* be PVShortArray, PVIntArray pr PVLongArray.
|
||||
* @return the value field or null if it is not of the expected type.
|
||||
*/
|
||||
template<typename PVT>
|
||||
std::tr1::shared_ptr<PVT> getValue() const
|
||||
{
|
||||
return std::tr1::dynamic_pointer_cast<PVT>(pvValue);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
NTHistogram(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTHistogram;
|
||||
epics::pvData::PVScalarArrayPtr pvValue;
|
||||
|
||||
friend class detail::NTHistogramBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTHISTOGRAM_H */
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/* ntid.h */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTID_H
|
||||
#define NTID_H
|
||||
@@ -13,104 +13,110 @@ namespace epics {
|
||||
namespace nt {
|
||||
|
||||
/**
|
||||
* Utility class for parsing an ID following the NT type ID conventions
|
||||
* @brief Utility class for parsing a type ID that follows the NT type ID conventions
|
||||
*
|
||||
* An NT type ID will be of the from epics:nt/<type-name>:<Major>.<Minor>,
|
||||
* e.g. epics:nt/NTNDArray:1.2
|
||||
* An NT type ID will be of the from
|
||||
@code
|
||||
epics:nt/<type-name>:<Major>.<Minor>
|
||||
@endcode
|
||||
* e.g.
|
||||
@code
|
||||
epics:nt/NTNDArray:1.2
|
||||
@endcode
|
||||
* @author dgh
|
||||
*/
|
||||
class NTID
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates an NTID from the specified type ID
|
||||
* Creates an NTID from the specified type ID.
|
||||
*
|
||||
* @param id The the id to be parsed.
|
||||
* @param id the the ID to be parsed.
|
||||
* @return NTNDArray instance on success, null otherwise.
|
||||
*/
|
||||
NTID(const std::string &id);
|
||||
/**
|
||||
* Get the full name of the id, i.e. the original ID
|
||||
*
|
||||
* For example above returns "epics:nt/NTNDArray:1.2"
|
||||
* Returns the full name of the id, i.e. the original ID
|
||||
* <p>
|
||||
* For example above returns "epics:nt/NTNDArray:1.2".
|
||||
* @return the full name
|
||||
*/
|
||||
std::string getFullName();
|
||||
|
||||
/**
|
||||
* Get the fully qualified name including namespaces, but excluding version numbers
|
||||
*
|
||||
* Returns the fully qualified name including namespaces, but excluding version numbers.
|
||||
* <p>
|
||||
* For example above return "epics:nt/NTNDArray"
|
||||
* @return the fully qualified name
|
||||
*/
|
||||
std::string getQualifiedName();
|
||||
|
||||
/**
|
||||
* Get the namespace
|
||||
*
|
||||
* For example above return "epics:nt"
|
||||
* Returns the namespace
|
||||
* <p>
|
||||
* For example above return "epics:nt".
|
||||
* @return the namespace
|
||||
*/
|
||||
std::string getNamespace();
|
||||
|
||||
/**
|
||||
* Get the unqualified name, without namespace or version
|
||||
*
|
||||
* For example above return "NTNDArray"
|
||||
* Returns the unqualified name, without namespace or version.
|
||||
* <p>
|
||||
* For example above return "NTNDArray".
|
||||
* @return the unqualified name
|
||||
*/
|
||||
std::string getName();
|
||||
|
||||
/**
|
||||
* Get the unqualified name, without namespace or version
|
||||
*
|
||||
* For example above return "NTNDArray"
|
||||
* @return the unqualified name
|
||||
* Returns the version as a string.
|
||||
* <p>
|
||||
* For example above return "NTNDArray".
|
||||
* @return the the version string
|
||||
*/
|
||||
std::string getVersion();
|
||||
|
||||
/**
|
||||
* Get the Major version as a string
|
||||
*
|
||||
* For example above return "1"
|
||||
* Returns the Major version as a string.
|
||||
* <p>
|
||||
* For example above return "1".
|
||||
* @return the Major string
|
||||
*/
|
||||
std::string getMajorVersionString();
|
||||
|
||||
/**
|
||||
* Does the ID contain a major version and is it a number
|
||||
*
|
||||
* Does the ID contain a major version and is it a number.
|
||||
* <p>
|
||||
* @return true if it contains a major version number
|
||||
*/
|
||||
bool hasMajorVersion();
|
||||
|
||||
/**
|
||||
* Get the Major version as an integer
|
||||
*
|
||||
* For example above return 1
|
||||
* Returns the Major version as an integer.
|
||||
* <p>
|
||||
* For example above return 1.
|
||||
* @return the Major string
|
||||
*/
|
||||
int getMajorVersion();
|
||||
|
||||
/**
|
||||
* Get the Major version as a string
|
||||
*
|
||||
* For example above return "1"
|
||||
* Returns the Major version as a string.
|
||||
* <p>
|
||||
* For example above return "1".
|
||||
* @return the Major string
|
||||
*/
|
||||
std::string getMinorVersionString();
|
||||
|
||||
/**
|
||||
* Does the ID contain a minor version and is it a number
|
||||
*
|
||||
* Does the ID contain a minor version and is it a number.
|
||||
* <p>
|
||||
* @return true if it contains a minor version number
|
||||
*/
|
||||
bool hasMinorVersion();
|
||||
|
||||
/**
|
||||
* Get the Minor version as an integer
|
||||
*
|
||||
* For example above return 1
|
||||
* Returns the Minor version as an integer.
|
||||
* <p>
|
||||
* For example above return 1.
|
||||
* @return the Minor string
|
||||
*/
|
||||
int getMinorVersion();
|
||||
312
src/pv/ntmatrix.h
Normal file
312
src/pv/ntmatrix.h
Normal file
@@ -0,0 +1,312 @@
|
||||
/* ntmatrix.h */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTMATRIX_H
|
||||
#define NTMATRIX_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntmatrixEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/pvDisplay.h>
|
||||
|
||||
#ifdef ntmatrixEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntmatrixEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTMatrix;
|
||||
typedef std::tr1::shared_ptr<NTMatrix> NTMatrixPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTMatrix.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTMatrixBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTMatrixBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTMatrixBuilder);
|
||||
|
||||
/**
|
||||
* Adds dimension field to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDim();
|
||||
|
||||
/**
|
||||
* Adds descriptor field to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Adds alarm field to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Adds timeStamp field to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Adds display field to the NTMatrix.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDisplay();
|
||||
|
||||
/**
|
||||
* Creates a <b>Structure</b> that represents NTMatrix.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>PVStructure</b> that represents NTMatrix.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>NTMatrix</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTMatrix</b>.
|
||||
*/
|
||||
NTMatrixPtr create();
|
||||
|
||||
/**
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTMatrixBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTMatrixBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool dim;
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
bool display;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTMatrix;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTMatrixBuilder> NTMatrixBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTMatrix
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTMatrix
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTMatrix);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Creates an NTMatrix wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTMatrix
|
||||
* and if so returns an NTMatrix which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTMatrix instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Creates an NTMatrix wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTMatrix or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTMatrix instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure reports to be a compatible NTMatrix.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTMatrix through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTMatrix
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTMatrix.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTMatrix through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTMatrix
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure is compatible with NTMatrix.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTMatrix through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTMatrix
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure is compatible with NTMatrix.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTMatrix through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTMatrix
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the wrapped PVStructure is valid with respect to this
|
||||
* version of NTMatrix.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTMatrix
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Creates an NTMatrix builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTMatrixBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTMatrix() {}
|
||||
|
||||
/**
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Attaches a PVDisplay to the wrapped PVStructure.
|
||||
* Does nothing if no display.
|
||||
* @param pvDisplay the PVDisplay that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a display field), otherwise false.
|
||||
*/
|
||||
bool attachDisplay(epics::pvData::PVDisplay &pvDisplay) const;
|
||||
|
||||
/**
|
||||
* Get the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Returns the display field.
|
||||
* @return the display field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getDisplay() const;
|
||||
|
||||
/**
|
||||
* Returns the value field.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVDoubleArrayPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Returns the dim field.
|
||||
* @return the dim field or or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getDim() const;
|
||||
|
||||
private:
|
||||
NTMatrix(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTMatrix;
|
||||
epics::pvData::PVDoubleArrayPtr pvValue;
|
||||
|
||||
friend class detail::NTMatrixBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTMATRIX_H */
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntmultiChannel.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTMULTICHANNEL_H
|
||||
#define NTMULTICHANNEL_H
|
||||
@@ -54,81 +53,96 @@ namespace detail {
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer value(epics::pvData::UnionConstPtr valuePtr);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTMultiChannel.
|
||||
* Adds descriptor field to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTMultiChannel.
|
||||
* Adds alarm field to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTMultiChannel.
|
||||
* Adds timeStamp field to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Add severity array to the NTMultiChannel.
|
||||
* Adds severity array to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addSeverity();
|
||||
|
||||
/**
|
||||
* Add status array to the NTMultiChannel.
|
||||
* Adds status array to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addStatus();
|
||||
|
||||
/**
|
||||
* Add message array to the NTMultiChannel.
|
||||
* Adds message array to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addMessage();
|
||||
|
||||
/**
|
||||
* Add secondsPastEpoch array to the NTMultiChannel.
|
||||
* Adds secondsPastEpoch array to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addSecondsPastEpoch();
|
||||
|
||||
/**
|
||||
* Add nanoseconds array to the NTMultiChannel.
|
||||
* Adds nanoseconds array to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addNanoseconds();
|
||||
|
||||
/**
|
||||
* Add userTag array to the NTMultiChannel.
|
||||
* Adds userTag array to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addUserTag();
|
||||
|
||||
/**
|
||||
* Add isConnected array to the NTMultiChannel.
|
||||
* Adds isConnected array to the NTMultiChannel.
|
||||
* @return this instance of <b>NTMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addIsConnected();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTMultiChannel.
|
||||
* Creates a <b>Structure</b> that represents NTMultiChannel.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTMultiChannel.
|
||||
* This resets this instance state and allows new {@code instance to be created.}
|
||||
* Creates a <b>PVStructure</b> that represents NTMultiChannel.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTMultiChannel</b> instance.
|
||||
* This resets this instance state and allows new {@code instance to be created.}
|
||||
* Creates a <b>NTMultiChannel</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTMultiChannel</b>
|
||||
*/
|
||||
NTMultiChannelPtr create();
|
||||
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of a <b>NTMultiChannelBuilder</b>
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTMultiChannelBuilder();
|
||||
|
||||
@@ -172,64 +186,92 @@ public:
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTMultiChannel.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTMultiChannel.
|
||||
* @return NTMultiChannel instance on success, nullptr otherwise.
|
||||
* Creates an NTMultiChannel wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTMultiChannel
|
||||
* and if so returns an NTMultiChannel which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTMultiChannel instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTMultiChannel without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTMultiChannel.
|
||||
* @return NTMultiChannel instance.
|
||||
* Creates an NTMultiChannel wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTMultiChannel or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTMultiChannel instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTMultiChannel.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTMultiChannel.
|
||||
* Returns whether the specified Structure reports to be a compatible NTMultiChannel.
|
||||
* <p>
|
||||
* Checks whether the specified Structure reports compatibility with this
|
||||
* version of NTMultiChannel through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTMultiChannel
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTMultiChannel.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTMultiChannel.
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTMultiChannel.
|
||||
* <p>
|
||||
* Checks whether the specified PVStructure reports compatibility with this
|
||||
* version of NTMultiChannel through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTMultiChannel
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTMultiChannel.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTMultiChannel.
|
||||
* Returns whether the specified Structure is compatible with NTMultiChannel.
|
||||
* <p>
|
||||
* Checks whether the specified Structure is compatible with this version
|
||||
* of NTMultiChannel through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTMultiChannel
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTMultiChannel.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTMultiChannel.
|
||||
* Returns whether the specified PVStructure is compatible with NTMultiChannel.
|
||||
* <p>
|
||||
* Checks whether the specified PVStructure is compatible with this version
|
||||
* of NTMultiChannel through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTMultiChannel
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTMultiChannel.
|
||||
* Checks whether the wrapped PVStructure is valid with respect to this
|
||||
* version of NTMultiChannel.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTMultiChannel
|
||||
* @return (false,true) if (is not, is) a valid NTMultiChannel.
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTMultiChannel
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTMultiChannelBuilder instance
|
||||
* Creates an NTMultiChannelBuilder instance
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTMultiChannelBuilderPtr createBuilder();
|
||||
@@ -238,99 +280,113 @@ public:
|
||||
* Destructor
|
||||
*/
|
||||
~NTMultiChannel() {}
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance
|
||||
has a timeStamp field), otherwise false.
|
||||
*/
|
||||
/**
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach a pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const
|
||||
{return pvNTMultiChannel;}
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const
|
||||
{return pvTimeStamp;}
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const
|
||||
{return pvAlarm;}
|
||||
/**
|
||||
* Get the value of each channel.
|
||||
* @return PVUnionArrayPtr
|
||||
*/
|
||||
epics::pvData::PVUnionArrayPtr getValue() const
|
||||
{return pvValue;}
|
||||
/**
|
||||
* Get the channelName of each channel.
|
||||
* @return PVStringArrayPtr
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getChannelName() const
|
||||
{ return pvChannelName;};
|
||||
/**
|
||||
* Get the connection state of each channel.
|
||||
* @return PVBooleanArrayPtr
|
||||
*/
|
||||
epics::pvData::PVBooleanArrayPtr getIsConnected() const
|
||||
{ return pvIsConnected;};
|
||||
/**
|
||||
* Get the severity of each channel.
|
||||
* @return PVIntArrayPtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getSeverity() const
|
||||
{return pvSeverity;}
|
||||
/**
|
||||
* Get the status of each channel.
|
||||
* @return PVIntArrayPtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getStatus() const
|
||||
{return pvStatus;}
|
||||
/**
|
||||
* Get the message of each chnnel.
|
||||
* @return PVStringArrayPtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getMessage() const
|
||||
{return pvMessage;}
|
||||
/**
|
||||
* Get the secondsPastEpoch of each channel.
|
||||
* @return PVLongArrayPtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVLongArrayPtr getSecondsPastEpoch() const
|
||||
{return pvSecondsPastEpoch;}
|
||||
/**
|
||||
* Get the nanoseconds of each channel.
|
||||
* @return PVIntArrayPtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getNanoseconds() const
|
||||
{return pvNanoseconds;}
|
||||
/**
|
||||
* Get the userTag of each channel.
|
||||
* @return PVIntArrayPtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getUserTag() const
|
||||
{return pvUserTag;}
|
||||
/**
|
||||
* Get the descriptor.
|
||||
* @return PVStringPtr which may be null.
|
||||
* Return the descriptor field.
|
||||
* @return the descriptor field or null if no descriptor field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const
|
||||
{return pvDescriptor;}
|
||||
|
||||
/**
|
||||
* Returns the timeStamp field.
|
||||
* @return the timeStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const
|
||||
{return pvTimeStamp;}
|
||||
|
||||
/**
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const
|
||||
{return pvAlarm;}
|
||||
|
||||
/**
|
||||
* Returns the field with the value of each channel.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVUnionArrayPtr getValue() const
|
||||
{return pvValue;}
|
||||
|
||||
/**
|
||||
* Returns the field with the channelName of each channel.
|
||||
* @return the channelName field
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getChannelName() const
|
||||
{ return pvChannelName;};
|
||||
|
||||
/**
|
||||
* Returns the field with the connection state of each channel.
|
||||
* @return the isConnected field or null if no such field
|
||||
*/
|
||||
epics::pvData::PVBooleanArrayPtr getIsConnected() const
|
||||
{ return pvIsConnected;};
|
||||
|
||||
/**
|
||||
* Returns the field with the severity of each channel.
|
||||
* @return the severity field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getSeverity() const
|
||||
{return pvSeverity;}
|
||||
|
||||
/**
|
||||
* Returns the field with the status of each channel.
|
||||
* @return the status field or null if no such field
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getStatus() const
|
||||
{return pvStatus;}
|
||||
|
||||
/**
|
||||
* Returns the field with the message of each channel.
|
||||
* @return message field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getMessage() const
|
||||
{return pvMessage;}
|
||||
|
||||
/**
|
||||
* Returns the field with the secondsPastEpoch of each channel.
|
||||
* @return the secondsPastEpoch field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVLongArrayPtr getSecondsPastEpoch() const
|
||||
{return pvSecondsPastEpoch;}
|
||||
|
||||
/**
|
||||
* Returns the field with the nanoseconds of each channel.
|
||||
* @return nanoseconds field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getNanoseconds() const
|
||||
{return pvNanoseconds;}
|
||||
|
||||
/**
|
||||
* Returns the field with the userTag of each channel.
|
||||
* @return the userTag field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getUserTag() const
|
||||
{return pvUserTag;}
|
||||
|
||||
private:
|
||||
NTMultiChannel(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTMultiChannel;
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntnameValue.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTNAMEVALUE_H
|
||||
#define NTNAMEVALUE_H
|
||||
@@ -45,55 +44,55 @@ namespace detail {
|
||||
POINTER_DEFINITIONS(NTNameValueBuilder);
|
||||
|
||||
/**
|
||||
* Set a value array <b>Scalar</b> type.
|
||||
* @param scalarType value array scalar array.
|
||||
* Sets the value array <b>Scalar</b> type.
|
||||
* @param scalarType the value field element ScalarType
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
*/
|
||||
shared_pointer value(epics::pvData::ScalarType scalarType);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTNameValue.
|
||||
* Adds descriptor field to the NTNameValue.
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTNameValue.
|
||||
* Adds alarm field to the NTNameValue.
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTNameValue.
|
||||
* Adds timeStamp field to the NTNameValue.
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTNameValue.
|
||||
* Creates a <b>Structure</b> that represents NTNameValue.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTNameValue.
|
||||
* Creates a <b>PVStructure</b> that represents NTNameValue.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTNameValue</b> instance.
|
||||
* Creates a <b>NTNameValue</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTNameValue</b>
|
||||
*/
|
||||
NTNameValuePtr create();
|
||||
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
@@ -134,65 +133,90 @@ public:
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTNameValue.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTNameValue.
|
||||
* @return NTNameValue instance on success, nullptr otherwise.
|
||||
* Creates an NTNameValue wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTNameValue
|
||||
* and if so returns an NTNameValue which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped.
|
||||
* @return NTNameValue instance wrapping pvStructure on success, null otherwise.
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTNameValue without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTNameValue.
|
||||
* @return NTNameValue instance.
|
||||
* Creates an NTNameValue wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTNameValue or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped.
|
||||
* @return NTNameValue instance wrapping pvStructure.
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTNameValue.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTNameValue.
|
||||
* Returns whether the specified Structure reports to be a compatible NTNameValue.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTNameValue through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test.
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTNameValue.
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTNameValue.
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTNameValue.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTNameValue through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTNameValue.
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTNameValue.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTNameValue.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTNameValue.
|
||||
* Returns whether the specified Structure is compatible with NTNameValue.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTNameValue through the introspection interface.
|
||||
* @param structure the Structure to test.
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTNameValue.
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTNameValue.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTNameValue.
|
||||
* Returns whether the specified PVStructure is compatible with NTNameValue.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTNameValue through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTNameValue
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTNameValue.
|
||||
* Returns whether the wrapped PVStructure is valid with respect to this
|
||||
* version of NTNameValue.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTNameValue
|
||||
* @return (false,true) if (is not, is) a valid NTNameValue.
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTNameValue
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTNameValue builder instance.
|
||||
* Creates an NTNameValue builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTNameValueBuilderPtr createBuilder();
|
||||
@@ -203,60 +227,63 @@ public:
|
||||
~NTNameValue() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no descriptor field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no timeStamp field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no alarm field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the name array field.
|
||||
* Returns the name array field.
|
||||
* @return The PVStringArray for the name.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getName() const;
|
||||
|
||||
/**
|
||||
* Get the value array field.
|
||||
* Returns the value array field.
|
||||
* @return The PVField for the value.
|
||||
*/
|
||||
epics::pvData::PVFieldPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the value array field of a specified type (e.g. PVDoubleArray).
|
||||
* @return The <PVT> array for the value.
|
||||
* Returns the value array field of a specified expected type (e.g. PVDoubleArray).
|
||||
*
|
||||
* @tparam PVT The expected type of the value field which should be
|
||||
* be PVScalarArray or a derived class.
|
||||
* @return The PVT array for the value.
|
||||
*/
|
||||
template<typename PVT>
|
||||
std::tr1::shared_ptr<PVT> getValue() const
|
||||
353
src/pv/ntndarray.h
Normal file
353
src/pv/ntndarray.h
Normal file
@@ -0,0 +1,353 @@
|
||||
/* ntndarray.h */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTNDARRAY_H
|
||||
#define NTNDARRAY_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntndarrayEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/pvDisplay.h>
|
||||
#include <pv/pvControl.h>
|
||||
|
||||
#ifdef ntndarrayEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntndarrayEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTNDArray;
|
||||
typedef std::tr1::shared_ptr<NTNDArray> NTNDArrayPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTNDArray.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author mse
|
||||
*/
|
||||
class epicsShareClass NTNDArrayBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTNDArrayBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTNDArrayBuilder);
|
||||
|
||||
/**
|
||||
* Adds descriptor field to the NTNDArray.
|
||||
* @return this instance of <b>NTNDArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Adds alarm field to the NTNDArray.
|
||||
* @return this instance of <b>NTNDArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Adds timeStamp field to the NTNDArray.
|
||||
* @return this instance of <b>NTNDArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Adds display field to the NTNDArray.
|
||||
* @return this instance of <b>NTNDArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDisplay();
|
||||
|
||||
/**
|
||||
* Creates a <b>Structure</b> that represents NTNDArray.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>PVStructure</b> that represents NTNDArray.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>NTNDArray</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTNDArray</b>
|
||||
*/
|
||||
NTNDArrayPtr create();
|
||||
|
||||
/**
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of a <b>NTArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTNDArrayBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool descriptor;
|
||||
bool timeStamp;
|
||||
bool alarm;
|
||||
bool display;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTNDArray;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTNDArrayBuilder> NTNDArrayBuilderPtr;
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTNDArray
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTNDArray
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTNDArray);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Creates an NTScalarArray wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTScalarArray
|
||||
* and if so returns an NTScalarArray which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTScalarArray instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Creates an NTNDArray wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTNDArray or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTNDArray instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure reports to be a compatible NTNDArray.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTNDArray through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the pvStructure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTNDArray
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTNDArray.
|
||||
*
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTNDArray through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTNDArray
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure is compatible with NTNDArray.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTNDArray through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTNDArray
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure is compatible with NTNDArray.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTNDArray through the introspection interface.
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTNDArray
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the wrapped PVStructure is valid with respect to this
|
||||
* version of NTNDArray.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTNDArray
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Creates an NTNDArrayBuilder instance
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTNDArrayBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTNDArray() {}
|
||||
|
||||
/**
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attaches a pvTimeStamp to dataTimeStamp field.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachDataTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Returns the value field.
|
||||
* Returns the value field.
|
||||
*/
|
||||
epics::pvData::PVUnionPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Returns the codec field.
|
||||
* @return the codec field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getCodec() const;
|
||||
|
||||
/**
|
||||
* Returns the compressedDataSize field.
|
||||
* @return the compressedDataSize field.
|
||||
*/
|
||||
epics::pvData::PVLongPtr getCompressedDataSize() const;
|
||||
|
||||
/**
|
||||
* Returns the uncompressedDataSize field.
|
||||
* @return the uncompressedDataSize field.
|
||||
*/
|
||||
epics::pvData::PVLongPtr getUncompressedDataSize() const;
|
||||
|
||||
/**
|
||||
* Returns the dimension field.
|
||||
* @return the dimension field.
|
||||
*/
|
||||
epics::pvData::PVStructureArrayPtr getDimension() const;
|
||||
|
||||
/**
|
||||
* Returns the uniqueId field.
|
||||
* @return the uniqueId field.
|
||||
*/
|
||||
epics::pvData::PVIntPtr getUniqueId() const;
|
||||
|
||||
/**
|
||||
* Returns the dataTimeStamp field.
|
||||
* @return the dataTimeStamp field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getDataTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Returns the attribute field.
|
||||
* @return the attribute field.
|
||||
*/
|
||||
epics::pvData::PVStructureArrayPtr getAttribute() const;
|
||||
|
||||
/**
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no descriptor field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no timeStamp field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no alarm field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Attaches a PVDisplay to the wrapped PVStructure.
|
||||
* Does nothing if no display.
|
||||
* @param pvDisplay the PVDisplay that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a display field), otherwise false.
|
||||
*/
|
||||
bool attachDisplay(epics::pvData::PVDisplay &pvDisplay) const;
|
||||
|
||||
/**
|
||||
* Returns the display field.
|
||||
* @return PVStructurePtr or null if no alarm field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getDisplay() const;
|
||||
|
||||
private:
|
||||
NTNDArray(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
epics::pvData::int64 getExpectedUncompressedSize();
|
||||
epics::pvData::int64 getValueSize();
|
||||
epics::pvData::int64 getValueTypeSize();
|
||||
|
||||
epics::pvData::PVStructurePtr pvNTNDArray;
|
||||
|
||||
friend class detail::NTNDArrayBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTNDARRAY_H */
|
||||
316
src/pv/ntndarrayAttribute.h
Normal file
316
src/pv/ntndarrayAttribute.h
Normal file
@@ -0,0 +1,316 @@
|
||||
/* ntndarrayAttribute.h */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTNDARRAYATTRIBUTE_H
|
||||
#define NTNDARRAYATTRIBUTE_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntndarrayAttributeEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef ntndarrayAttributeEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntndarrayAttributeEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
struct Result;
|
||||
class NTNDArrayAttribute;
|
||||
typedef std::tr1::shared_ptr<NTNDArrayAttribute> NTNDArrayAttributePtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTAttribute extended as required by NTNDArray
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTNDArrayAttributeBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTNDArrayAttributeBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTNDArrayAttributeBuilder);
|
||||
|
||||
/**
|
||||
* Adds tags field to the NTNDArrayAttribute.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTags();
|
||||
|
||||
/**
|
||||
* Adds descriptor field to the NTNDArrayAttribute.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Adds alarm field to the NTNDArrayAttribute.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Adds timeStamp field to the NTNDArrayAttribute.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Creates a <b>Structure</b> that represents NTNDArrayAttribute.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>PVStructure</b> that represents NTNDArrayAttribute.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>NTNDArrayAttribute</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTNDArrayAttribute</b>.
|
||||
*/
|
||||
NTNDArrayAttributePtr create();
|
||||
|
||||
/**
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTNDArrayAttributeBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
protected://private:
|
||||
NTNDArrayAttributeBuilder();
|
||||
|
||||
void reset();
|
||||
|
||||
bool tags;
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTNDArrayAttribute;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTNDArrayAttributeBuilder> NTNDArrayAttributeBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTNDArrayAttribute
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTNDArrayAttribute
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTNDArrayAttribute);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Creates an NTNDArrayAttribute wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTAttribute
|
||||
* extended as required by NTNDArray and if so returns an
|
||||
* NTNDArrayAttribute which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTAttribute instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Creates an NTNDArrayAttribute wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTAttribute extended as required by NTNDArray
|
||||
* or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTAttribute instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure reports to be a compatible NTAttribute.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTAttribute through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTAttribute
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTAttribute.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTAttribute through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTAttribute
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure is compatible with NTAttribute
|
||||
* extended as required by NTNDArray.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTAttribute extended as required by this version of NTNDArray
|
||||
* through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTAttribute
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure is compatible with NTAttribute
|
||||
* extended as required by NTNDArray.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTAttribute extended as required by this version of NTNDArray
|
||||
* through the introspection interface.
|
||||
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTAttribute
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the wrapped PVStructure is valid with respect to this
|
||||
* version of NTAttribute extended as per this version of NTNDArray.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTNDArrayAttribute
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Creates an NTNDArrayAttribute builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTNDArrayAttributeBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTNDArrayAttribute() {}
|
||||
|
||||
/**
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no alarm field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Returns the name field.
|
||||
* @return the name field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getName() const;
|
||||
|
||||
/**
|
||||
* Returns the value field.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVUnionPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Returns the tags field.
|
||||
* @return the tags field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getTags() const;
|
||||
|
||||
/**
|
||||
* Returns the sourceType field.
|
||||
* @return the sourceType field.
|
||||
*/
|
||||
epics::pvData::PVIntPtr getSourceType() const;
|
||||
|
||||
/**
|
||||
* Returns the source field.
|
||||
* @return the source field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getSource() const;
|
||||
|
||||
private:
|
||||
NTNDArrayAttribute(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
static Result& isAttribute(Result& result);
|
||||
|
||||
epics::pvData::PVStructurePtr pvNTNDArrayAttribute;
|
||||
epics::pvData::PVUnionPtr pvValue;
|
||||
|
||||
friend class detail::NTNDArrayAttributeBuilder;
|
||||
friend class NTNDArray;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTNDARRAYATTRIBUTE_H */
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntscalar.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTSCALAR_H
|
||||
#define NTSCALAR_H
|
||||
@@ -45,66 +44,67 @@ namespace detail {
|
||||
POINTER_DEFINITIONS(NTScalarBuilder);
|
||||
|
||||
/**
|
||||
* Set a value type of a NTScalar.
|
||||
* Sets the value type of an NTScalar.
|
||||
* @param scalarType the value type.
|
||||
* @return this instance of <b>NTScalarBuilder</b>.
|
||||
*/
|
||||
shared_pointer value(epics::pvData::ScalarType scalarType);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTScalar.
|
||||
* Adds descriptor field to the NTScalar.
|
||||
* @return this instance of <b>NTScalarBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTScalar.
|
||||
* Adds alarm field to the NTScalar.
|
||||
* @return this instance of <b>NTScalarBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTScalar.
|
||||
* Adds timeStamp field to the NTScalar.
|
||||
* @return this instance of <b>NTScalarBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Add display structure to the NTScalar.
|
||||
* Adds display field to the NTScalar.
|
||||
* @return this instance of <b>NTScalarBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDisplay();
|
||||
|
||||
/**
|
||||
* Add control structure to the NTScalar.
|
||||
* Adds control field to the NTScalar.
|
||||
* @return this instance of <b>NTScalarBuilder</b>.
|
||||
*/
|
||||
shared_pointer addControl();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTScalar.
|
||||
* Creates a <b>Structure</b> that represents NTScalar.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTScalar.
|
||||
* Creates a <b>PVStructure</b> that represents NTScalar.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTScalar</b> instance.
|
||||
* Creates a <b>NTScalar</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTScalar</b>.
|
||||
*/
|
||||
NTScalarPtr create();
|
||||
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTScalarBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
@@ -149,65 +149,92 @@ public:
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTScalar.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTScalar.
|
||||
* @return NTScalar instance on success, nullptr otherwise.
|
||||
* Creates an NTScalar wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTScalar
|
||||
* and if so returns an NTScalar which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTScalar instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTMultiChannel without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTScalar.
|
||||
* @return NTScalar instance.
|
||||
* Creates an NTScalar wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTScalar or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTScalar instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTScalar.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalar.
|
||||
* Returns whether the specified Structure reports to be a compatible NTScalar.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTScalar through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTScalar
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTScalar.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalar.
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTScalar.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTScalar through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTScalar
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTScalar.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalar.
|
||||
* Returns whether the specified Structure is compatible with NTScalar.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTScalar through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTScalar
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTScalar.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalar.
|
||||
* Returns whether the specified PVStructure is compatible with NTScalar.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTScalar through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTScalar
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTScalar.
|
||||
* Returns whether the wrapped PVStructure is valid with respect to this
|
||||
* version of NTScalar.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTScalar
|
||||
* @return (false,true) if (is not, is) a valid NTScalar.
|
||||
* @return (false,true) if wrapped PVStructure (is not, is) a valid NTScalar
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTScalar builder instance.
|
||||
* Creates an NTScalar builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTScalarBuilderPtr createBuilder();
|
||||
@@ -218,82 +245,84 @@ public:
|
||||
~NTScalar() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Attach an pvDisplay.
|
||||
* @param pvDisplay The pvDisplay that will be attached.
|
||||
* Does nothing if no display.
|
||||
* @return true if the operation was successfull (i.e. this instance has a display field), otherwise false.
|
||||
* Attaches a PVDisplay to the wrapped PVStructure.
|
||||
* Does nothing if no display field.
|
||||
* @param pvDisplay the PVDisplay that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a display field), otherwise false.
|
||||
*/
|
||||
bool attachDisplay(epics::pvData::PVDisplay &pvDisplay) const;
|
||||
|
||||
/**
|
||||
* Attach an pvControl.
|
||||
* @param pvControl The pvControl that will be attached.
|
||||
* Does nothing if no control.
|
||||
* @return true if the operation was successfull (i.e. this instance has a control field), otherwise false.
|
||||
* Attaches an PVControl to the wrapped PVStructure.
|
||||
* Does nothing if no control field.
|
||||
* @param pvControl The PVControl that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a control field), otherwise false.
|
||||
*/
|
||||
bool attachControl(epics::pvData::PVControl &pvControl) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no descriptor field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no timeStamp field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no alarm field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the display.
|
||||
* Returns the display.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getDisplay() const;
|
||||
|
||||
/**
|
||||
* Get the control.
|
||||
* Returns the control.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getControl() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* Returns the value field.
|
||||
* @return The PVField for the values.
|
||||
*/
|
||||
epics::pvData::PVFieldPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the value field of a specified type (e.g. PVDouble).
|
||||
* @return The <PVT> field for the values.
|
||||
* Returns the value field of a specified type (for example, PVDouble).
|
||||
* @tparam PVT the expected type of the value field which should be
|
||||
* be PVScalar or a derived class.
|
||||
* @return the value field or null if it is not of the expected type.
|
||||
*/
|
||||
template<typename PVT>
|
||||
std::tr1::shared_ptr<PVT> getValue() const
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntscalarArray.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTSCALARARRAY_H
|
||||
#define NTSCALARARRAY_H
|
||||
@@ -46,66 +45,75 @@ namespace detail {
|
||||
POINTER_DEFINITIONS(NTScalarArrayBuilder);
|
||||
|
||||
/**
|
||||
* Set a value type of a NTScalarArray.
|
||||
* @param elementType the value array element type.
|
||||
* Sets the value type of the NTScalarArray.
|
||||
* @param elementType the value field element ScalarType.
|
||||
* @return this instance of <b>NTScalarArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer value(epics::pvData::ScalarType elementType);
|
||||
|
||||
/**
|
||||
* Sets the value type of the NTScalarArray.
|
||||
* @param elementType the value field element ScalarType.
|
||||
* @return this instance of <b>NTScalarArrayBuilder</b>.
|
||||
* @deprecated use value instead.
|
||||
*/
|
||||
shared_pointer arrayValue(epics::pvData::ScalarType elementType);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTScalarArray.
|
||||
* Adds descriptor field to the NTScalarArray.
|
||||
* @return this instance of <b>NTScalarArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTScalarArray.
|
||||
* Adds alarm field to the NTScalarArray.
|
||||
* @return this instance of <b>NTScalarArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTScalarArray.
|
||||
* Adds timeStamp field to the NTScalarArray.
|
||||
* @return this instance of <b>NTScalarArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Add display structure to the NTScalarArray.
|
||||
* Adds display field to the NTScalarArray.
|
||||
* @return this instance of <b>NTScalarArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDisplay();
|
||||
|
||||
/**
|
||||
* Add control structure to the NTScalarArray.
|
||||
* Adds control field to the NTScalarArray.
|
||||
* @return this instance of <b>NTScalarArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer addControl();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTScalarArray.
|
||||
* Creates a <b>Structure</b> that represents NTScalarArray.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTScalarArray.
|
||||
* Creates a <b>PVStructure</b> that represents NTScalarArray.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTScalarArray</b> instance.
|
||||
* Creates a <b>NTScalarArray</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTScalarArray</b>.
|
||||
*/
|
||||
NTScalarArrayPtr create();
|
||||
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTScalarArrayBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
@@ -150,65 +158,91 @@ public:
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTScalarArray.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTScalarArray.
|
||||
* @return NTScalarArray instance on success, nullptr otherwise.
|
||||
* Creates an NTScalarArray wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTScalarArray
|
||||
* and if so returns an NTScalarArray which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTScalarArray instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTMatrix without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTScalarArray.
|
||||
* @return NTScalarArray instance.
|
||||
* Creates an NTScalarArray wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTScalarArray or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTScalarArray instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTScalarArray.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalarArray.
|
||||
* Returns whether the specified Structure reports to be a compatible NTScalarArray.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTScalarArray through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTScalarArray
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTScalarArray.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalarArray.
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTScalarArray.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTScalarArray through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTScalarArray
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTScalarArray.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalarArray.
|
||||
* Returns whether the specified Structure is compatible with NTScalarArray.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTScalarArray through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test.
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTScalarArray
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTScalarArray.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalarArray.
|
||||
* Returns whether the specified PVStructure is compatible with NTScalarArray.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTScalarArray through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTScalarArray
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTScalarArray.
|
||||
* Returns whether the wrapped PVStructure is a valid NTScalarArray.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTScalarArray
|
||||
* @return (false,true) if (is not, is) a valid NTScalarArray.
|
||||
* @return (false,true) if the wrapped PVStructure (is not, is) a valid NTScalarArray.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTScalarArray builder instance.
|
||||
* Creates an NTScalarArray builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTScalarArrayBuilderPtr createBuilder();
|
||||
@@ -219,82 +253,84 @@ public:
|
||||
~NTScalarArray() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Attach an pvDisplay.
|
||||
* @param pvDisplay The pvDisplay that will be attached.
|
||||
* Does nothing if no display.
|
||||
* @return true if the operation was successfull (i.e. this instance has a display field), otherwise false.
|
||||
* Attaches a PVDisplay to the wrapped PVStructure.
|
||||
* Does nothing if no display field.
|
||||
* @param pvDisplay the PVDisplay that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a display field), otherwise false.
|
||||
*/
|
||||
bool attachDisplay(epics::pvData::PVDisplay &pvDisplay) const;
|
||||
|
||||
/**
|
||||
* Attach an pvControl.
|
||||
* Attaches an pvControl.
|
||||
* @param pvControl The pvControl that will be attached.
|
||||
* Does nothing if no control.
|
||||
* Does nothing if no control field.
|
||||
* @return true if the operation was successfull (i.e. this instance has a control field), otherwise false.
|
||||
*/
|
||||
bool attachControl(epics::pvData::PVControl &pvControl) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no descriptor field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no timeStamp field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no alarm field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the display.
|
||||
* Returns the display.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getDisplay() const;
|
||||
|
||||
/**
|
||||
* Get the control.
|
||||
* Returns the control.
|
||||
* @return PVStructurePtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getControl() const;
|
||||
|
||||
/**
|
||||
* Get the value field.
|
||||
* Returns the value field.
|
||||
* @return The PVField for the values.
|
||||
*/
|
||||
epics::pvData::PVFieldPtr getValue() const;
|
||||
|
||||
/**
|
||||
* Get the value field of a specified type (e.g. PVDoubleArray).
|
||||
* @return The <PVT> field for the values.
|
||||
* Returns the value field of a specified type (e.g. PVDoubleArray).
|
||||
* @tparam PVT the expected type of the value field which should be
|
||||
* be PVScalarArray or a derived class.
|
||||
* @return the value field or null if it is not of the expected type.
|
||||
*/
|
||||
template<typename PVT>
|
||||
std::tr1::shared_ptr<PVT> getValue() const
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntscalarMultiChannel.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTSCALARMULTICHANNEL_H
|
||||
#define NTSCALARMULTICHANNEL_H
|
||||
@@ -49,87 +48,104 @@ namespace detail {
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTScalarMultiChannelBuilder);
|
||||
|
||||
/**
|
||||
* specify the scalar type for the value field.
|
||||
* Sets the scalar type for the value field.
|
||||
* If this is not called then pvDouble is the default.
|
||||
* @param scalarType the value field element ScalarType.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer value(epics::pvData::ScalarType scalarType);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTScalarMultiChannel.
|
||||
* Adds descriptor field to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTScalarMultiChannel.
|
||||
* Adds alarm field to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTScalarMultiChannel.
|
||||
* Adds timeStamp field to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Add severity array to the NTScalarMultiChannel.
|
||||
* Adds severity array to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addSeverity();
|
||||
|
||||
/**
|
||||
* Add status array to the NTScalarMultiChannel.
|
||||
* Adds status array to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addStatus();
|
||||
|
||||
/**
|
||||
* Add message array to the NTScalarMultiChannel.
|
||||
* Adds message array to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addMessage();
|
||||
|
||||
/**
|
||||
* Add secondsPastEpoch array to the NTScalarMultiChannel.
|
||||
* Adds secondsPastEpoch array to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addSecondsPastEpoch();
|
||||
|
||||
/**
|
||||
* Add nanoseconds array to the NTScalarMultiChannel.
|
||||
* Adds nanoseconds array to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addNanoseconds();
|
||||
|
||||
/**
|
||||
* Add userTag array to the NTScalarMultiChannel.
|
||||
* Adds userTag array to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addUserTag();
|
||||
|
||||
/**
|
||||
* Add isConnected array to the NTScalarMultiChannel.
|
||||
* Adds isConnected array to the NTScalarMultiChannel.
|
||||
* @return this instance of <b>NTScalarMultiChannelBuilder</b>.
|
||||
*/
|
||||
shared_pointer addIsConnected();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTScalarMultiChannel.
|
||||
* Creates a <b>Structure</b> that represents NTScalarMultiChannel.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTScalarMultiChannel.
|
||||
* This resets this instance state and allows new {@code instance to be created.}
|
||||
* Creates a <b>PVStructure</b> that represents NTScalarMultiChannel.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTScalarMultiChannel</b> instance.
|
||||
* This resets this instance state and allows new {@code instance to be created.}
|
||||
* Creates a <b>NTScalarMultiChannel</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTScalarMultiChannel</b>
|
||||
*/
|
||||
NTScalarMultiChannelPtr create();
|
||||
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of a <b>NTScalarMultiChannelBuilder</b>
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTScalarMultiChannelBuilder();
|
||||
|
||||
@@ -173,64 +189,90 @@ public:
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTScalarMultiChannel.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTScalarMultiChannel.
|
||||
* @return NTScalarMultiChannel instance on success, nullptr otherwise.
|
||||
* Creates an NTScalarMultiChannel wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTScalarMultiChannel
|
||||
* and if so returns an NTScalarMultiChannel which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTScalarMultiChannel instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTScalarMultiChannel without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTScalarMultiChannel.
|
||||
* @return NTScalarMultiChannel instance.
|
||||
* Creates an NTScalarMultiChannel wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTScalarMultiChannel or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTScalarMultiChannel instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTScalarMultiChannel.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalarMultiChannel.
|
||||
* Returns whether the specified Structure reports to be a compatible NTScalarMultiChannel.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTScalarMultiChannel through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTScalarMultiChannel
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTScalarMultiChannel.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalarMultiChannel.
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTScalarMultiChannel.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTScalarMultiChannel through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTScalarMultiChannel
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTScalarMultiChannel.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalarMultiChannel.
|
||||
* Returns whether the specified Structure is compatible with NTScalarMultiChannel.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTScalarMultiChannel through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTScalarMultiChannel
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTScalarMultiChannel.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTScalarMultiChannel.
|
||||
* Returns whether the wrapped PVStructure is a valid NTScalarMultiChannel.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* @return (false,true) if wrapped PVStructure (is not, is) a valid NTScalarMultiChannel
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTScalarMultiChannel.
|
||||
* Returns whether the specified PVStructure is a valid NTScalarMultiChannel.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTScalarMultiChannel
|
||||
* @return (false,true) if (is not, is) a valid NTScalarMultiChannel.
|
||||
* @return (false,true) if wrapped PVStructure (is not, is) a valid NTScalarMultiChannel.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTScalarMultiChannelBuilder instance
|
||||
* Creates an NTScalarMultiChannelBuilder instance
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTScalarMultiChannelBuilderPtr createBuilder();
|
||||
@@ -239,107 +281,126 @@ public:
|
||||
* Destructor
|
||||
*/
|
||||
~NTScalarMultiChannel() {}
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
/**
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach a pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const
|
||||
{return pvNTScalarMultiChannel;}
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Return the descriptor field.
|
||||
* @return the descriptor field or null if no descriptor field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const
|
||||
{return pvDescriptor;}
|
||||
|
||||
/**
|
||||
* Returns the timeStamp field.
|
||||
* @return the timeStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const
|
||||
{return pvTimeStamp;}
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const
|
||||
{return pvAlarm;}
|
||||
|
||||
/**
|
||||
* Get the value of each channel.
|
||||
* @return PVScalarArrayPtr
|
||||
* Returns the field with the value of each channel.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVScalarArrayPtr getValue() const
|
||||
{return pvValue;}
|
||||
|
||||
/**
|
||||
* Get the value field of a specified type (e.g. PVDoubleArray).
|
||||
* @return The <PVT> field for the values.
|
||||
* Returns the value of each channel of a specified expected type
|
||||
* (for example, PVDoubleArray).
|
||||
* @tparam PVT the expected type of the value field which should be
|
||||
* be PVScalarArray or a derived class.
|
||||
* @return the value field or null if it is not of the expected type.
|
||||
*/
|
||||
template<typename PVT>
|
||||
std::tr1::shared_ptr<PVT> getValue() const
|
||||
{
|
||||
return std::tr1::dynamic_pointer_cast<PVT>(pvValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channelName of each channel.
|
||||
* @return PVStringArrayPtr
|
||||
* Returns the field with the channelName of each channel.
|
||||
* @return the channelName field
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getChannelName() const
|
||||
{ return pvChannelName;};
|
||||
|
||||
/**
|
||||
* Get the connection state of each channel.
|
||||
* @return PVBooleanArrayPtr
|
||||
* Returns the field with the connection state of each channel.
|
||||
* @return the isConnected field or null if no such field
|
||||
*/
|
||||
epics::pvData::PVBooleanArrayPtr getIsConnected() const
|
||||
{ return pvIsConnected;};
|
||||
|
||||
/**
|
||||
* Get the severity of each channel.
|
||||
* @return PVIntArrayPtr which may be null.
|
||||
* Returns the field with the severity of each channel.
|
||||
* @return the severity field or null if no such field
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getSeverity() const
|
||||
{return pvSeverity;}
|
||||
|
||||
/**
|
||||
* Get the status of each channel.
|
||||
* @return PVIntArrayPtr which may be null.
|
||||
* Returns the field with the status of each channel.
|
||||
* @return the status field or null if no such field
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getStatus() const
|
||||
{return pvStatus;}
|
||||
|
||||
/**
|
||||
* Get the message of each chnnel.
|
||||
* @return PVStringArrayPtr which may be null.
|
||||
* Returns the field with the message of each channel.
|
||||
* @return message field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getMessage() const
|
||||
{return pvMessage;}
|
||||
|
||||
/**
|
||||
* Get the secondsPastEpoch of each channel.
|
||||
* @return PVLongArrayPtr which may be null.
|
||||
* Returns the field with the secondsPastEpoch of each channel.
|
||||
* @return the secondsPastEpoch field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVLongArrayPtr getSecondsPastEpoch() const
|
||||
{return pvSecondsPastEpoch;}
|
||||
|
||||
/**
|
||||
* Get the nanoseconds of each channel.
|
||||
* @return PVIntArrayPtr which may be null.
|
||||
* Returns the field with the nanoseconds of each channel.
|
||||
* @return nanoseconds field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getNanoseconds() const
|
||||
{return pvNanoseconds;}
|
||||
|
||||
/**
|
||||
* Get the userTag of each channel.
|
||||
* @return PVIntArrayPtr which may be null.
|
||||
* Returns the field with the userTag of each channel.
|
||||
* @return the userTag field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVIntArrayPtr getUserTag() const
|
||||
{return pvUserTag;}
|
||||
/**
|
||||
* Get the descriptor.
|
||||
* @return PVStringPtr which may be null.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const
|
||||
{return pvDescriptor;}
|
||||
|
||||
private:
|
||||
NTScalarMultiChannel(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTScalarMultiChannel;
|
||||
@@ -1,8 +1,7 @@
|
||||
/* nttable.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTTABLE_H
|
||||
#define NTTABLE_H
|
||||
@@ -48,7 +47,7 @@ namespace detail {
|
||||
POINTER_DEFINITIONS(NTTableBuilder);
|
||||
|
||||
/**
|
||||
* Add a column of given <b>Scalar</b> type.
|
||||
* Adds a column of given <b>Scalar</b> type.
|
||||
* @param name name of the column.
|
||||
* @param elementType column type, a scalar array.
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
@@ -56,32 +55,32 @@ namespace detail {
|
||||
shared_pointer addColumn(std::string const & name, epics::pvData::ScalarType elementType);
|
||||
|
||||
/**
|
||||
* Add descriptor field to the NTTable.
|
||||
* Adds descriptor field to the NTTable.
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Add alarm structure to the NTTable.
|
||||
* Adds alarm field to the NTTable.
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Add timeStamp structure to the NTTable.
|
||||
* Adds timeStamp field to the NTTable.
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTTable.
|
||||
* Creates a <b>Structure</b> that represents NTTable.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTTable.
|
||||
* Creates a <b>PVStructure</b> that represents NTTable.
|
||||
* The returned PVStructure will have labels equal to the column names.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>.
|
||||
@@ -89,17 +88,18 @@ namespace detail {
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTTable</b> instance.
|
||||
* Creates a <b>NTTable</b> instance.
|
||||
* The returned NTTable will wrap a PVStructure which will have
|
||||
* labels equal to the column names.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTTable</b>.
|
||||
*/
|
||||
NTTablePtr create();
|
||||
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTTableBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
@@ -142,65 +142,91 @@ public:
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTTable.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTTable.
|
||||
* @return NTTable instance on success, nullptr otherwise.
|
||||
* Creates an NTTable wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTTable
|
||||
* and if so returns an NTTable which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTTable instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTMultiChannel without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTTable.
|
||||
* @return NTTable instance.
|
||||
* Creates an NTTable wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTTable or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTTable instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTTable.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTTable.
|
||||
* Returns whether the specified Structure reports to be a compatible NTTable.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTTable through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTTable
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTTable.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTTable.
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTTable.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTTable through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTTable
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTTable.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTTable.
|
||||
* Returns whether the specified Structure is compatible with NTTable.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTTable through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTTable
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTTable.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTTable.
|
||||
* Returns whether the specified PVStructure is compatible with NTTable.
|
||||
*
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTTable through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTTable
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTTable.
|
||||
* Returns whether the specified structure is a valid NTTable.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTTable
|
||||
* @return (false,true) if (is not, is) a valid NTTable.
|
||||
* @return (false,true) if wrapped PVStructure (is not, is) a valid NTTable
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTTable builder instance.
|
||||
* Creates an NTTable builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTTableBuilderPtr createBuilder();
|
||||
@@ -211,69 +237,73 @@ public:
|
||||
~NTTable() {}
|
||||
|
||||
/**
|
||||
* Attach a pvTimeStamp.
|
||||
* @param pvTimeStamp The pvTimeStamp that will be attached.
|
||||
* Does nothing if no timeStamp.
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attach an pvAlarm.
|
||||
* @param pvAlarm The pvAlarm that will be attached.
|
||||
* Does nothing if no alarm.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the descriptor field.
|
||||
* @return The pvString or null if no function field.
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no descriptor field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Get the timeStamp.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Get the alarm.
|
||||
* @return PVStructurePtr which may be null.
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Get the labels field.
|
||||
* @return The pvStringArray for the labels.
|
||||
* Returns the labels field.
|
||||
* @return the labels field.
|
||||
*/
|
||||
epics::pvData::PVStringArrayPtr getLabels() const;
|
||||
|
||||
/**
|
||||
* Get the column names for the table.
|
||||
* Returns the column names for the table.
|
||||
* For each name, calling getColumn should return the column, which should not be null.
|
||||
* @return The column names.
|
||||
* @return the column names.
|
||||
*/
|
||||
epics::pvData::StringArray const & getColumnNames() const;
|
||||
|
||||
/**
|
||||
* Get the PVField (column) for a field that follows the label field.
|
||||
* @param columnName The name of the column.
|
||||
* @return The PVFieldPtr for the field.
|
||||
* Returns the PVField for the column with the specified colum name.
|
||||
* @param columnName the name of the column.
|
||||
* @return the field for the column or null if column does not exist.
|
||||
*/
|
||||
epics::pvData::PVFieldPtr getColumn(std::string const & columnName) const;
|
||||
|
||||
/**
|
||||
* Get the PVField (column) for a field that follows the label field of a specified type (e.g. PVDoubleArray).
|
||||
* @param columnName The name of the column.
|
||||
* @return The <PVT> field.
|
||||
* Returns the column with the specified column name and of a specified
|
||||
* expected type (for example, PVDoubleArray).
|
||||
* @tparam PVT the expected type of the column which should be
|
||||
* be PVScalarArray or a derived class.
|
||||
* @param columnName the name of the column.
|
||||
* @return the field for the column or null if column does not exist
|
||||
* or is not of the specified type.
|
||||
*/
|
||||
template<typename PVT>
|
||||
std::tr1::shared_ptr<PVT> getColumn(std::string const & columnName) const
|
||||
280
src/pv/ntunion.h
Normal file
280
src/pv/ntunion.h
Normal file
@@ -0,0 +1,280 @@
|
||||
/* ntunion.h */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTUNION_H
|
||||
#define NTUNION_H
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define ntunionEpicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#ifdef ntunionEpicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
# undef ntunionEpicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include <pv/ntfield.h>
|
||||
|
||||
#include <shareLib.h>
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
class NTUnion;
|
||||
typedef std::tr1::shared_ptr<NTUnion> NTUnionPtr;
|
||||
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* @brief Interface for in-line creating of NTUnion.
|
||||
*
|
||||
* One instance can be used to create multiple instances.
|
||||
* An instance of this object must not be used concurrently (an object has a state).
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTUnionBuilder :
|
||||
public std::tr1::enable_shared_from_this<NTUnionBuilder>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTUnionBuilder);
|
||||
|
||||
/**
|
||||
* Specifies the union for the value field.
|
||||
* If this is not called then a variant union is the default.
|
||||
* @param unionType the introspection object for the union value field
|
||||
* @return this instance of NTUnionBuilder
|
||||
*/
|
||||
shared_pointer value(epics::pvData::UnionConstPtr unionType);
|
||||
|
||||
/**
|
||||
* Adds descriptor field to the NTUnion.
|
||||
* @return this instance of <b>NTUnionBuilder</b>.
|
||||
*/
|
||||
shared_pointer addDescriptor();
|
||||
|
||||
/**
|
||||
* Adds alarm field to the NTUnion.
|
||||
* @return this instance of <b>NTUnionBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAlarm();
|
||||
|
||||
/**
|
||||
* Adds timeStamp field to the NTUnion.
|
||||
* @return this instance of <b>NTUnionBuilder</b>.
|
||||
*/
|
||||
shared_pointer addTimeStamp();
|
||||
|
||||
/**
|
||||
* Creates a <b>Structure</b> that represents NTUnion.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>PVStructure</b> that represents NTUnion.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>PVStructure</b>.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Creates a <b>NTUnion</b> instance.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of a <b>NTUnion</b>.
|
||||
*/
|
||||
NTUnionPtr create();
|
||||
/**
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTUnionBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
|
||||
private:
|
||||
NTUnionBuilder();
|
||||
|
||||
epics::pvData::UnionConstPtr valueType;
|
||||
|
||||
void reset();
|
||||
|
||||
bool descriptor;
|
||||
bool alarm;
|
||||
bool timeStamp;
|
||||
|
||||
// NOTE: this preserves order, however it does not handle duplicates
|
||||
epics::pvData::StringArray extraFieldNames;
|
||||
epics::pvData::FieldConstPtrArray extraFields;
|
||||
|
||||
friend class ::epics::nt::NTUnion;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef std::tr1::shared_ptr<detail::NTUnionBuilder> NTUnionBuilderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience Class for NTUnion
|
||||
*
|
||||
* @author dgh
|
||||
*/
|
||||
class epicsShareClass NTUnion
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(NTUnion);
|
||||
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Creates an NTUnion wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTUnion
|
||||
* and if so returns an NTUnion which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTUnion instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Creates an NTUnion wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTUnion or is non-null.
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTUnion instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure reports to be a compatible NTUnion.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTUnion through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTUnion
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTUnion.
|
||||
*
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTUnion through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTUnion
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified Structure is compatible with NTUnion.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTUnion through the introspection interface.
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTUnion
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Returns whether the specified PVStructure is compatible with NTUnion.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTUnion through the introspection interface
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTUnion
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Returns whether the wrapped PVStructure is a valid NTUnion.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* @return (false,true) if wrapped PVStructure (is not, is) a valid NTUnion
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Creates an NTUnion builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTUnionBuilderPtr createBuilder();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~NTUnion() {}
|
||||
|
||||
/**
|
||||
* Attaches a PVTimeStamp to the wrapped PVStructure.
|
||||
* Does nothing if no timeStamp field.
|
||||
* @param pvTimeStamp the PVTimeStamp that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.
|
||||
*/
|
||||
bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
|
||||
|
||||
/**
|
||||
* Attaches a PVAlarm to the wrapped PVStructure.
|
||||
* Does nothing if no alarm field.
|
||||
* @param pvAlarm the PVAlarm that will be attached.
|
||||
* @return true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.
|
||||
*/
|
||||
bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
|
||||
|
||||
/**
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Returns the descriptor field.
|
||||
* @return the descriptor field or null if no descriptor field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getDescriptor() const;
|
||||
|
||||
/**
|
||||
* Returns the timeStamp field.
|
||||
* @return the timStamp field or null if no timeStamp field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Returns the alarm field.
|
||||
* @return the alarm field or null if no alarm field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getAlarm() const;
|
||||
|
||||
/**
|
||||
* Returns the value field.
|
||||
* @return the value field.
|
||||
*/
|
||||
epics::pvData::PVUnionPtr getValue() const;
|
||||
|
||||
private:
|
||||
NTUnion(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
epics::pvData::PVStructurePtr pvNTUnion;
|
||||
epics::pvData::PVUnionPtr pvValue;
|
||||
|
||||
friend class detail::NTUnionBuilder;
|
||||
};
|
||||
|
||||
}}
|
||||
#endif /* NTUNION_H */
|
||||
@@ -1,8 +1,7 @@
|
||||
/* nturi.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTURI_H
|
||||
#define NTURI_H
|
||||
@@ -45,13 +44,13 @@ namespace detail {
|
||||
POINTER_DEFINITIONS(NTURIBuilder);
|
||||
|
||||
/**
|
||||
* Add authority field to the NTURI.
|
||||
* Adds authority field to the NTURI.
|
||||
* @return this instance of <b>NTURIBuilder</b>.
|
||||
*/
|
||||
shared_pointer addAuthority();
|
||||
|
||||
/**
|
||||
* Add extra <b>Scalar</b> of ScalarType pvString
|
||||
* Adds extra <b>Scalar</b> of ScalarType pvString
|
||||
* to the query field of the type.
|
||||
* @param name name of the field.
|
||||
* @return this instance of <b>NTURIBuilder</b>.
|
||||
@@ -59,7 +58,7 @@ namespace detail {
|
||||
shared_pointer addQueryString(std::string const & name);
|
||||
|
||||
/**
|
||||
* Add extra <b>Scalar</b> of ScalarType pvDouble
|
||||
* Adds extra <b>Scalar</b> of ScalarType pvDouble
|
||||
* to the query field of the type.
|
||||
* @param name name of the field.
|
||||
* @return this instance of <b>NTURIBuilder</b>.
|
||||
@@ -67,7 +66,7 @@ namespace detail {
|
||||
shared_pointer addQueryDouble(std::string const & name);
|
||||
|
||||
/**
|
||||
* Add extra <b>Scalar</b> of ScalarType pvInt
|
||||
* Adds extra <b>Scalar</b> of ScalarType pvInt
|
||||
* to the query field of the type.
|
||||
* @param name name of the field.
|
||||
* @return this instance of <b>NTURIBuilder</b>.
|
||||
@@ -75,14 +74,14 @@ namespace detail {
|
||||
shared_pointer addQueryInt(std::string const & name);
|
||||
|
||||
/**
|
||||
* Create a <b>Structure</b> that represents NTURI.
|
||||
* Creates a <b>Structure</b> that represents NTURI.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>Structure</b>.
|
||||
*/
|
||||
epics::pvData::StructureConstPtr createStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>PVStructure</b> that represents NTURI.
|
||||
* Creates a <b>PVStructure</b> that represents NTURI.
|
||||
* The returned PVStructure will have labels equal to the column names.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>PVStructure</b>.
|
||||
@@ -90,17 +89,18 @@ namespace detail {
|
||||
epics::pvData::PVStructurePtr createPVStructure();
|
||||
|
||||
/**
|
||||
* Create a <b>NTURI</b> instance.
|
||||
* Creates a <b>NTURI</b> instance.
|
||||
* The returned NTURI will wrap a PVStructure which will have
|
||||
* labels equal to the column names.
|
||||
* This resets this instance state and allows new instance to be created.
|
||||
* @return a new instance of <b>NTURI</b>.
|
||||
*/
|
||||
NTURIPtr create();
|
||||
|
||||
/**
|
||||
* Add extra <b>Field</b> to the type.
|
||||
* @param name name of the field.
|
||||
* @param field a field to add.
|
||||
* Adds extra <b>Field</b> to the type.
|
||||
* @param name the name of the field.
|
||||
* @param field the field to be added.
|
||||
* @return this instance of <b>NTURIBuilder</b>.
|
||||
*/
|
||||
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
|
||||
@@ -141,65 +141,91 @@ public:
|
||||
static const std::string URI;
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTURI.
|
||||
* First isCompatible is called.
|
||||
* This method will nullptr if the structure is is not compatible.
|
||||
* This method will nullptr if the structure is nullptr.
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTURI.
|
||||
* @return NTURI instance on success, nullptr otherwise.
|
||||
* Creates an NTURI wrapping the specified PVStructure if the latter is compatible.
|
||||
* <p>
|
||||
* Checks the supplied PVStructure is compatible with NTURI
|
||||
* and if so returns an NTURI which wraps it.
|
||||
* This method will return null if the structure is is not compatible
|
||||
* or is null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTURI instance wrapping pvStructure on success, null otherwise
|
||||
*/
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Wrap (aka dynamic cast, or wrap) the structure to NTMultiChannel without checking for isCompatible
|
||||
* @param structure The structure to wrap-ed (dynamic cast, wrapped) to NTURI.
|
||||
* @return NTURI instance.
|
||||
* Creates an NTScalar wrapping the specified PVStructure, regardless of the latter's compatibility.
|
||||
* <p>
|
||||
* No checks are made as to whether the specified PVStructure
|
||||
* is compatible with NTScalar or is non-null.
|
||||
*
|
||||
* @param pvStructure the PVStructure to be wrapped
|
||||
* @return NTScalar instance wrapping pvStructure
|
||||
*/
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & structure);
|
||||
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTURI.
|
||||
* @param structure The structure to test.
|
||||
* @return (false,true) if (is not, is) an NTURI.
|
||||
* Returns whether the specified Structure reports to be a compatible NTScalar.
|
||||
* <p>
|
||||
* Checks if the specified Structure reports compatibility with this
|
||||
* version of NTScalar through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if (is not, is) a compatible NTScalar
|
||||
*/
|
||||
static bool is_a(epics::pvData::StructureConstPtr const & structure);
|
||||
|
||||
/**
|
||||
* Is the structure an NTURI.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTURI.
|
||||
* Returns whether the specified PVStructure reports to be a compatible NTURI.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure reports compatibility with this
|
||||
* version of NTURI through its type ID, including checking version numbers.
|
||||
* The return value does not depend on whether the structure is actually
|
||||
* compatible in terms of its introspection type.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test.
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTURI.
|
||||
*/
|
||||
static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
|
||||
|
||||
/**
|
||||
* Is the Structure compatible with NTURI.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param structure The Structure to test.
|
||||
* @return (false,true) if (is not, is) an NTURI.
|
||||
* Returns whether the specified Structure is compatible with NTURI.
|
||||
* <p>
|
||||
* Checks if the specified Structure is compatible with this version
|
||||
* of NTURI through the introspection interface.
|
||||
*
|
||||
* @param structure the Structure to test
|
||||
* @return (false,true) if the specified Structure (is not, is) a compatible NTURI
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::StructureConstPtr const &structure);
|
||||
|
||||
/**
|
||||
* Is the PVStructure compatible with NTURI.
|
||||
* This method introspects the fields to see if they are compatible.
|
||||
* @param pvStructure The PVStructure to test.
|
||||
* @return (false,true) if (is not, is) an NTURI.
|
||||
* Returns whether the specified PVStructure is compatible with NTURI.
|
||||
* <p>
|
||||
* Checks if the specified PVStructure is compatible with this version
|
||||
* of NTURI through the introspection interface.
|
||||
*
|
||||
* @param pvStructure the PVStructure to test
|
||||
* @return (false,true) if the specified PVStructure (is not, is) a compatible NTURI
|
||||
*/
|
||||
static bool isCompatible(
|
||||
epics::pvData::PVStructurePtr const &pvStructure);
|
||||
|
||||
/**
|
||||
* Checks if the specified structure is a valid NTURI.
|
||||
* Returns whether the wrapped PVStructure is a valid NTURI.
|
||||
* <p>
|
||||
* Unlike isCompatible(), isValid() may perform checks on the value
|
||||
* data as well as the introspection data.
|
||||
*
|
||||
* Checks whether the wrapped structure is valid with respect to this
|
||||
* version of NTURI
|
||||
* @return (false,true) if (is not, is) a valid NTURI.
|
||||
* @return (false,true) if wrapped PVStructure (is not, is) a valid NTURI.
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Create a NTURI builder instance.
|
||||
* Creates an NTURI builder instance.
|
||||
* @return builder instance.
|
||||
*/
|
||||
static NTURIBuilderPtr createBuilder();
|
||||
@@ -210,37 +236,37 @@ public:
|
||||
~NTURI() {}
|
||||
|
||||
/**
|
||||
* Get the pvStructure.
|
||||
* @return PVStructurePtr.
|
||||
* Returns the PVStructure wrapped by this instance.
|
||||
* @return the PVStructure wrapped by this instance.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getPVStructure() const;
|
||||
|
||||
/**
|
||||
* Get the scheme field.
|
||||
* @return The PVString for the scheme.
|
||||
* Returns the scheme field.
|
||||
* @return the scheme field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getScheme() const;
|
||||
|
||||
/**
|
||||
* Get the authority field.
|
||||
* @return The PVString for the authority.
|
||||
* Returns the authority field.
|
||||
* @return the authority field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getAuthority() const;
|
||||
|
||||
/**
|
||||
* Get the path field.
|
||||
* @return The PVString for the path.
|
||||
* Returns the path field.
|
||||
* @return the path field.
|
||||
*/
|
||||
epics::pvData::PVStringPtr getPath() const;
|
||||
|
||||
/**
|
||||
* Get the query field.
|
||||
* @return The PVStructure for the query.
|
||||
* Returns the query field.
|
||||
* @return the query field or null if no such field.
|
||||
*/
|
||||
epics::pvData::PVStructurePtr getQuery() const;
|
||||
|
||||
/**
|
||||
* Get the names of the query fields for the URI.
|
||||
* Returns the names of the query fields for the URI.
|
||||
* For each name, calling getQueryField should return
|
||||
* the query field, which should not be null.
|
||||
* @return The query field names.
|
||||
@@ -248,21 +274,25 @@ public:
|
||||
epics::pvData::StringArray const & getQueryNames() const;
|
||||
|
||||
/**
|
||||
* Get the PVField (column) for a field that follows the label field.
|
||||
* @param columnName The name of the column.
|
||||
* @return The PVFieldPtr for the field.
|
||||
* Returns the subfield of the query field with the specified name.
|
||||
* @param name the name of the subfield.
|
||||
* @return the the subfield of the query field or null if the field does not exist.
|
||||
*/
|
||||
epics::pvData::PVFieldPtr getQueryField(std::string const & columnName) const;
|
||||
epics::pvData::PVFieldPtr getQueryField(std::string const & name) const;
|
||||
|
||||
/**
|
||||
* Get the PVField (column) for a field that follows the label field of a specified type (e.g. PVDoubleArray).
|
||||
* @param columnName The name of the column.
|
||||
* @return The <PVT> field.
|
||||
* Returns the subfield of the query field (parameter) with the specified
|
||||
* name and of a specified expected type (for example, PVString).
|
||||
* @tparam PVT the expected type of the subfield which should be
|
||||
* be PVString, PVInt pr PVDouble.
|
||||
* @param name the subfield of the query field or null if the field does
|
||||
* not exist or is not of the expected type.
|
||||
* @return The PVT field.
|
||||
*/
|
||||
template<typename PVT>
|
||||
std::tr1::shared_ptr<PVT> getQueryField(std::string const & columnName) const
|
||||
std::tr1::shared_ptr<PVT> getQueryField(std::string const & name) const
|
||||
{
|
||||
epics::pvData::PVFieldPtr pvField = getQueryField(columnName);
|
||||
epics::pvData::PVFieldPtr pvField = getQueryField(name);
|
||||
if (pvField.get())
|
||||
return std::tr1::dynamic_pointer_cast<PVT>(pvField);
|
||||
else
|
||||
@@ -1,8 +1,7 @@
|
||||
/* ntutils.h */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef NTUTILS_H
|
||||
#define NTUTILS_H
|
||||
@@ -23,9 +22,9 @@ public:
|
||||
/**
|
||||
* Checks whether NT types are compatible by checking their IDs,
|
||||
* i.e. their names and major version must match.
|
||||
* @param u1 the first uri.
|
||||
* @param u2 the second uri.
|
||||
* @return true of URIs are compatible, false otherwise.
|
||||
* @param u1 the first URI.
|
||||
* @param u2 the second URI.
|
||||
* @return true if URIs are compatible, false otherwise.
|
||||
*/
|
||||
static bool is_a(const std::string &u1, const std::string &u2);
|
||||
|
||||
277
src/validator.h
Normal file
277
src/validator.h
Normal file
@@ -0,0 +1,277 @@
|
||||
/* validator.h */
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#ifndef VALIDATOR_H
|
||||
#define VALIDATOR_H
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
#include <pv/pvIntrospect.h>
|
||||
|
||||
namespace epics { namespace nt {
|
||||
|
||||
/**
|
||||
* @brief Validation methods for NT types.
|
||||
*
|
||||
* @author bsm
|
||||
*/
|
||||
|
||||
struct Result {
|
||||
struct Error {
|
||||
std::string path;
|
||||
enum Type {
|
||||
MissingField,
|
||||
IncorrectType,
|
||||
IncorrectId,
|
||||
} type;
|
||||
|
||||
Error(std::string const & path, Type type)
|
||||
: path(path), type(type) {}
|
||||
|
||||
bool operator==(const Error& other) const {
|
||||
return type == other.type && path == other.path;
|
||||
}
|
||||
|
||||
std::ostream& dump(std::ostream& os) const {
|
||||
os << "Error(path=" << (path.empty() ? "<root>" : path) << ": ";
|
||||
|
||||
switch(type) {
|
||||
case MissingField: os << "missing"; break;
|
||||
case IncorrectType: os << "incorrect type"; break;
|
||||
case IncorrectId: os << "incorrect ID"; break;
|
||||
}
|
||||
os << ")";
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
epics::pvData::FieldConstPtr field;
|
||||
std::string path;
|
||||
std::vector<Error> errors;
|
||||
|
||||
enum result_t {
|
||||
Pass,
|
||||
Fail,
|
||||
} result;
|
||||
|
||||
Result(const epics::pvData::FieldConstPtr& field, const std::string& path = std::string())
|
||||
: field(field), path(path), errors(), result(Pass) {}
|
||||
|
||||
Result() {}
|
||||
|
||||
Result& operator|=(const Result& other) {
|
||||
result = std::max(result, other.result);
|
||||
errors.insert(errors.end(), other.errors.begin(), other.errors.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this Result is valid.
|
||||
*
|
||||
* @return true if all tests passed, false otherwise.
|
||||
*/
|
||||
inline bool valid(void) const {
|
||||
return result == Pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that this Result's field is of a particular type 'T'.
|
||||
*
|
||||
* Appends an Error::Type::IncorrectType if the field is not of type 'T'.
|
||||
*
|
||||
* @return itself
|
||||
*/
|
||||
template<typename T>
|
||||
Result& is(void) {
|
||||
if (!dynamic_cast<T const *>(field.get())) {
|
||||
result = Fail;
|
||||
errors.push_back(Error(path, Error::IncorrectType));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that this Result's field is of a particular type 'T' and has
|
||||
* an ID equal to 'id'.
|
||||
*
|
||||
* Appends an Error::Type::IncorrectType if the field is not of type 'T'.
|
||||
* Appends an Error::Type::IncorrectId if the field does not have an ID
|
||||
* equal to 'id'.
|
||||
*
|
||||
* @return itself
|
||||
*/
|
||||
template<typename T>
|
||||
Result& is(const std::string& id) {
|
||||
T const *s = dynamic_cast<T const *>(field.get());
|
||||
if (!s) {
|
||||
result = Fail;
|
||||
errors.push_back(Error(path, Error::IncorrectType));
|
||||
} else if (s->getID() != id) {
|
||||
result = Fail;
|
||||
errors.push_back(Error(path, Error::IncorrectId));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that this Result's field has a subfield with name 'name' and
|
||||
* apply the function 'fn' to the subfield.
|
||||
*
|
||||
* Appends an Error::Type::IncorrectType if the field is not one of
|
||||
* Structure, StructureArray, Union, UnionArray.
|
||||
* Appends an Error::Type::MissingField if the subfield is not
|
||||
* present.
|
||||
*
|
||||
* @return itself
|
||||
*/
|
||||
template<Result& (*fn)(Result&)>
|
||||
Result& has(const std::string& name) {
|
||||
return has<epics::pvData::Field>(name, false, fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that this Result's field has an optional subfield with name
|
||||
* 'name' and, if it has, apply the function 'fn' to the subfield.
|
||||
*
|
||||
* Appends an Error::Type::IncorrectType if the field is not one of
|
||||
* Structure, StructureArray, Union, UnionArray.
|
||||
*
|
||||
* @return itself
|
||||
*/
|
||||
template<Result& (*fn)(Result&)>
|
||||
Result& maybeHas(const std::string& name) {
|
||||
return has<epics::pvData::Field>(name, true, fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that this Result's field has a subfield with name 'name',
|
||||
* apply the function 'fn' to the subfield and
|
||||
* test that the subfield is of type 'T'.
|
||||
*
|
||||
* Appends an Error::Type::IncorrectType if the field is not one of
|
||||
* Structure, StructureArray, Union, UnionArray.
|
||||
* Appends an Error::Type::IncorrectType if the subfield is not of
|
||||
* type 'T'.
|
||||
* Appends an Error::Type::MissingField if the subfield is not
|
||||
* present.
|
||||
*
|
||||
* @return itself
|
||||
*/
|
||||
template<Result& (*fn)(Result&), typename T>
|
||||
Result& has(const std::string& name) {
|
||||
return has<T>(name, false, fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that this Result's field has an optional subfield with name
|
||||
* 'name' and, if it has, apply the function 'fn' to the subfield and
|
||||
* test that the subfield is of type 'T'.
|
||||
*
|
||||
* Appends an Error::Type::IncorrectType if the field is not one of
|
||||
* Structure, StructureArray, Union, UnionArray.
|
||||
* Appends an Error::Type::IncorrectType if the subfield exists and
|
||||
* is not of type 'T'.
|
||||
*
|
||||
* @return itself
|
||||
*/
|
||||
template<Result& (*fn)(Result&), typename T>
|
||||
Result& maybeHas(const std::string& name) {
|
||||
return has<T>(name, true, fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that this Result's field has a subfield with name 'name' and
|
||||
* test that the subfield is of type 'T'.
|
||||
*
|
||||
* Appends an Error::Type::IncorrectType if the field is not one of
|
||||
* Structure, StructureArray, Union, UnionArray.
|
||||
* Appends an Error::Type::IncorrectType if the subfield is not of
|
||||
* type 'T'.
|
||||
* Appends an Error::Type::MissingField if the subfield is not
|
||||
* present.
|
||||
*
|
||||
* @return itself
|
||||
*/
|
||||
template<typename T>
|
||||
Result& has(const std::string& name) {
|
||||
return has<T>(name, false, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that this Result's field has an optional subfield with name
|
||||
* 'name' and, if it has, test that the subfield is of type 'T'.
|
||||
*
|
||||
* Appends an Error::Type::IncorrectType if the field is not one of
|
||||
* Structure, StructureArray, Union, UnionArray.
|
||||
* Appends an Error::Type::IncorrectType if the subfield exists and
|
||||
* is not of type 'T'.
|
||||
*
|
||||
* @return itself
|
||||
*/
|
||||
template<typename T>
|
||||
Result& maybeHas(const std::string& name) {
|
||||
return has<T>(name, true, NULL);
|
||||
}
|
||||
|
||||
std::ostream& dump(std::ostream& os) const {
|
||||
os << "Result(valid=" << (result == Pass) << ", errors=[ ";
|
||||
|
||||
std::vector<Error>::const_iterator it;
|
||||
for (it = errors.begin(); it != errors.end(); ++it) {
|
||||
(*it).dump(os);
|
||||
os << " ";
|
||||
}
|
||||
os << "])";
|
||||
return os;
|
||||
}
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
Result& has(const std::string& name, bool optional, Result& (*check)(Result&) = NULL) {
|
||||
epics::pvData::FieldConstPtr subField;
|
||||
|
||||
switch(field->getType()) {
|
||||
case epics::pvData::structure:
|
||||
subField = static_cast<epics::pvData::Structure const *>(field.get())->getField(name);
|
||||
break;
|
||||
case epics::pvData::structureArray:
|
||||
subField = static_cast<epics::pvData::StructureArray const *>(field.get())->getStructure()->getField(name);
|
||||
break;
|
||||
case epics::pvData::union_:
|
||||
subField = static_cast<epics::pvData::Union const *>(field.get())->getField(name);
|
||||
break;
|
||||
case epics::pvData::unionArray:
|
||||
subField = static_cast<epics::pvData::UnionArray const *>(field.get())->getUnion()->getField(name);
|
||||
break;
|
||||
default:
|
||||
// Expected a structure-like Field
|
||||
result = Fail;
|
||||
errors.push_back(Error(path, Error::IncorrectType));
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string subFieldPath(path.empty() ? name : path + "." + name);
|
||||
|
||||
if (!subField) {
|
||||
if (!optional) {
|
||||
result = Fail;
|
||||
errors.push_back(Error(subFieldPath, Error::MissingField));
|
||||
}
|
||||
} else if (!dynamic_cast<T const *>(subField.get())) {
|
||||
result = Fail;
|
||||
errors.push_back(Error(subFieldPath, Error::IncorrectType));
|
||||
} else if (check) {
|
||||
Result r(subField, subFieldPath);
|
||||
*this |= check(r);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,84 @@
|
||||
TOP = ..
|
||||
include $(TOP)/configure/CONFIG
|
||||
DIRS += nt
|
||||
include $(TOP)/configure/RULES_DIRS
|
||||
TOP=..
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
PROD_LIBS += nt pvData Com
|
||||
|
||||
TESTPROD_HOST += ntfieldTest
|
||||
ntfieldTest_SRCS += ntfieldTest.cpp
|
||||
TESTS += ntfieldTest
|
||||
|
||||
TESTPROD_HOST += ntscalarTest
|
||||
ntscalarTest_SRCS += ntscalarTest.cpp
|
||||
TESTS += ntscalarTest
|
||||
|
||||
TESTPROD_HOST += ntscalarArrayTest
|
||||
ntscalarArrayTest_SRCS += ntscalarArrayTest.cpp
|
||||
TESTS += ntscalarArrayTest
|
||||
|
||||
TESTPROD_HOST += ntnameValueTest
|
||||
ntnameValueTest_SRCS += ntnameValueTest.cpp
|
||||
TESTS += ntnameValueTest
|
||||
|
||||
TESTPROD_HOST += ntmultiChannelTest
|
||||
ntmultiChannelTest_SRCS += ntmultiChannelTest.cpp
|
||||
TESTS += ntmultiChannelTest
|
||||
|
||||
TESTPROD_HOST += ntscalarMultiChannelTest
|
||||
ntscalarMultiChannelTest_SRCS += ntscalarMultiChannelTest.cpp
|
||||
TESTS += ntscalarMultiChannelTest
|
||||
|
||||
TESTPROD_HOST += nttableTest
|
||||
nttableTest_SRCS = nttableTest.cpp
|
||||
TESTS += nttableTest
|
||||
|
||||
TESTPROD_HOST += ntndarrayTest
|
||||
ntndarrayTest_SRCS = ntndarrayTest.cpp
|
||||
TESTS += ntndarrayTest
|
||||
|
||||
TESTPROD_HOST += ntmatrixTest
|
||||
ntmatrixTest_SRCS = ntmatrixTest.cpp
|
||||
TESTS += ntmatrixTest
|
||||
|
||||
TESTPROD_HOST += ntenumTest
|
||||
ntenumTest_SRCS = ntenumTest.cpp
|
||||
TESTS += ntenumTest
|
||||
|
||||
TESTPROD_HOST += ntunionTest
|
||||
ntunionTest_SRCS = ntunionTest.cpp
|
||||
TESTS += ntunionTest
|
||||
|
||||
TESTPROD_HOST += ntaggregateTest
|
||||
ntaggregateTest_SRCS = ntaggregateTest.cpp
|
||||
TESTS += ntaggregateTest
|
||||
|
||||
TESTPROD_HOST += ntattributeTest
|
||||
ntattributeTest_SRCS = ntattributeTest.cpp
|
||||
TESTS += ntattributeTest
|
||||
|
||||
TESTPROD_HOST += ntndarrayAttributeTest
|
||||
ntndarrayAttributeTest_SRCS = ntndarrayAttributeTest.cpp
|
||||
TESTS += ntndarrayAttributeTest
|
||||
|
||||
TESTPROD_HOST += ntcontinuumTest
|
||||
ntcontinuumTest = ntcontinuumTest.cpp
|
||||
TESTS += ntcontinuumTest
|
||||
|
||||
TESTPROD_HOST += nthistogramTest
|
||||
nthistogramTest_SRCS = nthistogramTest.cpp
|
||||
TESTS += nthistogramTest
|
||||
|
||||
TESTPROD_HOST += ntutilsTest
|
||||
ntutilsTest_SRCS = ntutilsTest.cpp
|
||||
TESTS += ntutilsTest
|
||||
|
||||
TESTPROD_HOST += validatorTest
|
||||
validatorTest_SRCS = validatorTest.cpp
|
||||
TESTS += validatorTest
|
||||
|
||||
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
TOP=../..
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
PROD_LIBS += nt pvData Com
|
||||
|
||||
TESTPROD_HOST += ntfieldTest
|
||||
ntfieldTest_SRCS += ntfieldTest.cpp
|
||||
TESTS += ntfieldTest
|
||||
|
||||
TESTPROD_HOST += ntscalarTest
|
||||
ntscalarTest_SRCS += ntscalarTest.cpp
|
||||
TESTS += ntscalarTest
|
||||
|
||||
TESTPROD_HOST += ntscalarArrayTest
|
||||
ntscalarArrayTest_SRCS += ntscalarArrayTest.cpp
|
||||
TESTS += ntscalarArrayTest
|
||||
|
||||
TESTPROD_HOST += ntnameValueTest
|
||||
ntnameValueTest_SRCS += ntnameValueTest.cpp
|
||||
TESTS += ntnameValueTest
|
||||
|
||||
TESTPROD_HOST += ntmultiChannelTest
|
||||
ntmultiChannelTest_SRCS += ntmultiChannelTest.cpp
|
||||
TESTS += ntmultiChannelTest
|
||||
|
||||
TESTPROD_HOST += ntscalarMultiChannelTest
|
||||
ntscalarMultiChannelTest_SRCS += ntscalarMultiChannelTest.cpp
|
||||
TESTS += ntscalarMultiChannelTest
|
||||
|
||||
TESTPROD_HOST += nttableTest
|
||||
nttableTest_SRCS = nttableTest.cpp
|
||||
TESTS += nttableTest
|
||||
|
||||
TESTPROD_HOST += ntndarrayTest
|
||||
ntndarrayTest_SRCS = ntndarrayTest.cpp
|
||||
TESTS += ntndarrayTest
|
||||
|
||||
TESTPROD_HOST += ntmatrixTest
|
||||
ntmatrixTest_SRCS = ntmatrixTest.cpp
|
||||
TESTS += ntmatrixTest
|
||||
|
||||
TESTPROD_HOST += ntenumTest
|
||||
ntenumTest_SRCS = ntenumTest.cpp
|
||||
TESTS += ntenumTest
|
||||
|
||||
TESTPROD_HOST += ntunionTest
|
||||
ntunionTest_SRCS = ntunionTest.cpp
|
||||
TESTS += ntunionTest
|
||||
|
||||
TESTPROD_HOST += ntaggregateTest
|
||||
ntaggregateTest_SRCS = ntaggregateTest.cpp
|
||||
TESTS += ntaggregateTest
|
||||
|
||||
TESTPROD_HOST += ntattributeTest
|
||||
ntattributeTest_SRCS = ntattributeTest.cpp
|
||||
TESTS += ntattributeTest
|
||||
|
||||
TESTPROD_HOST += ntndarrayAttributeTest
|
||||
ntndarrayAttributeTest_SRCS = ntndarrayAttributeTest.cpp
|
||||
TESTS += ntndarrayAttributeTest
|
||||
|
||||
TESTPROD_HOST += ntcontinuumTest
|
||||
ntattributeTest_SRCS = ntcontinuumTest.cpp
|
||||
TESTS += ntcontinuumTest
|
||||
|
||||
TESTPROD_HOST += nthistogramTest
|
||||
ntattributeTest_SRCS = nthistogramTest.cpp
|
||||
TESTS += nthistogramTest
|
||||
|
||||
TESTPROD_HOST += ntutilsTest
|
||||
ntutilsTest_SRCS = ntutilsTest.cpp
|
||||
TESTS += ntutilsTest
|
||||
|
||||
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -66,6 +65,9 @@ void test_ntaggregate()
|
||||
create();
|
||||
testOk1(ntAggregate.get() != 0);
|
||||
|
||||
testOk1(NTAggregate::is_a(ntAggregate->getPVStructure()));
|
||||
testOk1(NTAggregate::isCompatible(ntAggregate->getPVStructure()));
|
||||
|
||||
testOk1(ntAggregate->getPVStructure().get() != 0);
|
||||
testOk1(ntAggregate->getValue().get() != 0);
|
||||
testOk1(ntAggregate->getDescriptor().get() != 0);
|
||||
@@ -76,7 +78,7 @@ void test_ntaggregate()
|
||||
// example how to set a value
|
||||
//
|
||||
ntAggregate->getValue()->put(1.0);
|
||||
|
||||
|
||||
//
|
||||
// example how to get a value
|
||||
//
|
||||
@@ -165,11 +167,9 @@ void test_wrap()
|
||||
}
|
||||
|
||||
MAIN(testNTAggregate) {
|
||||
testPlan(28);
|
||||
testPlan(30);
|
||||
test_builder();
|
||||
test_ntaggregate();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#include <epicsUnitTest.h>
|
||||
#include <testMain.h>
|
||||
@@ -76,6 +74,9 @@ void test_ntattribute()
|
||||
create();
|
||||
testOk1(ntAttribute.get() != 0);
|
||||
|
||||
testOk1(NTAttribute::is_a(ntAttribute->getPVStructure()));
|
||||
testOk1(NTAttribute::isCompatible(ntAttribute->getPVStructure()));
|
||||
|
||||
testOk1(ntAttribute->getPVStructure().get() != 0);
|
||||
testOk1(ntAttribute->getName().get() != 0);
|
||||
testOk1(ntAttribute->getValue().get() != 0);
|
||||
@@ -166,11 +167,9 @@ void test_wrap()
|
||||
}
|
||||
|
||||
MAIN(testNTAttribute) {
|
||||
testPlan(33);
|
||||
testPlan(35);
|
||||
test_builder();
|
||||
test_ntattribute();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -72,6 +71,9 @@ void test_ntcontinuum()
|
||||
create();
|
||||
testOk1(ntContinuum.get() != 0);
|
||||
|
||||
testOk1(NTContinuum::is_a(ntContinuum->getPVStructure()));
|
||||
testOk1(NTContinuum::isCompatible(ntContinuum->getPVStructure()));
|
||||
|
||||
testOk1(ntContinuum->getPVStructure().get() != 0);
|
||||
testOk1(ntContinuum->getDescriptor().get() != 0);
|
||||
testOk1(ntContinuum->getAlarm().get() != 0);
|
||||
@@ -265,12 +267,10 @@ void test_extra()
|
||||
|
||||
|
||||
MAIN(testNTContinuum) {
|
||||
testPlan(59);
|
||||
testPlan(61);
|
||||
test_builder();
|
||||
test_ntcontinuum();
|
||||
test_wrap();
|
||||
test_extra();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
#include <testMain.h>
|
||||
|
||||
@@ -67,6 +65,9 @@ void test_ntenum()
|
||||
create();
|
||||
testOk1(ntEnum.get() != 0);
|
||||
|
||||
testOk1(NTEnum::is_a(ntEnum->getPVStructure()));
|
||||
testOk1(NTEnum::isCompatible(ntEnum->getPVStructure()));
|
||||
|
||||
testOk1(ntEnum->getPVStructure().get() != 0);
|
||||
testOk1(ntEnum->getValue().get() != 0);
|
||||
testOk1(ntEnum->getDescriptor().get() != 0);
|
||||
@@ -83,7 +84,7 @@ void test_ntenum()
|
||||
choices[1] = "On";
|
||||
pvValue->getSubField<PVStringArray>("choices")->replace(freeze(choices));
|
||||
pvValue->getSubField<PVInt>("index")->put(1);
|
||||
|
||||
|
||||
//
|
||||
// example how to get a value
|
||||
//
|
||||
@@ -178,11 +179,9 @@ void test_wrap()
|
||||
}
|
||||
|
||||
MAIN(testNTEnum) {
|
||||
testPlan(30);
|
||||
testPlan(32);
|
||||
test_builder();
|
||||
test_ntenum();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
/*
|
||||
* ntfieldTest.cpp
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -84,6 +83,9 @@ void test_nthistogram()
|
||||
create();
|
||||
testOk1(ntHistogram.get() != 0);
|
||||
|
||||
testOk1(NTHistogram::is_a(ntHistogram->getPVStructure()));
|
||||
testOk1(NTHistogram::isCompatible(ntHistogram->getPVStructure()));
|
||||
|
||||
testOk1(ntHistogram->getPVStructure().get() != 0);
|
||||
testOk1(ntHistogram->getDescriptor().get() != 0);
|
||||
testOk1(ntHistogram->getAlarm().get() != 0);
|
||||
@@ -250,12 +252,10 @@ void test_extra()
|
||||
|
||||
|
||||
MAIN(testNTHistogram) {
|
||||
testPlan(50);
|
||||
testPlan(52);
|
||||
test_builder();
|
||||
test_nthistogram();
|
||||
test_wrap();
|
||||
test_extra();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
#include <testMain.h>
|
||||
|
||||
@@ -59,7 +57,7 @@ void test_ntmatrix()
|
||||
NTMatrixBuilderPtr builder = NTMatrix::createBuilder();
|
||||
testOk(builder.get() != 0, "Got builder");
|
||||
|
||||
NTMatrixPtr ntScalarArray = builder->
|
||||
NTMatrixPtr ntMatrix = builder->
|
||||
//arrayValue(pvInt)->
|
||||
addDim()->
|
||||
addDescriptor()->
|
||||
@@ -67,15 +65,18 @@ void test_ntmatrix()
|
||||
addTimeStamp()->
|
||||
addDisplay()->
|
||||
create();
|
||||
testOk1(ntScalarArray.get() != 0);
|
||||
testOk1(ntMatrix.get() != 0);
|
||||
|
||||
testOk1(ntScalarArray->getPVStructure().get() != 0);
|
||||
testOk1(ntScalarArray->getValue().get() != 0);
|
||||
testOk1(ntScalarArray->getDim().get() != 0);
|
||||
testOk1(ntScalarArray->getDescriptor().get() != 0);
|
||||
testOk1(ntScalarArray->getAlarm().get() != 0);
|
||||
testOk1(ntScalarArray->getTimeStamp().get() != 0);
|
||||
testOk1(ntScalarArray->getDisplay().get() != 0);
|
||||
testOk1(NTMatrix::is_a(ntMatrix->getPVStructure()));
|
||||
testOk1(NTMatrix::isCompatible(ntMatrix->getPVStructure()));
|
||||
|
||||
testOk1(ntMatrix->getPVStructure().get() != 0);
|
||||
testOk1(ntMatrix->getValue().get() != 0);
|
||||
testOk1(ntMatrix->getDim().get() != 0);
|
||||
testOk1(ntMatrix->getDescriptor().get() != 0);
|
||||
testOk1(ntMatrix->getAlarm().get() != 0);
|
||||
testOk1(ntMatrix->getTimeStamp().get() != 0);
|
||||
testOk1(ntMatrix->getDisplay().get() != 0);
|
||||
|
||||
//
|
||||
// example how to set values
|
||||
@@ -85,7 +86,7 @@ void test_ntmatrix()
|
||||
newValues.push_back(2.0);
|
||||
newValues.push_back(8.0);
|
||||
|
||||
PVDoubleArrayPtr pvValueField = ntScalarArray->getValue();
|
||||
PVDoubleArrayPtr pvValueField = ntMatrix->getValue();
|
||||
pvValueField->replace(freeze(newValues));
|
||||
|
||||
//
|
||||
@@ -102,7 +103,7 @@ void test_ntmatrix()
|
||||
// timeStamp ops
|
||||
//
|
||||
PVTimeStamp pvTimeStamp;
|
||||
if (ntScalarArray->attachTimeStamp(pvTimeStamp))
|
||||
if (ntMatrix->attachTimeStamp(pvTimeStamp))
|
||||
{
|
||||
testPass("timeStamp attach");
|
||||
|
||||
@@ -123,7 +124,7 @@ void test_ntmatrix()
|
||||
// alarm ops
|
||||
//
|
||||
PVAlarm pvAlarm;
|
||||
if (ntScalarArray->attachAlarm(pvAlarm))
|
||||
if (ntMatrix->attachAlarm(pvAlarm))
|
||||
{
|
||||
testPass("alarm attach");
|
||||
|
||||
@@ -141,7 +142,7 @@ void test_ntmatrix()
|
||||
// display ops
|
||||
//
|
||||
PVDisplay pvDisplay;
|
||||
if (ntScalarArray->attachDisplay(pvDisplay))
|
||||
if (ntMatrix->attachDisplay(pvDisplay))
|
||||
{
|
||||
testPass("display attach");
|
||||
|
||||
@@ -150,7 +151,6 @@ void test_ntmatrix()
|
||||
display.setLow(-15);
|
||||
display.setHigh(15);
|
||||
display.setDescription("This is a test scalar array");
|
||||
display.setFormat("%d");
|
||||
display.setUnits("A");
|
||||
pvDisplay.set(display);
|
||||
}
|
||||
@@ -160,10 +160,10 @@ void test_ntmatrix()
|
||||
//
|
||||
// set descriptor
|
||||
//
|
||||
ntScalarArray->getDescriptor()->put("This is a test NTMatrix");
|
||||
ntMatrix->getDescriptor()->put("This is a test NTMatrix");
|
||||
|
||||
// dump ntScalarArray
|
||||
std::cout << *ntScalarArray->getPVStructure() << std::endl;
|
||||
// dump ntMatrix
|
||||
std::cout << *ntMatrix->getPVStructure() << std::endl;
|
||||
|
||||
}
|
||||
|
||||
@@ -201,11 +201,9 @@ void test_wrap()
|
||||
}
|
||||
|
||||
MAIN(testNTMatrix) {
|
||||
testPlan(36);
|
||||
testPlan(38);
|
||||
test_builder();
|
||||
test_ntmatrix();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
/*
|
||||
* ntmutiChannelTest.cpp
|
||||
@@ -54,6 +53,9 @@ static void test()
|
||||
create();
|
||||
testOk1(multiChannel.get() != 0);
|
||||
|
||||
testOk1(NTMultiChannel::is_a(multiChannel->getPVStructure()));
|
||||
testOk1(NTMultiChannel::isCompatible(multiChannel->getPVStructure()));
|
||||
|
||||
PVStructurePtr pvStructure = multiChannel->getPVStructure();
|
||||
testOk1(pvStructure.get()!=NULL);
|
||||
testOk1(NTMultiChannel::is_a(pvStructure->getStructure()));
|
||||
@@ -186,9 +188,8 @@ void test_wrap()
|
||||
|
||||
MAIN(testCreateRequest)
|
||||
{
|
||||
testPlan(25);
|
||||
testPlan(27);
|
||||
test();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -81,6 +80,9 @@ void test_ntnameValue()
|
||||
create();
|
||||
testOk1(ntNameValue.get() != 0);
|
||||
|
||||
testOk1(NTNameValue::is_a(ntNameValue->getPVStructure()));
|
||||
testOk1(NTNameValue::isCompatible(ntNameValue->getPVStructure()));
|
||||
|
||||
testOk1(ntNameValue->getPVStructure().get() != 0);
|
||||
testOk1(ntNameValue->getDescriptor().get() != 0);
|
||||
testOk1(ntNameValue->getAlarm().get() != 0);
|
||||
@@ -245,12 +247,10 @@ void test_extra()
|
||||
|
||||
|
||||
MAIN(testNTNameValue) {
|
||||
testPlan(48);
|
||||
testPlan(50);
|
||||
test_builder();
|
||||
test_ntnameValue();
|
||||
test_wrap();
|
||||
test_extra();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#include <epicsUnitTest.h>
|
||||
#include <testMain.h>
|
||||
@@ -76,6 +74,9 @@ void test_ntndarrayAttribute()
|
||||
create();
|
||||
testOk1(ntNDArrayAttribute.get() != 0);
|
||||
|
||||
testOk1(NTNDArrayAttribute::is_a(ntNDArrayAttribute->getPVStructure()));
|
||||
testOk1(NTNDArrayAttribute::isCompatible(ntNDArrayAttribute->getPVStructure()));
|
||||
|
||||
testOk1(ntNDArrayAttribute->getPVStructure().get() != 0);
|
||||
testOk1(ntNDArrayAttribute->getName().get() != 0);
|
||||
testOk1(ntNDArrayAttribute->getValue().get() != 0);
|
||||
@@ -168,11 +169,9 @@ void test_wrap()
|
||||
}
|
||||
|
||||
MAIN(testNTNDArrayAttribute) {
|
||||
testPlan(37);
|
||||
testPlan(39);
|
||||
test_builder();
|
||||
test_ntndarrayAttribute();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -22,8 +21,8 @@ void test_builder(bool extraFields)
|
||||
testOk(builder.get() != 0, "Got builder");
|
||||
|
||||
builder->addDescriptor()->
|
||||
addTimeStamp()->
|
||||
addAlarm()->
|
||||
addTimeStamp()->
|
||||
addAlarm()->
|
||||
addDisplay();
|
||||
|
||||
if (extraFields)
|
||||
@@ -69,13 +68,13 @@ void test_all()
|
||||
|
||||
PVStructurePtr pvStructure = builder->
|
||||
addDescriptor()->
|
||||
addTimeStamp()->
|
||||
addAlarm()->
|
||||
addDisplay()->
|
||||
addTimeStamp()->
|
||||
addAlarm()->
|
||||
addDisplay()->
|
||||
add("extra1",fieldCreate->createScalar(pvString)) ->
|
||||
add("extra2",fieldCreate->createScalarArray(pvString)) ->
|
||||
createPVStructure();
|
||||
std::cout << *pvStructure << std::endl;
|
||||
testOk1(NTNDArray::is_a(pvStructure)==true);
|
||||
testOk1(NTNDArray::isCompatible(pvStructure)==true);
|
||||
}
|
||||
|
||||
@@ -113,7 +112,7 @@ void test_wrap()
|
||||
}
|
||||
|
||||
MAIN(testNTNDArray) {
|
||||
testPlan(59);
|
||||
testPlan(60);
|
||||
test_builder(true);
|
||||
test_builder(false);
|
||||
test_builder(false); // called twice to test caching
|
||||
@@ -121,5 +120,3 @@ MAIN(testNTNDArray) {
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -23,7 +22,7 @@ void test_builder()
|
||||
testOk(builder.get() != 0, "Got builder");
|
||||
|
||||
StructureConstPtr structure = builder->
|
||||
arrayValue(pvDouble)->
|
||||
value(pvDouble)->
|
||||
addDescriptor()->
|
||||
addAlarm()->
|
||||
addTimeStamp()->
|
||||
@@ -75,7 +74,7 @@ void test_ntscalarArray()
|
||||
testOk(builder.get() != 0, "Got builder");
|
||||
|
||||
NTScalarArrayPtr ntScalarArray = builder->
|
||||
arrayValue(pvInt)->
|
||||
value(pvInt)->
|
||||
addDescriptor()->
|
||||
addAlarm()->
|
||||
addTimeStamp()->
|
||||
@@ -84,6 +83,9 @@ void test_ntscalarArray()
|
||||
create();
|
||||
testOk1(ntScalarArray.get() != 0);
|
||||
|
||||
testOk1(NTScalarArray::is_a(ntScalarArray->getPVStructure()));
|
||||
testOk1(NTScalarArray::isCompatible(ntScalarArray->getPVStructure()));
|
||||
|
||||
testOk1(ntScalarArray->getPVStructure().get() != 0);
|
||||
testOk1(ntScalarArray->getValue().get() != 0);
|
||||
testOk1(ntScalarArray->getDescriptor().get() != 0);
|
||||
@@ -165,7 +167,6 @@ void test_ntscalarArray()
|
||||
display.setLow(-15);
|
||||
display.setHigh(15);
|
||||
display.setDescription("This is a test scalar array");
|
||||
display.setFormat("%d");
|
||||
display.setUnits("A");
|
||||
pvDisplay.set(display);
|
||||
}
|
||||
@@ -220,7 +221,7 @@ void test_wrap()
|
||||
testOk(builder.get() != 0, "Got builder");
|
||||
|
||||
PVStructurePtr pvStructure = builder->
|
||||
arrayValue(pvDouble)->
|
||||
value(pvDouble)->
|
||||
createPVStructure();
|
||||
testOk1(pvStructure.get() != 0);
|
||||
if (!pvStructure)
|
||||
@@ -235,11 +236,9 @@ void test_wrap()
|
||||
}
|
||||
|
||||
MAIN(testNTScalarArray) {
|
||||
testPlan(38);
|
||||
testPlan(40);
|
||||
test_builder();
|
||||
test_ntscalarArray();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
/*
|
||||
* ntscalarMultiChannelTest.cpp
|
||||
@@ -54,6 +53,9 @@ static void test()
|
||||
create();
|
||||
testOk1(multiChannel.get() != 0);
|
||||
|
||||
testOk1(NTScalarMultiChannel::is_a(multiChannel->getPVStructure()));
|
||||
testOk1(NTScalarMultiChannel::isCompatible(multiChannel->getPVStructure()));
|
||||
|
||||
PVStructurePtr pvStructure = multiChannel->getPVStructure();
|
||||
testOk1(pvStructure.get()!=NULL);
|
||||
testOk1(NTScalarMultiChannel::is_a(pvStructure->getStructure()));
|
||||
@@ -173,9 +175,8 @@ void test_wrap()
|
||||
|
||||
MAIN(testCreateRequest)
|
||||
{
|
||||
testPlan(25);
|
||||
testPlan(27);
|
||||
test();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -86,6 +85,9 @@ void test_ntscalar()
|
||||
create();
|
||||
testOk1(ntScalar.get() != 0);
|
||||
|
||||
testOk1(NTScalar::is_a(ntScalar->getPVStructure()));
|
||||
testOk1(NTScalar::isCompatible(ntScalar->getPVStructure()));
|
||||
|
||||
testOk1(ntScalar->getPVStructure().get() != 0);
|
||||
testOk1(ntScalar->getValue().get() != 0);
|
||||
testOk1(ntScalar->getDescriptor().get() != 0);
|
||||
@@ -157,7 +159,6 @@ void test_ntscalar()
|
||||
display.setLow(-15);
|
||||
display.setHigh(15);
|
||||
display.setDescription("This is a test scalar");
|
||||
display.setFormat("%d");
|
||||
display.setUnits("A");
|
||||
pvDisplay.set(display);
|
||||
}
|
||||
@@ -226,11 +227,9 @@ void test_wrap()
|
||||
}
|
||||
|
||||
MAIN(testNTScalar) {
|
||||
testPlan(35);
|
||||
testPlan(37);
|
||||
test_builder();
|
||||
test_ntscalar();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -119,6 +118,9 @@ void test_nttable()
|
||||
create();
|
||||
testOk1(ntTable.get() != 0);
|
||||
|
||||
testOk1(NTTable::is_a(ntTable->getPVStructure()));
|
||||
testOk1(NTTable::isCompatible(ntTable->getPVStructure()));
|
||||
|
||||
testOk1(ntTable->getPVStructure().get() != 0);
|
||||
testOk1(ntTable->getDescriptor().get() != 0);
|
||||
testOk1(ntTable->getAlarm().get() != 0);
|
||||
@@ -236,12 +238,10 @@ void test_wrap()
|
||||
}
|
||||
|
||||
MAIN(testNTTable) {
|
||||
testPlan(48);
|
||||
testPlan(50);
|
||||
test_builder();
|
||||
test_labels();
|
||||
test_nttable();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -48,7 +47,6 @@ void test_builder()
|
||||
testOk(valueField.get() != 0, "value is enum");
|
||||
|
||||
std::cout << *structure << std::endl;
|
||||
|
||||
}
|
||||
|
||||
void test_ntunion()
|
||||
@@ -65,6 +63,9 @@ void test_ntunion()
|
||||
create();
|
||||
testOk1(ntUnion.get() != 0);
|
||||
|
||||
testOk1(NTUnion::is_a(ntUnion->getPVStructure()));
|
||||
testOk1(NTUnion::isCompatible(ntUnion->getPVStructure()));
|
||||
|
||||
testOk1(ntUnion->getPVStructure().get() != 0);
|
||||
testOk1(ntUnion->getValue().get() != 0);
|
||||
testOk1(ntUnion->getDescriptor().get() != 0);
|
||||
@@ -156,12 +157,42 @@ void test_wrap()
|
||||
testOk(ptr.get() != 0, "wrapUnsafe OK");
|
||||
}
|
||||
|
||||
MAIN(testNTUnion) {
|
||||
testPlan(27);
|
||||
test_builder();
|
||||
test_ntunion();
|
||||
test_wrap();
|
||||
return testDone();
|
||||
|
||||
void test_variant_union()
|
||||
{
|
||||
StructureConstPtr structure = NTUnion::createBuilder()->
|
||||
addDescriptor()->
|
||||
addAlarm()->
|
||||
addTimeStamp()->
|
||||
createStructure();
|
||||
testOk1(structure->getField<Union>("value")->isVariant());
|
||||
}
|
||||
|
||||
void test_regular_union()
|
||||
{
|
||||
UnionConstPtr u = getFieldCreate()->createFieldBuilder()->
|
||||
add("x", pvDouble)->
|
||||
add("i", pvInt)->
|
||||
createUnion();
|
||||
|
||||
StructureConstPtr structure = NTUnion::createBuilder()->
|
||||
value(u)->
|
||||
addDescriptor()->
|
||||
addAlarm()->
|
||||
addTimeStamp()->
|
||||
createStructure();
|
||||
testOk1(!structure->getField<Union>("value")->isVariant());
|
||||
testOk1(structure->getField<Union>("value") == u);
|
||||
}
|
||||
|
||||
|
||||
|
||||
MAIN(testNTUnion) {
|
||||
testPlan(32);
|
||||
test_builder();
|
||||
test_ntunion();
|
||||
test_wrap();
|
||||
test_variant_union();
|
||||
test_regular_union();
|
||||
return testDone();
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* This software is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
@@ -34,5 +33,3 @@ MAIN(testNTUtils) {
|
||||
test_is_a();
|
||||
return testDone();
|
||||
}
|
||||
|
||||
|
||||
311
test/validatorTest.cpp
Normal file
311
test/validatorTest.cpp
Normal file
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright information and license terms for this software can be
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include <epicsUnitTest.h>
|
||||
#include <testMain.h>
|
||||
|
||||
#include "../src/validator.h"
|
||||
#include <pv/ntndarray.h>
|
||||
#include <pv/pvIntrospect.h>
|
||||
|
||||
using namespace epics::nt;
|
||||
using namespace epics::pvData;
|
||||
|
||||
static epics::pvData::FieldCreatePtr FC;
|
||||
|
||||
void test_is()
|
||||
{
|
||||
testDiag("test_is");
|
||||
|
||||
// Result::is<Scalar> must be valid for Scalars of any type
|
||||
for(int i = pvBoolean; i <= pvString; ++i) {
|
||||
ScalarType t = static_cast<ScalarType>(i);
|
||||
testOk(Result(FC->createScalar(t)).is<Scalar>().valid(),
|
||||
"Result(Scalar<%s>).is<Scalar>().valid()", ScalarTypeFunc::name(t));
|
||||
}
|
||||
|
||||
// Result::is<ScalarArray> must be valid for ScalarArray of any type
|
||||
for(int i = pvBoolean; i <= pvString; ++i) {
|
||||
ScalarType t = static_cast<ScalarType>(i);
|
||||
testOk(Result(FC->createScalarArray(t)).is<ScalarArray>().valid(),
|
||||
"Result(ScalarArray<%s>).is<ScalarArray>().valid()", ScalarTypeFunc::name(t));
|
||||
}
|
||||
|
||||
{
|
||||
// Result::is<Scalar> must be invalid for non-Scalar
|
||||
Result result(FC->createScalarArray(pvInt));
|
||||
result.is<Scalar>();
|
||||
testOk(!result.valid(), "!Result(ScalarArray<pvInt>).is<Scalar>.valid()");
|
||||
testOk1(result.errors.at(0) == Result::Error("", Result::Error::IncorrectType));
|
||||
}
|
||||
|
||||
{
|
||||
// Result::is<ScalarArray> must be invalid for non-ScalarArray
|
||||
Result result(FC->createScalar(pvInt));
|
||||
result.is<ScalarArray>();
|
||||
testOk(!result.valid(), "!Result(ScalarArray<pvInt>).is<Scalar>.valid()");
|
||||
testOk1(result.errors.at(0) == Result::Error("", Result::Error::IncorrectType));
|
||||
}
|
||||
}
|
||||
|
||||
void test_is_id()
|
||||
{
|
||||
testDiag("test_is_id");
|
||||
|
||||
FieldBuilderPtr FB(FieldBuilder::begin());
|
||||
|
||||
{
|
||||
// Both type and ID match for Structure
|
||||
Result result(FB->setId("TEST_ID")->createStructure());
|
||||
result.is<Structure>("TEST_ID");
|
||||
testOk(result.valid(), "Result(Structure['TEST_ID']).is<Structure>('TEST_ID').valid()");
|
||||
}
|
||||
|
||||
{
|
||||
// Both type and ID match for Union
|
||||
UnionConstPtr un(FB->
|
||||
setId("TEST_ID")->
|
||||
add("A", pvInt)->
|
||||
add("B", pvString)->
|
||||
createUnion()
|
||||
);
|
||||
Result result(un);
|
||||
result.is<Union>("TEST_ID");
|
||||
testOk(result.valid(), "Result(Union{A:int,B:string}['TEST_ID']).is<Union>('TEST_ID').valid()");
|
||||
}
|
||||
|
||||
{
|
||||
// Both type and ID match for Variant Union
|
||||
Result result(FB-> createUnion());
|
||||
result.is<Union>(Union::ANY_ID);
|
||||
testOk(result.valid(), "Result(Union).is<Union>('%s').valid()", Union::ANY_ID.c_str());
|
||||
}
|
||||
|
||||
{
|
||||
// ID matches, type doesn't
|
||||
Result result(FB->setId("TEST_ID")->createStructure());
|
||||
result.is<Union>("TEST_ID");
|
||||
testOk(!result.valid(), "!Result(Union['TEST_ID']).is<Structure>('TEST_ID').valid()");
|
||||
testOk1(result.errors.at(0) == Result::Error("", Result::Error::IncorrectType));
|
||||
}
|
||||
|
||||
{
|
||||
// Type matches, ID doesn't
|
||||
Result result(FB->setId("WRONG_ID")->createStructure());
|
||||
result.is<Structure>("TEST_ID");
|
||||
testOk(!result.valid(), "!Result(Structure['WRONG_ID']).is<Structure>('TEST_ID').valid()");
|
||||
testOk1(result.errors.at(0) == Result::Error("", Result::Error::IncorrectId));
|
||||
}
|
||||
|
||||
{
|
||||
// Neither type nor ID match (ID is not even checked in this case since it doesn't exist)
|
||||
Result result(FC->createScalar(pvDouble));
|
||||
result.is<Structure>("SOME_ID");
|
||||
testOk(!result.valid(), "!Result(Scalar).is<Structure>('SOME_ID').valid()");
|
||||
testOk1(result.errors.at(0) == Result::Error("", Result::Error::IncorrectType));
|
||||
}
|
||||
}
|
||||
|
||||
void test_has()
|
||||
{
|
||||
testDiag("test_has");
|
||||
|
||||
FieldBuilderPtr FB(FieldBuilder::begin());
|
||||
|
||||
StructureConstPtr struc(FB->
|
||||
add("A", pvInt)->
|
||||
add("B", pvString)->
|
||||
createStructure()
|
||||
);
|
||||
|
||||
std::string strucRepr("Structure{A:int,B:String}");
|
||||
|
||||
{
|
||||
// Test that struc has both A and B, both being Scalars
|
||||
Result result(struc);
|
||||
result
|
||||
.has<Scalar>("A")
|
||||
.has<Scalar>("B");
|
||||
|
||||
testOk(result.valid(),
|
||||
"Result(%s).has<Scalar>('A').has<Scalar>('B').valid()",
|
||||
strucRepr.c_str());
|
||||
}
|
||||
|
||||
{
|
||||
// Test that struc does not have a field B of type ScalarArray
|
||||
Result result(struc);
|
||||
result
|
||||
.has<Scalar>("A")
|
||||
.has<ScalarArray>("B");
|
||||
testOk(!result.valid(),
|
||||
"!Result(%s).has<Scalar>('A').has<ScalarArray>('B').valid()",
|
||||
strucRepr.c_str());
|
||||
testOk1(result.errors.at(0) == Result::Error("B", Result::Error::IncorrectType));
|
||||
}
|
||||
|
||||
{
|
||||
// Test that struc does not have a field C
|
||||
Result result(struc);
|
||||
result
|
||||
.has<Scalar>("A")
|
||||
.has<Scalar>("C");
|
||||
testOk(!result.valid(),
|
||||
"!Result(%s).has<Scalar>('A').has<Scalar>('C').valid()",
|
||||
strucRepr.c_str());
|
||||
testOk1(result.errors.at(0) == Result::Error("C", Result::Error::MissingField));
|
||||
}
|
||||
|
||||
{
|
||||
// Test that 'has' fails for non-structure-like Fields
|
||||
Result result(FC->createScalar(pvByte));
|
||||
result.has<Scalar>("X");
|
||||
testOk(!result.valid(), "!Result(Scalar<pvByte>).has<Scalar>('X').valid()");
|
||||
testOk1(result.errors.at(0) == Result::Error("", Result::Error::IncorrectType));
|
||||
}
|
||||
}
|
||||
|
||||
void test_maybe_has()
|
||||
{
|
||||
testDiag("test_maybe_has");
|
||||
|
||||
FieldBuilderPtr FB(FieldBuilder::begin());
|
||||
|
||||
StructureConstPtr struc(FB->
|
||||
add("A", pvInt)->
|
||||
add("B", pvString)->
|
||||
createStructure()
|
||||
);
|
||||
|
||||
std::string strucRepr("Structure{A:int,B:String}");
|
||||
|
||||
{
|
||||
// Test that struc maybe has A and B, both being Scalars
|
||||
Result result(struc);
|
||||
result
|
||||
.maybeHas<Scalar>("A")
|
||||
.maybeHas<Scalar>("B");
|
||||
|
||||
testOk(result.valid(),
|
||||
"Result(%s).maybeHas<Scalar>('A').maybeHas<Scalar>('B').valid()",
|
||||
strucRepr.c_str());
|
||||
}
|
||||
|
||||
{
|
||||
// Test that if struc has a field B, it must be of type ScalarArray
|
||||
Result result(struc);
|
||||
result
|
||||
.maybeHas<Scalar>("A")
|
||||
.maybeHas<ScalarArray>("B");
|
||||
testOk(!result.valid(),
|
||||
"!Result(%s).maybeHas<Scalar>('A').maybeHas<ScalarArray>('B').valid()",
|
||||
strucRepr.c_str());
|
||||
testOk1(result.errors.at(0) == Result::Error("B", Result::Error::IncorrectType));
|
||||
}
|
||||
|
||||
{
|
||||
// Test that struc maybe has A (which it does) and B (which it doesn't)
|
||||
Result result(struc);
|
||||
result
|
||||
.maybeHas<Scalar>("A")
|
||||
.maybeHas<Scalar>("C");
|
||||
testOk(result.valid(),
|
||||
"Result(%s).maybeHas<Scalar>('A').maybeHas<Scalar>('C').valid()",
|
||||
strucRepr.c_str());
|
||||
}
|
||||
|
||||
{
|
||||
// Test that 'maybeHas' fails for non-structure-like Fields
|
||||
Result result(FC->createScalar(pvByte));
|
||||
result.maybeHas<Scalar>("X");
|
||||
testOk(!result.valid(), "!Result(Scalar<pvByte>).maybeHas<Scalar>('X').valid()");
|
||||
testOk1(result.errors.at(0) == Result::Error("", Result::Error::IncorrectType));
|
||||
}
|
||||
}
|
||||
|
||||
Result& isStructABC(Result& result)
|
||||
{
|
||||
return result
|
||||
.is<Structure>("ABC")
|
||||
.has<Scalar>("A")
|
||||
.has<ScalarArray>("B")
|
||||
.maybeHas<Scalar>("C");
|
||||
}
|
||||
|
||||
void test_has_fn()
|
||||
{
|
||||
testDiag("test_has_fn");
|
||||
FieldBuilderPtr FB(FieldBuilder::begin());
|
||||
|
||||
{
|
||||
StructureConstPtr inner(FB->
|
||||
setId("ABC")->
|
||||
add("A", pvInt)->
|
||||
addArray("B", pvDouble)->
|
||||
add("C", pvString)->
|
||||
createStructure()
|
||||
);
|
||||
|
||||
Result result(FB->add("inner", inner)->createStructure());
|
||||
result.has<&isStructABC>("inner");
|
||||
|
||||
testOk(result.valid(), "Result({inner:<valid structABC>}).has<&isStructAbc>('inner').valid()");
|
||||
}
|
||||
|
||||
{
|
||||
StructureConstPtr inner(FB->
|
||||
setId("ABC")->
|
||||
add("A", pvInt)->
|
||||
addArray("B", pvDouble)->
|
||||
createStructure()
|
||||
);
|
||||
|
||||
Result result(FB->add("inner", inner)->createStructure());
|
||||
result.has<&isStructABC>("inner");
|
||||
|
||||
testOk(result.valid(), "Result({inner:<valid structABC w/o C>}).has<&isStructAbc>('inner').valid()");
|
||||
}
|
||||
|
||||
{
|
||||
StructureConstPtr inner(FB->
|
||||
setId("XYZ")->
|
||||
add("A", pvInt)->
|
||||
addArray("B", pvDouble)->
|
||||
createStructure()
|
||||
);
|
||||
|
||||
Result result(FB->add("inner", inner)->createStructure());
|
||||
result.has<&isStructABC>("inner");
|
||||
|
||||
testOk(!result.valid(), "!Result({inner:<structABC wrong id>}).has<&isStructAbc>('inner').valid()");
|
||||
testOk1(result.errors.at(0) == Result::Error("inner", Result::Error::IncorrectId));
|
||||
}
|
||||
|
||||
{
|
||||
StructureConstPtr inner(FB->
|
||||
setId("XYZ")->
|
||||
add("A", pvInt)->
|
||||
add("B", pvDouble)->
|
||||
createStructure()
|
||||
);
|
||||
|
||||
Result result(FB->add("inner", inner)->createStructure());
|
||||
result.has<&isStructABC>("inner");
|
||||
|
||||
testOk(!result.valid(), "!Result({inner:<structABC wrong id and fields>}).has<&isStructAbc>('inner').valid()");
|
||||
testOk1(result.errors.size() == 2);
|
||||
}
|
||||
}
|
||||
|
||||
MAIN(testValidator) {
|
||||
testPlan(56);
|
||||
FC = epics::pvData::getFieldCreate();
|
||||
test_is();
|
||||
test_is_id();
|
||||
test_has();
|
||||
test_maybe_has();
|
||||
test_has_fn();
|
||||
return testDone();
|
||||
}
|
||||
Reference in New Issue
Block a user