merge SF changes

This commit is contained in:
Ralph Lange
2013-02-26 17:22:16 +01:00
23 changed files with 344 additions and 89 deletions
+1 -3
View File
@@ -92,9 +92,7 @@ LIBSRCS += bitSetUtil.cpp
SRC_DIRS += $(PVDATA)/monitor
INC += monitor.h
LIBRARY=pvData
LIBRARY = pvData
pvData_LIBS += Com
include $(TOP)/configure/RULES
+1 -1
View File
@@ -2721,7 +2721,7 @@ void convertStructure(StringBuilder buffer,PVStructure const *data,int indentLev
}
}
void convertArray(StringBuilder buffer,PVScalarArray const * xxx,int indentLevel)
void convertArray(StringBuilder buffer,PVScalarArray const * xxx,int /*indentLevel*/)
{
PVScalarArray *pv = const_cast<PVScalarArray *>(xxx);
ScalarArrayConstPtr array = pv->getScalarArray();
+8 -8
View File
@@ -39,7 +39,7 @@ Field::~Field() {
}
void Field::toString(StringBuilder buffer,int indentLevel) const{
void Field::toString(StringBuilder /*buffer*/,int /*indentLevel*/) const{
}
@@ -54,7 +54,7 @@ struct ScalarArrayHashFunction {
};
struct StructureHashFunction {
size_t operator() (const Structure& structure) const { return 0; }
size_t operator() (const Structure& /*structure*/) const { return 0; }
// TODO
// final int PRIME = 31;
// return PRIME * Arrays.hashCode(fieldNames) + Arrays.hashCode(fields);
@@ -70,7 +70,7 @@ Scalar::Scalar(ScalarType scalarType)
Scalar::~Scalar(){}
void Scalar::toString(StringBuilder buffer,int indentLevel) const{
void Scalar::toString(StringBuilder buffer,int /*indentLevel*/) const{
*buffer += getID();
}
@@ -119,7 +119,7 @@ void Scalar::serialize(ByteBuffer *buffer, SerializableControl *control) const {
buffer->putByte(getTypeCodeLUT());
}
void Scalar::deserialize(ByteBuffer *buffer, DeserializableControl *control) {
void Scalar::deserialize(ByteBuffer */*buffer*/, DeserializableControl */*control*/) {
// must be done via FieldCreate
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
}
@@ -213,7 +213,7 @@ String ScalarArray::getID() const
return getIDScalarArrayLUT();
}
void ScalarArray::toString(StringBuilder buffer,int indentLevel) const{
void ScalarArray::toString(StringBuilder buffer,int /*indentLevel*/) const{
*buffer += getID();
}
@@ -222,7 +222,7 @@ void ScalarArray::serialize(ByteBuffer *buffer, SerializableControl *control) co
buffer->putByte(0x10 | getTypeCodeLUT());
}
void ScalarArray::deserialize(ByteBuffer *buffer, DeserializableControl *control) {
void ScalarArray::deserialize(ByteBuffer */*buffer*/, DeserializableControl */*control*/) {
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
}
@@ -252,7 +252,7 @@ void StructureArray::serialize(ByteBuffer *buffer, SerializableControl *control)
control->cachedSerialize(pstructure, buffer);
}
void StructureArray::deserialize(ByteBuffer *buffer, DeserializableControl *control) {
void StructureArray::deserialize(ByteBuffer */*buffer*/, DeserializableControl */*control*/) {
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
}
@@ -357,7 +357,7 @@ void Structure::serialize(ByteBuffer *buffer, SerializableControl *control) cons
serializeStructureField(this, buffer, control);
}
void Structure::deserialize(ByteBuffer *buffer, DeserializableControl *control) {
void Structure::deserialize(ByteBuffer */*buffer*/, DeserializableControl */*control*/) {
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
}
+5
View File
@@ -97,4 +97,9 @@ PVArray::~PVArray()
pImpl->capacity = capacity;
}
std::ostream& operator<<(format::array_at_internal const& manip, const PVArray& array)
{
return array.dumpValue(manip.stream, manip.index);
}
}}
+15 -15
View File
@@ -147,9 +147,9 @@ void BasePVString::serialize(ByteBuffer *pbuffer,
{
// check bounds
const size_t length = /*(value == null) ? 0 :*/ value.length();
if (offset < 0) offset = 0;
else if (offset > length) offset = length;
if (count < 0) count = length;
/*if (offset < 0) offset = 0;
else*/ if (offset > length) offset = length;
//if (count < 0) count = length;
const size_t maxCount = length - offset;
if (count > maxCount)
@@ -271,7 +271,7 @@ size_t DefaultPVArray<T>::get(size_t offset, size_t len, PVArrayData<T> &data)
size_t length = this->getLength();
if(offset+len > length) {
n = length-offset;
if(n<0) n = 0;
//if(n<0) n = 0;
}
data.data = *value.get();
data.offset = offset;
@@ -331,8 +331,8 @@ template<typename T>
void DefaultPVArray<T>::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol) {
size_t size = SerializeHelper::readSize(pbuffer, pcontrol);
// if (size>0) { pcontrol->ensureData(sizeof(T)-1); pbuffer->align(sizeof(T)); }
if(size>=0) {
// alignment if (size>0) { pcontrol->ensureData(sizeof(T)-1); pbuffer->align(sizeof(T)); }
//if(size>=0) {
// prepare array, if necessary
if(size>this->getCapacity()) this->setCapacity(size);
// set new length
@@ -356,7 +356,7 @@ void DefaultPVArray<T>::deserialize(ByteBuffer *pbuffer,
}
// inform about the change?
PVField::postPut();
}
//}
// TODO null arrays (size == -1) not supported
}
@@ -367,10 +367,10 @@ void DefaultPVArray<T>::serialize(ByteBuffer *pbuffer,
size_t length = this->getLength();
// check bounds
if(offset<0)
/*if(offset<0)
offset = 0;
else if(offset>length) offset = length;
if(count<0) count = length;
else*/ if(offset>length) offset = length;
//if(count<0) count = length;
size_t maxCount = length-offset;
if(count>maxCount) count = maxCount;
@@ -406,7 +406,7 @@ template<>
void DefaultPVArray<String>::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol) {
size_t size = SerializeHelper::readSize(pbuffer, pcontrol);
if(size>=0) {
//if(size>=0) {
// prepare array, if necessary
if(size>getCapacity()) setCapacity(size);
// set new length
@@ -419,7 +419,7 @@ void DefaultPVArray<String>::deserialize(ByteBuffer *pbuffer,
}
// inform about the change?
postPut();
}
//}
// TODO null arrays (size == -1) not supported
}
@@ -429,10 +429,10 @@ void DefaultPVArray<String>::serialize(ByteBuffer *pbuffer,
size_t length = getLength();
// check bounds
if(offset<0)
/*if(offset<0)
offset = 0;
else if(offset>length) offset = length;
if(count<0) count = length;
else*/ if(offset>length) offset = length;
//if(count<0) count = length;
size_t maxCount = length-offset;
if(count>maxCount) count = maxCount;
+26 -9
View File
@@ -194,17 +194,34 @@ void PVField::toString(StringBuilder buf,int indentLevel)
if(pvAuxInfo.get()!=NULL) pvAuxInfo->toString(buf,indentLevel);
}
std::ostream& PVField::dumpValue(std::ostream& o) const
std::ostream& operator<<(std::ostream& o, const PVField& f)
{
// default implementation
// each PVField class should implement it to avoid switch statement
// and string reallocation
String tmp;
convert->getString(&tmp,this,0);
return o << tmp;
}
std::ostream& ro = f.dumpValue(o);
// TODO I do not want to call getPVAuxInfo() since it lazily creates a new instance of it
//if (f.pvAuxInfo.get()!=NULL) ro << *(f.pvAuxInfo.get());
return ro;
};
std::ostream& operator<<(std::ostream& o, const PVField& f) { return f.dumpValue(o); };
namespace format
{
std::ostream& operator<<(std::ostream& os, indent_level const& indent)
{
indent_value(os) = indent.level;
return os;
}
std::ostream& operator<<(std::ostream& os, indent const&)
{
long il = indent_value(os);
std::size_t spaces = static_cast<std::size_t>(il) * 4;
return os << std::string(spaces, ' ');
}
array_at_internal operator<<(std::ostream& str, array_at const& manip)
{
return array_at_internal(manip.index, str);
}
};
void PVField::computeOffset(const PVField * pvField) {
const PVStructure * pvTop = pvField->getParent();
+27
View File
@@ -702,4 +702,31 @@ static PVFieldPtr findSubField(
return PVFieldPtr();
}
std::ostream& PVStructure::dumpValue(std::ostream& o) const
{
o << format::indent() << getStructure()->getID() << ' ' << getFieldName();
String extendsName = getExtendsStructureName();
if(extendsName.length()>0) {
o << " extends " << extendsName;
}
o << std::endl;
{
format::indent_scope s(o);
PVFieldPtrArray const & fieldsData = getPVFields();
if (fieldsData.size() != 0) {
size_t length = getStructure()->getNumberFields();
for(size_t i=0; i<length; i++) {
PVFieldPtr fieldField = fieldsData[i];
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
}
}
return o;
}
}}
+29 -6
View File
@@ -133,7 +133,7 @@ size_t PVStructureArray::get(
size_t length = getLength();
if(offset+len > length) {
n = length - offset;
if(n<0) n = 0;
//if(n<0) n = 0;
}
data.data = *value.get();
data.offset = offset;
@@ -197,7 +197,7 @@ void PVStructureArray::serialize(ByteBuffer *pbuffer,
void PVStructureArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol) {
size_t size = SerializeHelper::readSize(pbuffer, pcontrol);
if(size>=0) {
//if(size>=0) {
// prepare array, if necessary
if(size>getCapacity()) setCapacity(size);
setLength(size);
@@ -217,7 +217,7 @@ void PVStructureArray::deserialize(ByteBuffer *pbuffer,
}
}
postPut();
}
//}
}
void PVStructureArray::serialize(ByteBuffer *pbuffer,
@@ -226,10 +226,10 @@ void PVStructureArray::serialize(ByteBuffer *pbuffer,
size_t length = getLength();
// check bounds
if(offset<0)
/*if(offset<0)
offset = 0;
else if(offset>length) offset = length;
if(count<0) count = length;
else*/ if(offset>length) offset = length;
//if(count<0) count = length;
size_t maxCount = length-offset;
if(count>maxCount) count = maxCount;
@@ -250,4 +250,27 @@ void PVStructureArray::serialize(ByteBuffer *pbuffer,
}
}
std::ostream& PVStructureArray::dumpValue(std::ostream& o) const
{
o << format::indent() << getStructureArray()->getID() << ' ' << getFieldName() << std::endl;
size_t length = getLength();
if (length > 0)
{
format::indent_scope s(o);
for (size_t i = 0; i < length; i++)
dumpValue(o, i);
}
return o;
}
std::ostream& PVStructureArray::dumpValue(std::ostream& o, std::size_t index) const
{
PVStructurePtrArray pvArray = *value.get();
PVStructurePtr pvStructure = pvArray[index];
return o << *(pvStructure.get());
return o;
}
}}
+1 -1
View File
@@ -331,7 +331,7 @@ namespace epics { namespace pvData {
return !(*this == set);
}
void BitSet::toString(StringBuilder buffer, int indentLevel) const
void BitSet::toString(StringBuilder buffer, int /*indentLevel*/) const
{
*buffer += '{';
int32 i = nextSetBit(0);
+4 -4
View File
@@ -77,14 +77,14 @@ namespace epics {
void SerializeHelper::serializeSubstring(const String& value,
std::size_t offset, std::size_t count, ByteBuffer* buffer,
SerializableControl* flusher) {
if(offset<0)
/*if(offset<0)
offset = 0;
else if(offset>(std::size_t)value.length()) offset = value.length();
else*/ if(offset>value.length()) offset = value.length();
if(offset+count>(std::size_t)value.length()) count = value.length()-offset;
if(offset+count>value.length()) count = value.length()-offset;
SerializeHelper::writeSize(count, buffer, flusher);
if (count<=0) return;
/*if (count<=0)*/ return;
std::size_t i = 0;
while(true) {
std::size_t maxToWrite = min(count-i, buffer->getRemaining());
+1 -1
View File
@@ -117,7 +117,7 @@ String Status::toString() const
return str;
}
void Status::toString(StringBuilder buffer, int indentLevel) const
void Status::toString(StringBuilder buffer, int /*indentLevel*/) const
{
*buffer += "Status [type=";
*buffer += StatusTypeName[m_statusType];
+94 -6
View File
@@ -14,10 +14,74 @@
#include <stdexcept>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <pv/pvIntrospect.h>
#include <pv/requester.h>
namespace epics { namespace pvData {
namespace format {
struct indent_level
{
long level;
indent_level(long l) : level(l) {}
};
inline long& indent_value(std::ios_base& ios)
{
static int indent_index = std::ios_base::xalloc();
return ios.iword(indent_index);
}
std::ostream& operator<<(std::ostream& os, indent_level const& indent);
struct indent_scope
{
long saved_level;
std::ios_base& stream;
indent_scope(std::ios_base& ios) :
stream(ios)
{
long& l = indent_value(ios);
saved_level = l;
l = saved_level + 1;
}
~indent_scope()
{
indent_value(stream) = saved_level;
}
};
struct indent
{
};
std::ostream& operator<<(std::ostream& os, indent const&);
struct array_at
{
std::size_t index;
array_at(std::size_t ix) : index(ix) {}
};
struct array_at_internal
{
std::size_t index;
std::ostream& stream;
array_at_internal(std::size_t ix, std::ostream& str) : index(ix), stream(str) {}
};
array_at_internal operator<<(std::ostream& str, array_at const& manip);
};
class PVAuxInfo;
class PostHandler;
@@ -277,7 +341,7 @@ public:
* @param o output stream.
* @return The output stream.
*/
virtual std::ostream& dumpValue(std::ostream& o) const;
virtual std::ostream& dumpValue(std::ostream& o) const = 0;
protected:
PVField::shared_pointer getPtrSelf()
@@ -359,6 +423,20 @@ public:
return o << get();
}
// get operator
// double value; doubleField >>= value;
void operator>>=(T& value) const
{
value = get();
}
// put operator
// double value = 12.8; doubleField <<= value;
void operator<<=(T value)
{
put(value);
}
protected:
PVScalarValue(ScalarConstPtr const & scalar)
: PVScalar(scalar) {}
@@ -453,6 +531,9 @@ public:
* @param The capacity.
*/
virtual void setCapacity(std::size_t capacity) = 0;
virtual std::ostream& dumpValue(std::ostream& o, std::size_t index) const = 0;
protected:
PVArray(FieldConstPtr const & field);
void setCapacityLength(std::size_t capacity,std::size_t length);
@@ -461,6 +542,8 @@ private:
friend class PVDataCreate;
};
std::ostream& operator<<(format::array_at_internal const& manip, const PVArray& array);
/**
* Class provided by caller of get
*/
@@ -505,8 +588,6 @@ public:
*/
const ScalarArrayConstPtr getScalarArray() const ;
virtual std::ostream& dumpValue(std::ostream& o, size_t index) const = 0;
protected:
PVScalarArray(ScalarArrayConstPtr const & scalarArray);
private:
@@ -608,6 +689,10 @@ public:
virtual pointer get() const { return &((*value.get())[0]); }
virtual vector const & getVector() {return *value;}
virtual shared_vector const & getSharedVector() {return value;}
virtual std::ostream& dumpValue(std::ostream& o) const;
virtual std::ostream& dumpValue(std::ostream& o, std::size_t index) const;
protected:
PVStructureArray(StructureArrayConstPtr const & structureArray);
private:
@@ -816,6 +901,9 @@ public:
* @param pvFields The array of fields for the structure.
*/
PVStructure(StructureConstPtr const & structure,PVFieldPtrArray const & pvFields);
virtual std::ostream& dumpValue(std::ostream& o) const;
private:
void fixParentStructure();
static PVFieldPtr nullPVField;
@@ -896,7 +984,7 @@ public:
std::ostream& dumpValue(std::ostream& o) const
{
o << "[";
o << '[';
std::size_t len = getLength();
bool first = true;
for (std::size_t i = 0; i < len; i++)
@@ -904,10 +992,10 @@ public:
if (first)
first = false;
else
o << ",";
o << ',';
dumpValue(o, i);
}
return o << "]";
return o << ']';
}
std::ostream& dumpValue(std::ostream& o, size_t index) const
+1 -1
View File
@@ -24,7 +24,7 @@ testByteBuffer_LIBS += pvData Com
PROD_HOST += testBaseException
testBaseException_SRCS += testBaseException.cpp
testBaseException_LIBS += pvData
testBaseException_LIBS += pvData Com
PROD_HOST += testSerialization
testSerialization_SRCS += testSerialization.cpp
+2 -2
View File
@@ -27,11 +27,11 @@ struct Unroller
};
template<>
void Unroller::unroll<0>(double d) {
void Unroller::unroll<0>(double /*d*/) {
THROW_BASE_EXCEPTION("the root cause");
}
void internalTestBaseException(int unused = 0)
void internalTestBaseException(int /*unused*/ = 0)
{
try {
// NOTE: 5, 4, 3, 2, 1 calls will be optimized and not shown
+1 -1
View File
@@ -30,7 +30,7 @@
using namespace epics::pvData;
static void testBasic(FILE * fd,FILE *auxfd ) {
static void testBasic(FILE * fd,FILE */*auxfd*/) {
int queueSize = 3;
StringArray messages;
messages.reserve(5);
+20 -18
View File
@@ -24,22 +24,24 @@
#include <pv/standardField.h>
#define BYTE_MAX_VALUE 127
#define BYTE_MIN_VALUE -128
#define UBYTE_MAX_VALUE 255
#define SHORT_MAX_VALUE 32767
#define SHORT_MIN_VALUE -32768
#define USHORT_MAX_VALUE 65535
#define INT_MAX_VALUE 2147483647
#define INT_MIN_VALUE (-INT_MAX_VALUE - 1)
#define UINT_MAX_VALUE 4294967295ULL
#define LONG_MAX_VALUE 9223372036854775807LL
#define LONG_MIN_VALUE (-LONG_MAX_VALUE - 1LL)
#define ULONG_MAX_VALUE 18446744073709549999ULL
#define FLOAT_MAX_VALUE 3.4028235E38
#define FLOAT_MIN_VALUE 1.4E-45
#define DOUBLE_MAX_VALUE 1.7976931348623157E308
#define DOUBLE_MIN_VALUE 4.9E-324
#include <limits>
#define BYTE_MAX_VALUE std::numeric_limits<int8>::max()
#define BYTE_MIN_VALUE std::numeric_limits<int8>::min()
#define UBYTE_MAX_VALUE std::numeric_limits<uint8>::max()
#define SHORT_MAX_VALUE std::numeric_limits<int16>::max()
#define SHORT_MIN_VALUE std::numeric_limits<int16>::min()
#define USHORT_MAX_VALUE std::numeric_limits<uint16>::max()
#define INT_MAX_VALUE std::numeric_limits<int32>::max()
#define INT_MIN_VALUE std::numeric_limits<int32>::min()
#define UINT_MAX_VALUE std::numeric_limits<uint32>::max()
#define LONG_MAX_VALUE std::numeric_limits<int64>::max()
#define LONG_MIN_VALUE std::numeric_limits<int64>::min()
#define ULONG_MAX_VALUE std::numeric_limits<uint64>::max()
#define FLOAT_MAX_VALUE std::numeric_limits<float>::max()
#define FLOAT_MIN_VALUE std::numeric_limits<float>::min()
#define DOUBLE_MAX_VALUE std::numeric_limits<double>::max()
#define DOUBLE_MIN_VALUE std::numeric_limits<double>::min()
using namespace epics::pvData;
@@ -54,7 +56,7 @@ public:
virtual void flushSerializeBuffer() {
}
virtual void ensureBuffer(std::size_t size) {
virtual void ensureBuffer(std::size_t /*size*/) {
}
virtual void alignBuffer(std::size_t alignment) {
@@ -76,7 +78,7 @@ public:
class DeserializableControlImpl : public DeserializableControl,
public NoDefaultMethods {
public:
virtual void ensureData(size_t size) {
virtual void ensureData(size_t /*size*/) {
}
virtual void alignData(size_t alignment) {
+2 -2
View File
@@ -50,7 +50,7 @@ public:
printf("poll called\n");
return emptyElement;
}
virtual void release(MonitorElementPtr const & monitorElement)
virtual void release(MonitorElementPtr const & /*monitorElement*/)
{
printf("release called\n");
}
@@ -70,7 +70,7 @@ static void testMonitor()
}
int main(int argc,char *argv[])
int main(int, char **)
{
testMonitor();
return(0);
+6 -6
View File
@@ -48,7 +48,7 @@ static String allProperties("alarm,timeStamp,display,control");
static PVStructurePtr doubleRecord;
static PVStructurePtr enumeratedRecord;
static void createRecords(FILE * fd,FILE *auxfd)
static void createRecords(FILE * fd,FILE */*auxfd*/)
{
doubleRecord = standardPVField->scalar(pvDouble,allProperties);
if(debug) {
@@ -70,7 +70,7 @@ static void createRecords(FILE * fd,FILE *auxfd)
}
}
static void printRecords(FILE * fd,FILE *auxfd)
static void printRecords(FILE * fd,FILE */*auxfd*/)
{
fprintf(fd,"doubleRecord\n");
builder.clear();
@@ -82,7 +82,7 @@ static void printRecords(FILE * fd,FILE *auxfd)
fprintf(fd,"%s\n",builder.c_str());
}
static void testAlarm(FILE * fd,FILE *auxfd)
static void testAlarm(FILE * fd,FILE */*auxfd*/)
{
if(debug) fprintf(fd,"testAlarm\n");
Alarm alarm;
@@ -155,7 +155,7 @@ static void testTimeStamp(FILE * fd,FILE *auxfd)
fprintf(fd,"testTimeStamp PASSED\n");
}
static void testControl(FILE * fd,FILE *auxfd)
static void testControl(FILE * fd,FILE */*auxfd*/)
{
if(debug) fprintf(fd,"testControl\n");
Control control;
@@ -182,7 +182,7 @@ static void testControl(FILE * fd,FILE *auxfd)
fprintf(fd,"testControl PASSED\n");
}
static void testDisplay(FILE * fd,FILE *auxfd)
static void testDisplay(FILE * fd,FILE */*auxfd*/)
{
if(debug) fprintf(fd,"testDisplay\n");
Display display;
@@ -215,7 +215,7 @@ static void testDisplay(FILE * fd,FILE *auxfd)
fprintf(fd,"testDisplay PASSED\n");
}
static void testEnumerated(FILE * fd,FILE *auxfd)
static void testEnumerated(FILE * fd,FILE */*auxfd*/)
{
if(debug) fprintf(fd,"testEnumerated\n");
PVEnumerated pvEnumerated;
+4
View File
@@ -42,6 +42,10 @@ PROD_HOST += testPVStructureArray
testPVStructureArray_SRCS += testPVStructureArray.cpp
testPVStructureArray_LIBS += pvData Com
PROD_HOST += testOperators
testOperators_SRCS += testOperators.cpp
testOperators_LIBS += pvData Com
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE
+91
View File
@@ -0,0 +1,91 @@
/* testOperators.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/* Author: Matej Sekoranja Date: 2013.02 */
#include <iostream>
#include <pv/pvData.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <epicsAssert.h>
using namespace epics::pvData;
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
static StandardFieldPtr standardField = getStandardField();
static StandardPVFieldPtr standardPVField = getStandardPVField();
int main(int, char*)
{
PVStructurePtr pvStructure = standardPVField->scalar(pvDouble,
"alarm,timeStamp,display,control,valueAlarm");
const double testDV = 12.8;
PVDoublePtr pvValue = pvStructure->getDoubleField("value");
*pvValue <<= testDV;
double dv;
*pvValue >>= dv;
assert(testDV == dv);
const std::string testSV = "test message";
PVStringPtr pvMessage = pvStructure->getStringField("alarm.message");
*pvMessage <<= testSV;
std::string sv;
*pvMessage >>= sv;
assert(testSV == sv);
//
// to stream tests
//
std::cout << *pvValue << std::endl;
std::cout << *pvMessage << std::endl;
std::cout << *pvStructure << std::endl;
StringArray choices;
choices.reserve(3);
choices.push_back("one");
choices.push_back("two");
choices.push_back("three");
pvStructure = standardPVField->enumerated(choices, "alarm,timeStamp,valueAlarm");
std::cout << *pvStructure << std::endl;
pvStructure = standardPVField->scalarArray(pvDouble,"alarm,timeStamp");
std::cout << *pvStructure << std::endl;
double values[] = { 1.1, 2.2, 3.3 };
PVDoubleArrayPtr darray = std::tr1::dynamic_pointer_cast<PVDoubleArray>(pvStructure->getScalarArrayField("value", pvDouble));
darray->put(0, 3, values, 0);
std::cout << *darray << std::endl;
std::cout << format::array_at(1) << *darray << std::endl;
StructureConstPtr structure = standardField->scalar(pvDouble, "alarm,timeStamp");
pvStructure = standardPVField->structureArray(structure,"alarm,timeStamp");
size_t num = 2;
PVStructurePtrArray pvStructures;
pvStructures.reserve(num);
for(size_t i=0; i<num; i++) {
pvStructures.push_back(
pvDataCreate->createPVStructure(structure));
}
PVStructureArrayPtr pvStructureArray = pvStructure->getStructureArrayField("value");
pvStructureArray->put(0, num, pvStructures, 0);
std::cout << *pvStructure << std::endl;
return 0;
}
+3 -3
View File
@@ -77,7 +77,7 @@ static void testCreatePVStructure(FILE * fd)
fprintf(fd,"testCreatePVStructure PASSED\n");
}
static void testPVScalarCommon(FILE * fd,String fieldName,ScalarType stype)
static void testPVScalarCommon(FILE * fd,String /*fieldName*/,ScalarType stype)
{
PVScalarPtr pvScalar = pvDataCreate->createPVScalar(stype);
if(stype==pvBoolean) {
@@ -91,7 +91,7 @@ static void testPVScalarCommon(FILE * fd,String fieldName,ScalarType stype)
}
static void testPVScalarWithProperties(
FILE * fd,String fieldName,ScalarType stype)
FILE * fd,String /*fieldName*/,ScalarType stype)
{
PVStructurePtr pvStructure;
bool hasValueAlarm = false;
@@ -335,7 +335,7 @@ static void testPVScalar(FILE * fd) {
}
static void testScalarArrayCommon(FILE * fd,String fieldName,ScalarType stype)
static void testScalarArrayCommon(FILE * fd,String /*fieldName*/,ScalarType stype)
{
PVStructurePtr pvStructure = standardPVField->scalarArray(
stype,alarmTimeStamp);
+1 -1
View File
@@ -35,7 +35,7 @@ static void print(String name)
if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str());
}
int main(int argc,char *argv[])
int main(int, char **)
{
StructureConstPtr doubleValue = standardField->scalar(pvDouble,
"alarm,timeStamp,display,control,valueAlarm");
+1 -1
View File
@@ -37,7 +37,7 @@ static void print(String name)
if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str());
}
int main(int argc,char *argv[])
int main(int, char **)
{
PVStructurePtr pvStructure = standardPVField->scalar(pvDouble,
"alarm,timeStamp,display,control,valueAlarm");