Fixed/bounded scalar array impl.
This commit is contained in:
-138
@@ -62,42 +62,6 @@ pvDataApp/misc/timeFunction.h
|
||||
pvDataApp/misc/timer.cpp
|
||||
pvDataApp/misc/timer.h
|
||||
pvDataApp/monitor/monitor.h
|
||||
pvDataApp/O.linux-x86_64/alarm.d
|
||||
pvDataApp/O.linux-x86_64/bitSet.d
|
||||
pvDataApp/O.linux-x86_64/bitSetUtil.d
|
||||
pvDataApp/O.linux-x86_64/byteBuffer.d
|
||||
pvDataApp/O.linux-x86_64/Compare.d
|
||||
pvDataApp/O.linux-x86_64/Convert.d
|
||||
pvDataApp/O.linux-x86_64/epicsException.d
|
||||
pvDataApp/O.linux-x86_64/event.d
|
||||
pvDataApp/O.linux-x86_64/executor.d
|
||||
pvDataApp/O.linux-x86_64/FieldCreateFactory.d
|
||||
pvDataApp/O.linux-x86_64/libpvData.a
|
||||
pvDataApp/O.linux-x86_64/libpvData.so
|
||||
pvDataApp/O.linux-x86_64/localStaticLock.d
|
||||
pvDataApp/O.linux-x86_64/messageQueue.d
|
||||
pvDataApp/O.linux-x86_64/pvAlarm.d
|
||||
pvDataApp/O.linux-x86_64/PVArray.d
|
||||
pvDataApp/O.linux-x86_64/PVAuxInfoImpl.d
|
||||
pvDataApp/O.linux-x86_64/pvControl.d
|
||||
pvDataApp/O.linux-x86_64/PVDataCreateFactory.d
|
||||
pvDataApp/O.linux-x86_64/pvDisplay.d
|
||||
pvDataApp/O.linux-x86_64/pvEnumerated.d
|
||||
pvDataApp/O.linux-x86_64/PVField.d
|
||||
pvDataApp/O.linux-x86_64/PVScalar.d
|
||||
pvDataApp/O.linux-x86_64/PVScalarArray.d
|
||||
pvDataApp/O.linux-x86_64/PVStructure.d
|
||||
pvDataApp/O.linux-x86_64/PVStructureArray.d
|
||||
pvDataApp/O.linux-x86_64/pvTimeStamp.d
|
||||
pvDataApp/O.linux-x86_64/requester.d
|
||||
pvDataApp/O.linux-x86_64/serializeHelper.d
|
||||
pvDataApp/O.linux-x86_64/StandardField.d
|
||||
pvDataApp/O.linux-x86_64/StandardPVField.d
|
||||
pvDataApp/O.linux-x86_64/status.d
|
||||
pvDataApp/O.linux-x86_64/timeFunction.d
|
||||
pvDataApp/O.linux-x86_64/timer.d
|
||||
pvDataApp/O.linux-x86_64/timeStamp.d
|
||||
pvDataApp/O.linux-x86_64/TypeFunc.d
|
||||
pvDataApp/property/alarm.cpp
|
||||
pvDataApp/property/alarm.h
|
||||
pvDataApp/property/alarm.h.orig
|
||||
@@ -117,45 +81,15 @@ pvDataApp/property/timeStamp.cpp
|
||||
pvDataApp/property/timeStamp.h
|
||||
pvDataApp/property/timeStamp.h.orig
|
||||
pvDataApp/pv/convert.h
|
||||
pvDataApp/pv/convert.h.orig
|
||||
pvDataApp/pv/pvData.h
|
||||
pvDataApp/pv/pvData.h.orig
|
||||
pvDataApp/pv/pvIntrospect.h
|
||||
pvDataApp/pv/pvIntrospect.h.orig
|
||||
pvDataApp/pv/pvType.h
|
||||
pvDataApp/pv/standardField.h
|
||||
pvDataApp/pv/standardField.h.orig
|
||||
pvDataApp/pv/standardPVField.h
|
||||
pvDataApp/pv/standardPVField.h.orig
|
||||
pvDataApp/pvMisc/bitSetUtil.cpp
|
||||
pvDataApp/pvMisc/bitSetUtil.h
|
||||
testApp/capi/O.linux-x86_64/libtestc.a
|
||||
testApp/capi/O.linux-x86_64/libtestc.so
|
||||
testApp/capi/O.linux-x86_64/testc.d
|
||||
testApp/capi/testc.cpp
|
||||
testApp/capi/testc.py
|
||||
testApp/mb/O.linux-x86_64/mb_test
|
||||
testApp/mb/O.linux-x86_64/mb_test.d
|
||||
testApp/misc/O.linux-x86_64/testBaseException
|
||||
testApp/misc/O.linux-x86_64/testBaseException.d
|
||||
testApp/misc/O.linux-x86_64/testBitSet
|
||||
testApp/misc/O.linux-x86_64/testBitSet.d
|
||||
testApp/misc/O.linux-x86_64/testByteBuffer
|
||||
testApp/misc/O.linux-x86_64/testByteBuffer.d
|
||||
testApp/misc/O.linux-x86_64/testByteOrder
|
||||
testApp/misc/O.linux-x86_64/testByteOrder.d
|
||||
testApp/misc/O.linux-x86_64/testMessageQueue
|
||||
testApp/misc/O.linux-x86_64/testMessageQueue.d
|
||||
testApp/misc/O.linux-x86_64/testQueue
|
||||
testApp/misc/O.linux-x86_64/testQueue.d
|
||||
testApp/misc/O.linux-x86_64/testSerialization
|
||||
testApp/misc/O.linux-x86_64/testSerialization.d
|
||||
testApp/misc/O.linux-x86_64/testThread
|
||||
testApp/misc/O.linux-x86_64/testThread.d
|
||||
testApp/misc/O.linux-x86_64/testTimer
|
||||
testApp/misc/O.linux-x86_64/testTimer.d
|
||||
testApp/misc/O.linux-x86_64/testTimeStamp
|
||||
testApp/misc/O.linux-x86_64/testTimeStamp.d
|
||||
testApp/misc/testBaseException.cpp
|
||||
testApp/misc/testBitSet.cpp
|
||||
testApp/misc/testByteBuffer.cpp
|
||||
@@ -166,34 +100,8 @@ testApp/misc/testSerialization.cpp
|
||||
testApp/misc/testThread.cpp
|
||||
testApp/misc/testTimer.cpp
|
||||
testApp/misc/testTimeStamp.cpp
|
||||
testApp/monitor/O.linux-x86_64/testMonitor
|
||||
testApp/monitor/O.linux-x86_64/testMonitor.d
|
||||
testApp/monitor/testMonitor.cpp
|
||||
testApp/property/O.linux-x86_64/testProperty
|
||||
testApp/property/O.linux-x86_64/testProperty.d
|
||||
testApp/property/testProperty.cpp
|
||||
testApp/pv/O.linux-x86_64/testConvert
|
||||
testApp/pv/O.linux-x86_64/testConvert.d
|
||||
testApp/pv/O.linux-x86_64/testIntrospect
|
||||
testApp/pv/O.linux-x86_64/testIntrospect.d
|
||||
testApp/pv/O.linux-x86_64/testOperators
|
||||
testApp/pv/O.linux-x86_64/testOperators.d
|
||||
testApp/pv/O.linux-x86_64/testPVAppend
|
||||
testApp/pv/O.linux-x86_64/testPVAppend.d
|
||||
testApp/pv/O.linux-x86_64/testPVAuxInfo
|
||||
testApp/pv/O.linux-x86_64/testPVAuxInfo.d
|
||||
testApp/pv/O.linux-x86_64/testPVData
|
||||
testApp/pv/O.linux-x86_64/testPVData.d
|
||||
testApp/pv/O.linux-x86_64/testPVScalarArray
|
||||
testApp/pv/O.linux-x86_64/testPVScalarArray.d
|
||||
testApp/pv/O.linux-x86_64/testPVStructureArray
|
||||
testApp/pv/O.linux-x86_64/testPVStructureArray.d
|
||||
testApp/pv/O.linux-x86_64/testPVType
|
||||
testApp/pv/O.linux-x86_64/testPVType.d
|
||||
testApp/pv/O.linux-x86_64/testStandardField
|
||||
testApp/pv/O.linux-x86_64/testStandardField.d
|
||||
testApp/pv/O.linux-x86_64/testStandardPVField
|
||||
testApp/pv/O.linux-x86_64/testStandardPVField.d
|
||||
testApp/pv/testConvert.cpp
|
||||
testApp/pv/testIntrospect.cpp
|
||||
testApp/pv/testOperators.cpp
|
||||
@@ -209,52 +117,6 @@ COPYRIGHT
|
||||
Doxyfile
|
||||
LICENSE
|
||||
README.html
|
||||
include/pv/alarm.h
|
||||
include/pv/bitSet.h
|
||||
include/pv/bitSetUtil.h
|
||||
include/pv/byteBuffer.h
|
||||
include/pv/control.h
|
||||
include/pv/convert.h
|
||||
include/pv/createRequest.h
|
||||
include/pv/current_function.h
|
||||
include/pv/destroyable.h
|
||||
include/pv/display.h
|
||||
include/pv/epicsException.h
|
||||
include/pv/event.h
|
||||
include/pv/executor.h
|
||||
include/pv/factory.h
|
||||
include/pv/localStaticLock.h
|
||||
include/pv/lock.h
|
||||
include/pv/messageQueue.h
|
||||
include/pv/monitor.h
|
||||
include/pv/monitorPlugin.h
|
||||
include/pv/noDefaultMethods.h
|
||||
include/pv/printer.h
|
||||
include/pv/pvAlarm.h
|
||||
include/pv/pvControl.h
|
||||
include/pv/pvCopy.h
|
||||
include/pv/pvData.h
|
||||
include/pv/pvDisplay.h
|
||||
include/pv/pvEnumerated.h
|
||||
include/pv/pvIntrospect.h
|
||||
include/pv/pvSubArrayCopy.h
|
||||
include/pv/pvTimeStamp.h
|
||||
include/pv/pvType.h
|
||||
include/pv/queue.h
|
||||
include/pv/requester.h
|
||||
include/pv/serialize.h
|
||||
include/pv/serializeHelper.h
|
||||
include/pv/sharedPtr.h
|
||||
include/pv/sharedVector.h
|
||||
include/pv/standardField.h
|
||||
include/pv/standardPVField.h
|
||||
include/pv/status.h
|
||||
include/pv/templateMeta.h
|
||||
include/pv/thread.h
|
||||
include/pv/timeFunction.h
|
||||
include/pv/timer.h
|
||||
include/pv/timeStamp.h
|
||||
include/pv/typeCast.h
|
||||
src/copy/createRequest.cpp
|
||||
src/copy/createRequest.h
|
||||
src/copy/pvCopy.cpp
|
||||
|
||||
@@ -80,7 +80,7 @@ string Scalar::getID() const
|
||||
return idScalarLUT[scalarType];
|
||||
}
|
||||
|
||||
int8 Scalar::getTypeCodeLUT() const
|
||||
int8 Scalar::getTypeCodeLUT(ScalarType scalarType)
|
||||
{
|
||||
static const int8 typeCodeLUT[] = {
|
||||
0x00, // pvBoolean
|
||||
@@ -102,7 +102,7 @@ int8 Scalar::getTypeCodeLUT() const
|
||||
|
||||
void Scalar::serialize(ByteBuffer *buffer, SerializableControl *control) const {
|
||||
control->ensureBuffer(1);
|
||||
buffer->putByte(getTypeCodeLUT());
|
||||
buffer->putByte(getTypeCodeLUT(scalarType));
|
||||
}
|
||||
|
||||
void Scalar::deserialize(ByteBuffer* /*buffer*/, DeserializableControl* /*control*/) {
|
||||
@@ -198,7 +198,8 @@ Array::Array(Type type)
|
||||
Array::~Array() {}
|
||||
|
||||
ScalarArray::ScalarArray(ScalarType elementType)
|
||||
: Array(scalarArray),elementType(elementType)
|
||||
: Array(scalarArray),
|
||||
elementType(elementType)
|
||||
{
|
||||
if(elementType<0 || elementType>MAX_SCALAR_TYPE)
|
||||
throw std::invalid_argument("Can't construct ScalarArray from invalid ScalarType");
|
||||
@@ -206,32 +207,12 @@ ScalarArray::ScalarArray(ScalarType elementType)
|
||||
|
||||
ScalarArray::~ScalarArray() {}
|
||||
|
||||
// TODO remove duplication, see Scalar::getTypeCodeLUT()
|
||||
int8 ScalarArray::getTypeCodeLUT() const
|
||||
{
|
||||
static const int8 typeCodeLUT[] = {
|
||||
0x00, // pvBoolean
|
||||
0x20, // pvByte
|
||||
0x21, // pvShort
|
||||
0x22, // pvInt
|
||||
0x23, // pvLong
|
||||
0x24, // pvUByte
|
||||
0x25, // pvUShort
|
||||
0x26, // pvUInt
|
||||
0x27, // pvULong
|
||||
0x42, // pvFloat
|
||||
0x43, // pvDouble
|
||||
0x60 // pvString
|
||||
};
|
||||
return typeCodeLUT[elementType];
|
||||
}
|
||||
|
||||
const string ScalarArray::getIDScalarArrayLUT() const
|
||||
{
|
||||
static const string idScalarArrayLUT[] = {
|
||||
"boolean[]", // pvBoolean
|
||||
"byte[]", // pvByte
|
||||
"short[]", // pvShort
|
||||
"boolean[]", // pvBoolean
|
||||
"byte[]", // pvByte
|
||||
"short[]", // pvShort
|
||||
"int[]", // pvInt
|
||||
"long[]", // pvLong
|
||||
"ubyte[]", // pvUByte
|
||||
@@ -257,13 +238,59 @@ std::ostream& ScalarArray::dump(std::ostream& o) const
|
||||
|
||||
void ScalarArray::serialize(ByteBuffer *buffer, SerializableControl *control) const {
|
||||
control->ensureBuffer(1);
|
||||
buffer->putByte((int8)0x08 | getTypeCodeLUT());
|
||||
buffer->putByte((int8)0x08 | Scalar::getTypeCodeLUT(elementType));
|
||||
}
|
||||
|
||||
void ScalarArray::deserialize(ByteBuffer* /*buffer*/, DeserializableControl* /*control*/) {
|
||||
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
|
||||
}
|
||||
|
||||
|
||||
BoundedScalarArray::~BoundedScalarArray() {}
|
||||
|
||||
BoundedScalarArray::BoundedScalarArray(ScalarType elementType, size_t size)
|
||||
: ScalarArray(elementType),
|
||||
size(size)
|
||||
{
|
||||
}
|
||||
|
||||
string BoundedScalarArray::getID() const
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%s<%zu>", ScalarTypeFunc::name(getElementType()), size);
|
||||
return string(buffer);
|
||||
}
|
||||
|
||||
void BoundedScalarArray::serialize(ByteBuffer *buffer, SerializableControl *control) const {
|
||||
control->ensureBuffer(1);
|
||||
buffer->putByte((int8)0x10 | Scalar::getTypeCodeLUT(getElementType()));
|
||||
SerializeHelper::writeSize(size, buffer, control);
|
||||
}
|
||||
|
||||
|
||||
FixedScalarArray::~FixedScalarArray() {}
|
||||
|
||||
FixedScalarArray::FixedScalarArray(ScalarType elementType, size_t size)
|
||||
: ScalarArray(elementType),
|
||||
size(size)
|
||||
{
|
||||
}
|
||||
|
||||
string FixedScalarArray::getID() const
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%s[%zu]", ScalarTypeFunc::name(getElementType()), size);
|
||||
return string(buffer);
|
||||
}
|
||||
|
||||
void FixedScalarArray::serialize(ByteBuffer *buffer, SerializableControl *control) const {
|
||||
control->ensureBuffer(1);
|
||||
buffer->putByte((int8)0x18 | Scalar::getTypeCodeLUT(getElementType()));
|
||||
SerializeHelper::writeSize(size, buffer, control);
|
||||
}
|
||||
|
||||
|
||||
|
||||
StructureArray::StructureArray(StructureConstPtr const & structure)
|
||||
: Array(structureArray),pstructure(structure)
|
||||
{
|
||||
@@ -668,6 +695,18 @@ FieldBuilderPtr FieldBuilder::addArray(string const & name, ScalarType scalarTyp
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
FieldBuilderPtr FieldBuilder::addFixedArray(string const & name, ScalarType scalarType, size_t size)
|
||||
{
|
||||
fields.push_back(fieldCreate->createFixedScalarArray(scalarType, size)); fieldNames.push_back(name);
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
FieldBuilderPtr FieldBuilder::addBoundedArray(string const & name, ScalarType scalarType, size_t size)
|
||||
{
|
||||
fields.push_back(fieldCreate->createBoundedScalarArray(scalarType, size)); fieldNames.push_back(name);
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
FieldBuilderPtr FieldBuilder::addArray(string const & name, FieldConstPtr const & element)
|
||||
{
|
||||
switch (element->getType())
|
||||
@@ -790,6 +829,22 @@ ScalarArrayConstPtr FieldCreate::createScalarArray(ScalarType elementType) const
|
||||
return scalarArrays[elementType];
|
||||
}
|
||||
|
||||
ScalarArrayConstPtr FieldCreate::createFixedScalarArray(ScalarType elementType, size_t size) const
|
||||
{
|
||||
if(elementType<0 || elementType>MAX_SCALAR_TYPE)
|
||||
throw std::invalid_argument("Can't construct ScalarArray from invalid ScalarType");
|
||||
|
||||
return ScalarArrayConstPtr(new FixedScalarArray(elementType, size), Field::Deleter());
|
||||
}
|
||||
|
||||
ScalarArrayConstPtr FieldCreate::createBoundedScalarArray(ScalarType elementType, size_t size) const
|
||||
{
|
||||
if(elementType<0 || elementType>MAX_SCALAR_TYPE)
|
||||
throw std::invalid_argument("Can't construct ScalarArray from invalid ScalarType");
|
||||
|
||||
return ScalarArrayConstPtr(new BoundedScalarArray(elementType, size), Field::Deleter());
|
||||
}
|
||||
|
||||
StructureConstPtr FieldCreate::createStructure () const
|
||||
{
|
||||
StringArray fieldNames;
|
||||
@@ -991,15 +1046,14 @@ FieldConstPtr FieldCreate::deserialize(ByteBuffer* buffer, DeserializableControl
|
||||
throw std::invalid_argument("invalid scalarArray type encoding");
|
||||
if (isVariable)
|
||||
return scalarArrays[scalarType];
|
||||
/*
|
||||
else if (isFixed)
|
||||
return FieldConstPtr(new ScalarFixedArray(scalarType, size), Field::Deleter());
|
||||
return FieldConstPtr(
|
||||
new FixedScalarArray(static_cast<epics::pvData::ScalarType>(scalarType), size),
|
||||
Field::Deleter());
|
||||
else
|
||||
return FieldConstPtr(new ScalarBoundedArray(scalarType, size), Field::Deleter());
|
||||
*/
|
||||
// TODO
|
||||
else
|
||||
throw std::invalid_argument("only variant array supported for now");
|
||||
return FieldConstPtr(
|
||||
new BoundedScalarArray(static_cast<epics::pvData::ScalarType>(scalarType), size),
|
||||
Field::Deleter());
|
||||
}
|
||||
else if (typeCode == 0x80)
|
||||
{
|
||||
|
||||
+136
-11
@@ -360,9 +360,12 @@ public:
|
||||
protected:
|
||||
Scalar(ScalarType scalarType);
|
||||
private:
|
||||
int8 getTypeCodeLUT() const;
|
||||
static int8 getTypeCodeLUT(ScalarType scalarType);
|
||||
ScalarType scalarType;
|
||||
friend class FieldCreate;
|
||||
friend class ScalarArray;
|
||||
friend class BoundedScalarArray;
|
||||
friend class FixedScalarArray;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -377,14 +380,21 @@ public:
|
||||
virtual ~Array();
|
||||
typedef Array& reference;
|
||||
typedef const Array& const_reference;
|
||||
|
||||
/* fixed-size array support
|
||||
// 0 not valid value, means undefined
|
||||
|
||||
enum ArraySizeType { variable, fixed, bounded };
|
||||
|
||||
/**
|
||||
* Get array size type (i.e. variable/fixed/bounded size array).
|
||||
* @return array size type enum.
|
||||
*/
|
||||
ArraySizeType getArraySizeType() const;
|
||||
|
||||
/**
|
||||
* Get maximum capacity of the array.
|
||||
* @return maximum capacity of the array, 0 indicates variable size array.
|
||||
*/
|
||||
std::size_t getMaximumCapacity() const;
|
||||
|
||||
// 0 not valid value, means undefined
|
||||
std::size_t getFixedLength() const;
|
||||
*/
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
@@ -394,8 +404,14 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class implements introspection object for field.
|
||||
* This class implements introspection object for scalar array.
|
||||
*/
|
||||
class epicsShareClass ScalarArray : public Array{
|
||||
public:
|
||||
@@ -414,6 +430,10 @@ public:
|
||||
*/
|
||||
ScalarType getElementType() const {return elementType;}
|
||||
|
||||
virtual ArraySizeType getArraySizeType() const {return Array::variable;}
|
||||
|
||||
virtual std::size_t getMaximumCapacity() const {return 0;}
|
||||
|
||||
virtual std::string getID() const;
|
||||
|
||||
virtual std::ostream& dump(std::ostream& o) const;
|
||||
@@ -427,12 +447,85 @@ protected:
|
||||
*/
|
||||
virtual ~ScalarArray();
|
||||
private:
|
||||
int8 getTypeCodeLUT() const;
|
||||
const std::string getIDScalarArrayLUT() const;
|
||||
ScalarType elementType;
|
||||
friend class FieldCreate;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class implements introspection object for bounded scalar array.
|
||||
*/
|
||||
class epicsShareClass BoundedScalarArray : public ScalarArray{
|
||||
public:
|
||||
POINTER_DEFINITIONS(BoundedScalarArray);
|
||||
typedef BoundedScalarArray& reference;
|
||||
typedef const BoundedScalarArray& const_reference;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param scalarType The scalarType for the field.
|
||||
* @param size maximum (bound) capacity.
|
||||
*/
|
||||
BoundedScalarArray(ScalarType scalarType, std::size_t size);
|
||||
|
||||
virtual ArraySizeType getArraySizeType() const {return Array::bounded;}
|
||||
|
||||
virtual std::size_t getMaximumCapacity() const {return size;}
|
||||
|
||||
virtual std::string getID() const;
|
||||
|
||||
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~BoundedScalarArray();
|
||||
private:
|
||||
std::size_t size;
|
||||
friend class FieldCreate;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class implements introspection object for bounded scalar array.
|
||||
*/
|
||||
class epicsShareClass FixedScalarArray : public ScalarArray{
|
||||
public:
|
||||
POINTER_DEFINITIONS(FixedScalarArray);
|
||||
typedef FixedScalarArray& reference;
|
||||
typedef const FixedScalarArray& const_reference;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param scalarType The scalarType for the field.
|
||||
* @param size maximum (bound) capacity.
|
||||
*/
|
||||
FixedScalarArray(ScalarType scalarType, std::size_t size);
|
||||
|
||||
virtual ArraySizeType getArraySizeType() const {return Array::fixed;}
|
||||
|
||||
virtual std::size_t getMaximumCapacity() const {return size;}
|
||||
|
||||
virtual std::string getID() const;
|
||||
|
||||
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~FixedScalarArray();
|
||||
private:
|
||||
std::size_t size;
|
||||
friend class FieldCreate;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class implements introspection object for a structureArray
|
||||
*/
|
||||
@@ -720,13 +813,31 @@ public:
|
||||
FieldBuilderPtr add(std::string const & name, FieldConstPtr const & field);
|
||||
|
||||
/**
|
||||
* Add array of {@code Scalar} elements.
|
||||
* Add variable size array of {@code Scalar} elements.
|
||||
* @param name name of the array.
|
||||
* @param scalarType type of a scalar element.
|
||||
* @return this instance of a {@code FieldBuilder}.
|
||||
*/
|
||||
FieldBuilderPtr addArray(std::string const & name, ScalarType scalarType);
|
||||
|
||||
/**
|
||||
* Add fixed-size array of {@code Scalar} elements.
|
||||
* @param name name of the array.
|
||||
* @param scalarType type of a scalar element.
|
||||
* @param size Array fixed size.
|
||||
* @return this instance of a {@code FieldBuilder}.
|
||||
*/
|
||||
FieldBuilderPtr addFixedArray(std::string const & name, ScalarType scalarType, std::size_t size);
|
||||
|
||||
/**
|
||||
* Add bounded-size array of {@code Scalar} elements.
|
||||
* @param name name of the array.
|
||||
* @param scalarType type of a scalar element.
|
||||
* @param bound Array maximum capacity (size).
|
||||
* @return this instance of a {@code FieldBuilder}.
|
||||
*/
|
||||
FieldBuilderPtr addBoundedArray(std::string const & name, ScalarType scalarType, std::size_t bound);
|
||||
|
||||
/**
|
||||
* Add array of {@code Field} elements.
|
||||
* @param name name of the array.
|
||||
@@ -843,11 +954,25 @@ public:
|
||||
*/
|
||||
ScalarConstPtr createScalar(ScalarType scalarType) const;
|
||||
/**
|
||||
* Create an {@code Array} field.
|
||||
* Create an {@code Array} field, variable size array.
|
||||
* @param elementType The {@code scalarType} for array elements
|
||||
* @return An {@code Array} Interface for the newly created object.
|
||||
*/
|
||||
ScalarArrayConstPtr createScalarArray(ScalarType elementType) const;
|
||||
/*
|
||||
* Create an {@code Array} field, fixed size array.
|
||||
* @param elementType The {@code scalarType} for array elements
|
||||
* @param size Fixed array size.
|
||||
* @return An {@code Array} Interface for the newly created object.
|
||||
*/
|
||||
ScalarArrayConstPtr createFixedScalarArray(ScalarType elementType, std::size_t size) const;
|
||||
/**
|
||||
* Create an {@code Array} field, bounded size array.
|
||||
* @param elementType The {@code scalarType} for array elements
|
||||
* @param size Array maximum capacity (bound).
|
||||
* @return An {@code Array} Interface for the newly created object.
|
||||
*/
|
||||
ScalarArrayConstPtr createBoundedScalarArray(ScalarType elementType, std::size_t bound) const;
|
||||
/**
|
||||
* Create an {@code Array} field that is has element type <i>Structure</i>
|
||||
* @param fieldName The field name
|
||||
|
||||
@@ -625,13 +625,13 @@ void testStructureId() {
|
||||
testOk1(structureWithNoId!=structure1);
|
||||
testOk1(structure1!=structure2);
|
||||
|
||||
//serializationTest(structure1);
|
||||
//serializationFieldTest(structure1);
|
||||
|
||||
PVStructurePtr pvStructure = getPVDataCreate()->createPVStructure(structure1);
|
||||
serializationTest(pvStructure);
|
||||
}
|
||||
|
||||
void serializatioTest(FieldConstPtr const & field)
|
||||
void serializationFieldTest(FieldConstPtr const & field)
|
||||
{
|
||||
buffer->clear();
|
||||
|
||||
@@ -660,27 +660,27 @@ void testIntrospectionSerialization()
|
||||
ScalarType scalarType = static_cast<ScalarType>(i);
|
||||
|
||||
ScalarConstPtr scalar = factory->createScalar(scalarType);
|
||||
serializatioTest(scalar);
|
||||
serializationFieldTest(scalar);
|
||||
|
||||
ScalarArrayConstPtr array = factory->createScalarArray(scalarType);
|
||||
serializatioTest(array);
|
||||
serializationFieldTest(array);
|
||||
}
|
||||
|
||||
// and a structure
|
||||
StructureConstPtr structure = getStandardField()->timeStamp();
|
||||
serializatioTest(structure);
|
||||
serializationFieldTest(structure);
|
||||
|
||||
// and a structure array
|
||||
StructureArrayConstPtr structureArray = factory->createStructureArray(structure);
|
||||
serializatioTest(structureArray);
|
||||
serializationFieldTest(structureArray);
|
||||
|
||||
// variant union
|
||||
UnionConstPtr variant = factory->createVariantUnion();
|
||||
serializatioTest(variant);
|
||||
serializationFieldTest(variant);
|
||||
|
||||
// variant array union
|
||||
UnionArrayConstPtr variantArray = factory->createVariantUnionArray();
|
||||
serializatioTest(variantArray);
|
||||
serializationFieldTest(variantArray);
|
||||
|
||||
// union
|
||||
UnionConstPtr punion = factory->createFieldBuilder()->
|
||||
@@ -692,11 +692,29 @@ void testIntrospectionSerialization()
|
||||
endNested()->
|
||||
addArray("intArray", pvInt)->
|
||||
createUnion();
|
||||
serializatioTest(punion);
|
||||
serializationFieldTest(punion);
|
||||
|
||||
// union array
|
||||
UnionArrayConstPtr punionArray = factory->createUnionArray(punion);
|
||||
serializatioTest(punionArray);
|
||||
serializationFieldTest(punionArray);
|
||||
}
|
||||
|
||||
void testArraySizeType() {
|
||||
testDiag("Testing array size types...");
|
||||
|
||||
FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
|
||||
StructureConstPtr s = fieldCreate->createFieldBuilder()->
|
||||
addArray("variableArray", pvDouble)->
|
||||
addFixedArray("fixedArray", pvDouble, 10)->
|
||||
addBoundedArray("boundedArray", pvDouble, 1024)->
|
||||
createStructure();
|
||||
testOk1(s.get() != 0);
|
||||
testOk1(Structure::DEFAULT_ID == s->getID());
|
||||
testOk1(3 == s->getFields().size());
|
||||
|
||||
serializationFieldTest(s);
|
||||
serializationTest(getPVDataCreate()->createPVStructure(s));
|
||||
}
|
||||
|
||||
void testStringCopy() {
|
||||
@@ -710,7 +728,7 @@ void testStringCopy() {
|
||||
|
||||
MAIN(testSerialization) {
|
||||
|
||||
testPlan(213);
|
||||
testPlan(216);
|
||||
|
||||
flusher = new SerializableControlImpl();
|
||||
control = new DeserializableControlImpl();
|
||||
@@ -724,10 +742,13 @@ MAIN(testSerialization) {
|
||||
testScalar();
|
||||
testArray();
|
||||
testStructure();
|
||||
testStructureId();
|
||||
testStructureArray();
|
||||
|
||||
testUnion();
|
||||
|
||||
testArraySizeType();
|
||||
|
||||
|
||||
delete buffer;
|
||||
delete control;
|
||||
|
||||
@@ -110,6 +110,23 @@ void test_invalid()
|
||||
}
|
||||
|
||||
|
||||
void test_arraySizeTypes()
|
||||
{
|
||||
testDiag("Test test_arraySizeTypes()");
|
||||
|
||||
FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
|
||||
StructureConstPtr s = fieldCreate->createFieldBuilder()->
|
||||
addArray("variableArray", pvDouble)->
|
||||
addFixedArray("fixedArray", pvDouble, 10)->
|
||||
addBoundedArray("boundedArray", pvDouble, 1024)->
|
||||
createStructure();
|
||||
testOk1(s.get() != 0);
|
||||
testOk1(Structure::DEFAULT_ID == s->getID());
|
||||
testOk1(3 == s->getFields().size());
|
||||
}
|
||||
|
||||
|
||||
void test_nestedStructure()
|
||||
{
|
||||
testDiag("Test test_nestedStructure()");
|
||||
@@ -224,11 +241,12 @@ void test_nestedStructureArray()
|
||||
|
||||
MAIN(testFieldBuilder)
|
||||
{
|
||||
testPlan(65);
|
||||
testPlan(68);
|
||||
testDiag("Tests for FieldBuilder");
|
||||
|
||||
test_factory();
|
||||
test_structure();
|
||||
test_arraySizeTypes();
|
||||
test_nestedStructure();
|
||||
test_nestedStructureArray();
|
||||
|
||||
|
||||
@@ -59,9 +59,26 @@ static void testScalar() {
|
||||
}
|
||||
|
||||
static void testScalarArrayCommon(ScalarType stype,
|
||||
bool isInteger,bool isNumeric,bool isPrimitive)
|
||||
bool isInteger,bool isNumeric,bool isPrimitive,
|
||||
Array::ArraySizeType sizeType = Array::variable, size_t size = 0)
|
||||
{
|
||||
ScalarArrayConstPtr pscalar = fieldCreate->createScalarArray(stype);
|
||||
ScalarArrayConstPtr pscalar;
|
||||
switch (sizeType)
|
||||
{
|
||||
case Array::variable:
|
||||
pscalar = fieldCreate->createScalarArray(stype);
|
||||
size = 0;
|
||||
break;
|
||||
case Array::bounded:
|
||||
pscalar = fieldCreate->createBoundedScalarArray(stype, size);
|
||||
break;
|
||||
case Array::fixed:
|
||||
pscalar = fieldCreate->createFixedScalarArray(stype, size);
|
||||
break;
|
||||
default:
|
||||
throw std::invalid_argument("unsupported array size type");
|
||||
}
|
||||
|
||||
Type type = pscalar->getType();
|
||||
testOk1(type==scalarArray);
|
||||
|
||||
@@ -69,6 +86,9 @@ static void testScalarArrayCommon(ScalarType stype,
|
||||
oss << type;
|
||||
testOk1(oss.str().compare("scalarArray")==0);
|
||||
|
||||
testOk1(pscalar->getArraySizeType()==sizeType);
|
||||
testOk1(pscalar->getMaximumCapacity()==size);
|
||||
|
||||
ScalarType scalarType = pscalar->getElementType();
|
||||
testOk1(scalarType==stype);
|
||||
testOk1(ScalarTypeFunc::isInteger(scalarType)==isInteger);
|
||||
@@ -86,6 +106,24 @@ static void testScalarArray() {
|
||||
testScalarArrayCommon(pvFloat,false,true,true);
|
||||
testScalarArrayCommon(pvDouble,false,true,true);
|
||||
testScalarArrayCommon(pvString,false,false,false);
|
||||
|
||||
testScalarArrayCommon(pvBoolean,false,false,true,Array::bounded,10);
|
||||
testScalarArrayCommon(pvByte,true,true,true,Array::bounded,10);
|
||||
testScalarArrayCommon(pvShort,true,true,true,Array::bounded,10);
|
||||
testScalarArrayCommon(pvInt,true,true,true,Array::bounded,10);
|
||||
testScalarArrayCommon(pvLong,true,true,true,Array::bounded,10);
|
||||
testScalarArrayCommon(pvFloat,false,true,true,Array::bounded,10);
|
||||
testScalarArrayCommon(pvDouble,false,true,true,Array::bounded,10);
|
||||
testScalarArrayCommon(pvString,false,false,false,Array::bounded,10);
|
||||
|
||||
testScalarArrayCommon(pvBoolean,false,false,true,Array::fixed,16);
|
||||
testScalarArrayCommon(pvByte,true,true,true,Array::fixed,16);
|
||||
testScalarArrayCommon(pvShort,true,true,true,Array::fixed,16);
|
||||
testScalarArrayCommon(pvInt,true,true,true,Array::fixed,16);
|
||||
testScalarArrayCommon(pvLong,true,true,true,Array::fixed,16);
|
||||
testScalarArrayCommon(pvFloat,false,true,true,Array::fixed,16);
|
||||
testScalarArrayCommon(pvDouble,false,true,true,Array::fixed,16);
|
||||
testScalarArrayCommon(pvString,false,false,false,Array::fixed,16);
|
||||
}
|
||||
|
||||
static void testStructure()
|
||||
@@ -258,7 +296,7 @@ static void testMapping()
|
||||
|
||||
MAIN(testIntrospect)
|
||||
{
|
||||
testPlan(180);
|
||||
testPlan(324);
|
||||
fieldCreate = getFieldCreate();
|
||||
pvDataCreate = getPVDataCreate();
|
||||
standardField = getStandardField();
|
||||
|
||||
Reference in New Issue
Block a user