Array IF added

This commit is contained in:
Matej Sekoranja
2014-05-13 00:18:30 +02:00
parent 6510c10884
commit 0ceb87eee1
3 changed files with 70 additions and 9 deletions

View File

@@ -216,8 +216,15 @@ static UnionConstPtr deserializeUnionField(const FieldCreate* fieldCreate, ByteB
return fieldCreate->createUnion(id, fieldNames, fields);
}
Array::Array(Type type)
: Field(type)
{
}
Array::~Array() {}
ScalarArray::ScalarArray(ScalarType elementType)
: Field(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");
@@ -282,7 +289,7 @@ void ScalarArray::deserialize(ByteBuffer* /*buffer*/, DeserializableControl* /*c
}
StructureArray::StructureArray(StructureConstPtr const & structure)
: Field(structureArray),pstructure(structure)
: Array(structureArray),pstructure(structure)
{
}
@@ -312,7 +319,7 @@ void StructureArray::deserialize(ByteBuffer* /*buffer*/, DeserializableControl*
}
UnionArray::UnionArray(UnionConstPtr const & _punion)
: Field(unionArray),punion(_punion)
: Array(unionArray),punion(_punion)
{
}

View File

@@ -542,6 +542,11 @@ public:
* Destructor
*/
virtual ~PVArray(){};
/**
* Get the introspection interface
* @return The interface.
*/
virtual ArrayConstPtr getArray() const = 0;
/**
* Set the field to be immutable, i. e. it can no longer be modified.
* This is permanent, i.e. once done the field can onot be made mutable.
@@ -1155,6 +1160,11 @@ public:
*/
virtual ~PVValueArray() {}
virtual ArrayConstPtr getArray() const
{
return std::tr1::static_pointer_cast<const Array>(this->getField());
}
std::ostream& dumpValue(std::ostream& o) const
{
const_svector v(this->view());
@@ -1216,6 +1226,11 @@ public:
*/
virtual ~PVValueArray() {}
virtual ArrayConstPtr getArray() const
{
return std::tr1::static_pointer_cast<const Array>(structureArray);
}
virtual size_t getLength() const {return value.size();}
virtual size_t getCapacity() const {return value.capacity();}
@@ -1306,6 +1321,11 @@ public:
*/
virtual ~PVValueArray() {}
virtual ArrayConstPtr getArray() const
{
return std::tr1::static_pointer_cast<const Array>(unionArray);
}
virtual size_t getLength() const {return value.size();}
virtual size_t getCapacity() const {return value.capacity();}

View File

@@ -24,6 +24,7 @@ namespace epics { namespace pvData {
class Field;
class Scalar;
class Array;
class ScalarArray;
class Structure;
class StructureArray;
@@ -42,6 +43,10 @@ typedef std::vector<FieldConstPtr> FieldConstPtrArray;
* typedef for a shared pointer to an immutable Scalar.
*/
typedef std::tr1::shared_ptr<const Scalar> ScalarConstPtr;
/**
* typedef for a shared pointer to an immutable Array.
*/
typedef std::tr1::shared_ptr<const Array> ArrayConstPtr;
/**
* typedef for a shared pointer to an immutable ScalarArray.
*/
@@ -314,10 +319,39 @@ private:
friend class FieldCreate;
};
/**
* This class implements introspection object for Array.
*/
class epicsShareClass Array : public Field{
public:
POINTER_DEFINITIONS(Array);
/**
* Destructor.
*/
virtual ~Array();
typedef Array& reference;
typedef const Array& const_reference;
/* fixed-size array support
// 0 not valid value, means undefined
std::size_t getMaximumCapacity() const;
// 0 not valid value, means undefined
std::size_t getFixedLength() const;
*/
protected:
/**
* Constructor
* @param fieldName The field type.
*/
Array(Type type);
};
/**
* This class implements introspection object for field.
*/
class epicsShareClass ScalarArray : public Field{
class epicsShareClass ScalarArray : public Array{
public:
POINTER_DEFINITIONS(ScalarArray);
typedef ScalarArray& reference;
@@ -332,7 +366,7 @@ public:
* Get the scalarType for the elements.
* @return the scalarType
*/
ScalarType getElementType() const {return elementType;}
ScalarType getElementType() const {return elementType;}
/**
* Convert the scalarType to a string and add it to builder.
* @param builder The string builder.
@@ -365,7 +399,7 @@ private:
/**
* This class implements introspection object for a structureArray
*/
class epicsShareClass StructureArray : public Field{
class epicsShareClass StructureArray : public Array{
public:
POINTER_DEFINITIONS(StructureArray);
typedef StructureArray& reference;
@@ -375,7 +409,7 @@ public:
* Get the introspection interface for the array elements.
* @return The introspection interface.
*/
StructureConstPtr getStructure() const {return pstructure;}
StructureConstPtr getStructure() const {return pstructure;}
/**
* Convert the scalarType to a string and add it to builder.
@@ -407,7 +441,7 @@ private:
/**
* This class implements introspection object for a unionArray
*/
class epicsShareClass UnionArray : public Field{
class epicsShareClass UnionArray : public Array{
public:
POINTER_DEFINITIONS(UnionArray);
typedef UnionArray& reference;
@@ -417,7 +451,7 @@ public:
* Get the introspection interface for the array elements.
* @return The introspection interface.
*/
UnionConstPtr getUnion() const {return punion;}
UnionConstPtr getUnion() const {return punion;}
/**
* Convert the scalarType to a string and add it to builder.