scalars and arrays implemented

This commit is contained in:
Marty Kraimer
2010-10-01 10:01:27 -04:00
parent 419f340aaa
commit 4b912a3c30
23 changed files with 1801 additions and 141 deletions
+8 -9
View File
@@ -35,6 +35,7 @@ namespace epics { namespace pvData {
static String fieldImmutable("field is immutable");
void PVArray::setLength(int length) {
if(length==pImpl->length) return;
if(PVField::isImmutable()) {
PVField::message(fieldImmutable,errorMessage);
return;
@@ -44,8 +45,13 @@ namespace epics { namespace pvData {
pImpl->length = length;
}
void PVArray::setCapacityLength(int capacity,int length) {
pImpl->capacity = capacity;
pImpl->length = length;
}
epicsBoolean PVArray::isCapacityImmutable()
epicsBoolean PVArray::isCapacityMutable()
{
if(PVField::isImmutable()) {
return epicsFalse;
@@ -53,7 +59,7 @@ namespace epics { namespace pvData {
return pImpl->capacityMutable;
}
void PVArray::setCapacityImmutable(epicsBoolean isMutable)
void PVArray::setCapacityMutable(epicsBoolean isMutable)
{
if(isMutable && PVField::isImmutable()) {
PVField::message(fieldImmutable,errorMessage);
@@ -76,12 +82,5 @@ namespace epics { namespace pvData {
pImpl->capacity = capacity;
}
void PVArray::toString(StringBuilder buf) {toString(buf,0);}
void PVArray::toString(StringBuilder buf, int indentLevel)
{
throw std::logic_error(notImplemented);
}
}}
#endif /* ABSTRACTPVARRAY_H */
+1 -1
View File
@@ -126,7 +126,7 @@ static String notImplemented("not implemented");
void PVField::postPut()
{
throw std::logic_error(notImplemented);
if(pImpl->postHandler!=0) pImpl->postHandler->postPut();
}
void PVField::setPostHandler(PostHandler *ppostHandler)
+153
View File
@@ -0,0 +1,153 @@
/*BasePVBooleanArrray.h*/
#ifndef BASEPVBOOLEANARRAY_H
#define BASEPVBOOLEANARRAY_H
#include <cstddef>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <epicsTypes.h>
#include "pvData.h"
#include "factory.h"
#include "AbstractPVScalarArray.h"
namespace epics { namespace pvData {
PVBooleanArray::~PVBooleanArray() {}
PVBooleanArray::PVBooleanArray(PVStructure *parent,ScalarArrayConstPtr scalar)
: PVScalarArray(parent,scalar) {}
class BasePVBooleanArray : public PVBooleanArray {
public:
BasePVBooleanArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
virtual ~BasePVBooleanArray();
virtual void setCapacity(int capacity);
virtual int get(int offset, int length, BooleanArrayData *data) ;
virtual int put(int offset,int length,BooleanArray from,
int fromOffset);
virtual void shareData(epicsBoolean value[],int capacity,int length);
// from Serializable
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) ;
virtual void toString(StringBuilder buf);
virtual void toString(StringBuilder buf,int indentLevel);
virtual epicsBoolean equals(PVField *pv) ;
private:
epicsBoolean *value;
};
BasePVBooleanArray::BasePVBooleanArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
: PVBooleanArray(parent,scalarArray),value(new epicsBoolean[0])
{ }
BasePVBooleanArray::~BasePVBooleanArray()
{
delete[] value;
}
void BasePVBooleanArray::setCapacity(int capacity)
{
if(PVArray::getCapacity()==capacity) return;
if(!PVArray::isCapacityMutable()) {
std::string message("not capacityMutable");
PVField::message(message, errorMessage);
return;
}
int length = PVArray::getLength();
if(length>capacity) length = capacity;
epicsBoolean *newValue = new epicsBoolean[capacity];
for(int i=0; i<length; i++) newValue[i] = value[i];
delete[]value;
value = newValue;
PVArray::setCapacityLength(capacity,length);
}
int BasePVBooleanArray::get(int offset, int len, BooleanArrayData *data)
{
int n = len;
int length = PVArray::getLength();
if(offset+len > length) {
n = length-offset;
if(n<0) n = 0;
}
data->data = value;
data->offset = offset;
return n;
}
int BasePVBooleanArray::put(int offset,int len,
BooleanArray from,int fromOffset)
{
if(PVField::isImmutable()) {
PVField::message("field is immutable",errorMessage);
return 0;
}
if(from==value) return len;
if(len<1) return 0;
int length = PVArray::getLength();
int capacity = PVArray::getCapacity();
if(offset+len > length) {
int newlength = offset + len;
if(newlength>capacity) {
setCapacity(newlength);
newlength = PVArray::getCapacity();
len = newlength - offset;
if(len<=0) return 0;
}
length = newlength;
}
for(int i=0;i<len;i++) {
value[i+offset] = from[i+fromOffset];
}
PVArray::setLength(length);
PVField::postPut();
return len;
}
void BasePVBooleanArray::shareData(
epicsBoolean shareValue[],int capacity,int length)
{
delete[] value;
value = shareValue;
PVArray::setCapacityLength(capacity,length);
}
void BasePVBooleanArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVBooleanArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVBooleanArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count)
{
throw std::logic_error(notImplemented);
}
void BasePVBooleanArray::toString(StringBuilder buf)
{
toString(buf,1);
}
void BasePVBooleanArray::toString(StringBuilder buf,int indentLevel)
{
getConvert()->getString(buf,this,indentLevel);
PVField::toString(buf,indentLevel);
}
epicsBoolean BasePVBooleanArray::equals(PVField *pv)
{
return getConvert()->equals(this,pv);
}
}}
#endif /* BASEPVBOOLEANARRAY_H */
+153
View File
@@ -0,0 +1,153 @@
/*BasePVByteArray.h*/
#ifndef BASEPVBYTEARRAY_H
#define BASEPVBYTEARRAY_H
#include <cstddef>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <epicsTypes.h>
#include "pvData.h"
#include "factory.h"
#include "AbstractPVScalarArray.h"
namespace epics { namespace pvData {
PVByteArray::~PVByteArray() {}
PVByteArray::PVByteArray(PVStructure *parent,ScalarArrayConstPtr scalar)
: PVScalarArray(parent,scalar) {}
class BasePVByteArray : public PVByteArray {
public:
BasePVByteArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
virtual ~BasePVByteArray();
virtual void setCapacity(int capacity);
virtual int get(int offset, int length, ByteArrayData *data) ;
virtual int put(int offset,int length,ByteArray from,
int fromOffset);
virtual void shareData(epicsInt8 value[],int capacity,int length);
// from Serializable
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) ;
virtual void toString(StringBuilder buf);
virtual void toString(StringBuilder buf,int indentLevel);
virtual epicsBoolean equals(PVField *pv) ;
private:
epicsInt8 *value;
};
BasePVByteArray::BasePVByteArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
: PVByteArray(parent,scalarArray),value(new epicsInt8[0])
{ }
BasePVByteArray::~BasePVByteArray()
{
delete[] value;
}
void BasePVByteArray::setCapacity(int capacity)
{
if(PVArray::getCapacity()==capacity) return;
if(!PVArray::isCapacityMutable()) {
std::string message("not capacityMutable");
PVField::message(message, errorMessage);
return;
}
int length = PVArray::getLength();
if(length>capacity) length = capacity;
epicsInt8 *newValue = new epicsInt8[capacity];
for(int i=0; i<length; i++) newValue[i] = value[i];
delete[]value;
value = newValue;
PVArray::setCapacityLength(capacity,length);
}
int BasePVByteArray::get(int offset, int len, ByteArrayData *data)
{
int n = len;
int length = PVArray::getLength();
if(offset+len > length) {
n = length-offset;
if(n<0) n = 0;
}
data->data = value;
data->offset = offset;
return n;
}
int BasePVByteArray::put(int offset,int len,
ByteArray from,int fromOffset)
{
if(PVField::isImmutable()) {
PVField::message("field is immutable",errorMessage);
return 0;
}
if(from==value) return len;
if(len<1) return 0;
int length = PVArray::getLength();
int capacity = PVArray::getCapacity();
if(offset+len > length) {
int newlength = offset + len;
if(newlength>capacity) {
setCapacity(newlength);
newlength = PVArray::getCapacity();
len = newlength - offset;
if(len<=0) return 0;
}
length = newlength;
}
for(int i=0;i<len;i++) {
value[i+offset] = from[i+fromOffset];
}
PVArray::setLength(length);
PVField::postPut();
return len;
}
void BasePVByteArray::shareData(
epicsInt8 shareValue[],int capacity,int length)
{
delete[] value;
value = shareValue;
PVArray::setCapacityLength(capacity,length);
}
void BasePVByteArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVByteArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVByteArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count)
{
throw std::logic_error(notImplemented);
}
void BasePVByteArray::toString(StringBuilder buf)
{
toString(buf,1);
}
void BasePVByteArray::toString(StringBuilder buf,int indentLevel)
{
getConvert()->getString(buf,this,indentLevel);
PVField::toString(buf,indentLevel);
}
epicsBoolean BasePVByteArray::equals(PVField *pv)
{
return getConvert()->equals(this,pv);
}
}}
#endif /* BASEPVBYTEARRAY_H */
+60 -15
View File
@@ -25,7 +25,7 @@ namespace epics { namespace pvData {
virtual int get(int offset, int length, DoubleArrayData *data) ;
virtual int put(int offset,int length,DoubleArray from,
int fromOffset);
virtual void shareData(DoubleArrayData *from);
virtual void shareData(double value[],int capacity,int length);
// from Serializable
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
@@ -35,40 +35,84 @@ namespace epics { namespace pvData {
virtual void toString(StringBuilder buf,int indentLevel);
virtual epicsBoolean equals(PVField *pv) ;
private:
double *doubleArray;
double *value;
};
BasePVDoubleArray::BasePVDoubleArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
: PVDoubleArray(parent,scalarArray),doubleArray(new double[0])
: PVDoubleArray(parent,scalarArray),value(new double[0])
{ }
BasePVDoubleArray::~BasePVDoubleArray()
{
delete[] doubleArray;
delete[] value;
}
void BasePVDoubleArray::setCapacity(int capacity)
{
throw std::logic_error(notImplemented);
if(PVArray::getCapacity()==capacity) return;
if(!PVArray::isCapacityMutable()) {
std::string message("not capacityMutable");
PVField::message(message, errorMessage);
return;
}
int length = PVArray::getLength();
if(length>capacity) length = capacity;
double *newValue = new double[capacity];
for(int i=0; i<length; i++) newValue[i] = value[i];
delete[]value;
value = newValue;
PVArray::setCapacityLength(capacity,length);
}
int BasePVDoubleArray::get(int offset, int length,
DoubleArrayData *data)
int BasePVDoubleArray::get(int offset, int len, DoubleArrayData *data)
{
data->data = doubleArray;
return getLength();
int n = len;
int length = PVArray::getLength();
if(offset+len > length) {
n = length-offset;
if(n<0) n = 0;
}
data->data = value;
data->offset = offset;
return n;
}
int BasePVDoubleArray::put(int offset,int length,
int BasePVDoubleArray::put(int offset,int len,
DoubleArray from,int fromOffset)
{
return getLength();
if(PVField::isImmutable()) {
PVField::message("field is immutable",errorMessage);
return 0;
}
if(from==value) return len;
if(len<1) return 0;
int length = PVArray::getLength();
int capacity = PVArray::getCapacity();
if(offset+len > length) {
int newlength = offset + len;
if(newlength>capacity) {
setCapacity(newlength);
newlength = PVArray::getCapacity();
len = newlength - offset;
if(len<=0) return 0;
}
length = newlength;
}
for(int i=0;i<len;i++) {
value[i+offset] = from[i+fromOffset];
}
PVArray::setLength(length);
PVField::postPut();
return len;
}
void BasePVDoubleArray::shareData(DoubleArrayData *from)
void BasePVDoubleArray::shareData(
double shareValue[],int capacity,int length)
{
throw std::logic_error(notImplemented);
delete[] value;
value = shareValue;
PVArray::setCapacityLength(capacity,length);
}
void BasePVDoubleArray::serialize(ByteBuffer *pbuffer,
@@ -97,12 +141,13 @@ namespace epics { namespace pvData {
void BasePVDoubleArray::toString(StringBuilder buf,int indentLevel)
{
getConvert()->getString(buf,this,indentLevel);
PVArray::toString(buf,indentLevel);
PVField::toString(buf,indentLevel);
}
epicsBoolean BasePVDoubleArray::equals(PVField *pv)
{
throw std::logic_error(notImplemented);
return getConvert()->equals(this,pv);
}
}}
#endif /* BASEPVDOUBLEARRAY_H */
+153
View File
@@ -0,0 +1,153 @@
/*BasePVFloatArray.h*/
#ifndef BASEPVFLOATARRAY_H
#define BASEPVFLOATARRAY_H
#include <cstddef>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <epicsTypes.h>
#include "pvData.h"
#include "factory.h"
#include "AbstractPVScalarArray.h"
namespace epics { namespace pvData {
PVFloatArray::~PVFloatArray() {}
PVFloatArray::PVFloatArray(PVStructure *parent,ScalarArrayConstPtr scalar)
: PVScalarArray(parent,scalar) {}
class BasePVFloatArray : public PVFloatArray {
public:
BasePVFloatArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
virtual ~BasePVFloatArray();
virtual void setCapacity(int capacity);
virtual int get(int offset, int length, FloatArrayData *data) ;
virtual int put(int offset,int length,FloatArray from,
int fromOffset);
virtual void shareData(float value[],int capacity,int length);
// from Serializable
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) ;
virtual void toString(StringBuilder buf);
virtual void toString(StringBuilder buf,int indentLevel);
virtual epicsBoolean equals(PVField *pv) ;
private:
float *value;
};
BasePVFloatArray::BasePVFloatArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
: PVFloatArray(parent,scalarArray),value(new float[0])
{ }
BasePVFloatArray::~BasePVFloatArray()
{
delete[] value;
}
void BasePVFloatArray::setCapacity(int capacity)
{
if(PVArray::getCapacity()==capacity) return;
if(!PVArray::isCapacityMutable()) {
std::string message("not capacityMutable");
PVField::message(message, errorMessage);
return;
}
int length = PVArray::getLength();
if(length>capacity) length = capacity;
float *newValue = new float[capacity];
for(int i=0; i<length; i++) newValue[i] = value[i];
delete[]value;
value = newValue;
PVArray::setCapacityLength(capacity,length);
}
int BasePVFloatArray::get(int offset, int len, FloatArrayData *data)
{
int n = len;
int length = PVArray::getLength();
if(offset+len > length) {
n = length-offset;
if(n<0) n = 0;
}
data->data = value;
data->offset = offset;
return n;
}
int BasePVFloatArray::put(int offset,int len,
FloatArray from,int fromOffset)
{
if(PVField::isImmutable()) {
PVField::message("field is immutable",errorMessage);
return 0;
}
if(from==value) return len;
if(len<1) return 0;
int length = PVArray::getLength();
int capacity = PVArray::getCapacity();
if(offset+len > length) {
int newlength = offset + len;
if(newlength>capacity) {
setCapacity(newlength);
newlength = PVArray::getCapacity();
len = newlength - offset;
if(len<=0) return 0;
}
length = newlength;
}
for(int i=0;i<len;i++) {
value[i+offset] = from[i+fromOffset];
}
PVArray::setLength(length);
PVField::postPut();
return len;
}
void BasePVFloatArray::shareData(
float shareValue[],int capacity,int length)
{
delete[] value;
value = shareValue;
PVArray::setCapacityLength(capacity,length);
}
void BasePVFloatArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVFloatArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVFloatArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count)
{
throw std::logic_error(notImplemented);
}
void BasePVFloatArray::toString(StringBuilder buf)
{
toString(buf,1);
}
void BasePVFloatArray::toString(StringBuilder buf,int indentLevel)
{
getConvert()->getString(buf,this,indentLevel);
PVField::toString(buf,indentLevel);
}
epicsBoolean BasePVFloatArray::equals(PVField *pv)
{
return getConvert()->equals(this,pv);
}
}}
#endif /* BASEPVFLOATARRAY_H */
+153
View File
@@ -0,0 +1,153 @@
/*BasePVIntArray.h*/
#ifndef BASEPVINTARRAY_H
#define BASEPVINTARRAY_H
#include <cstddef>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <epicsTypes.h>
#include "pvData.h"
#include "factory.h"
#include "AbstractPVScalarArray.h"
namespace epics { namespace pvData {
PVIntArray::~PVIntArray() {}
PVIntArray::PVIntArray(PVStructure *parent,ScalarArrayConstPtr scalar)
: PVScalarArray(parent,scalar) {}
class BasePVIntArray : public PVIntArray {
public:
BasePVIntArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
virtual ~BasePVIntArray();
virtual void setCapacity(int capacity);
virtual int get(int offset, int length, IntArrayData *data) ;
virtual int put(int offset,int length,IntArray from,
int fromOffset);
virtual void shareData(epicsInt32 value[],int capacity,int length);
// from Serializable
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) ;
virtual void toString(StringBuilder buf);
virtual void toString(StringBuilder buf,int indentLevel);
virtual epicsBoolean equals(PVField *pv) ;
private:
epicsInt32 *value;
};
BasePVIntArray::BasePVIntArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
: PVIntArray(parent,scalarArray),value(new epicsInt32[0])
{ }
BasePVIntArray::~BasePVIntArray()
{
delete[] value;
}
void BasePVIntArray::setCapacity(int capacity)
{
if(PVArray::getCapacity()==capacity) return;
if(!PVArray::isCapacityMutable()) {
std::string message("not capacityMutable");
PVField::message(message, errorMessage);
return;
}
int length = PVArray::getLength();
if(length>capacity) length = capacity;
epicsInt32 *newValue = new epicsInt32[capacity];
for(int i=0; i<length; i++) newValue[i] = value[i];
delete[]value;
value = newValue;
PVArray::setCapacityLength(capacity,length);
}
int BasePVIntArray::get(int offset, int len, IntArrayData *data)
{
int n = len;
int length = PVArray::getLength();
if(offset+len > length) {
n = length-offset;
if(n<0) n = 0;
}
data->data = value;
data->offset = offset;
return n;
}
int BasePVIntArray::put(int offset,int len,
IntArray from,int fromOffset)
{
if(PVField::isImmutable()) {
PVField::message("field is immutable",errorMessage);
return 0;
}
if(from==value) return len;
if(len<1) return 0;
int length = PVArray::getLength();
int capacity = PVArray::getCapacity();
if(offset+len > length) {
int newlength = offset + len;
if(newlength>capacity) {
setCapacity(newlength);
newlength = PVArray::getCapacity();
len = newlength - offset;
if(len<=0) return 0;
}
length = newlength;
}
for(int i=0;i<len;i++) {
value[i+offset] = from[i+fromOffset];
}
PVArray::setLength(length);
PVField::postPut();
return len;
}
void BasePVIntArray::shareData(
epicsInt32 shareValue[],int capacity,int length)
{
delete[] value;
value = shareValue;
PVArray::setCapacityLength(capacity,length);
}
void BasePVIntArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVIntArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVIntArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count)
{
throw std::logic_error(notImplemented);
}
void BasePVIntArray::toString(StringBuilder buf)
{
toString(buf,1);
}
void BasePVIntArray::toString(StringBuilder buf,int indentLevel)
{
getConvert()->getString(buf,this,indentLevel);
PVField::toString(buf,indentLevel);
}
epicsBoolean BasePVIntArray::equals(PVField *pv)
{
return getConvert()->equals(this,pv);
}
}}
#endif /* BASEPVINTARRAY_H */
+153
View File
@@ -0,0 +1,153 @@
/*BasePVLongArray.h*/
#ifndef BASEPVLONGARRAY_H
#define BASEPVLONGARRAY_H
#include <cstddef>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <epicsTypes.h>
#include "pvData.h"
#include "factory.h"
#include "AbstractPVScalarArray.h"
namespace epics { namespace pvData {
PVLongArray::~PVLongArray() {}
PVLongArray::PVLongArray(PVStructure *parent,ScalarArrayConstPtr scalar)
: PVScalarArray(parent,scalar) {}
class BasePVLongArray : public PVLongArray {
public:
BasePVLongArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
virtual ~BasePVLongArray();
virtual void setCapacity(int capacity);
virtual int get(int offset, int length, LongArrayData *data) ;
virtual int put(int offset,int length,LongArray from,
int fromOffset);
virtual void shareData(epicsInt64 value[],int capacity,int length);
// from Serializable
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) ;
virtual void toString(StringBuilder buf);
virtual void toString(StringBuilder buf,int indentLevel);
virtual epicsBoolean equals(PVField *pv) ;
private:
epicsInt64 *value;
};
BasePVLongArray::BasePVLongArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
: PVLongArray(parent,scalarArray),value(new epicsInt64[0])
{ }
BasePVLongArray::~BasePVLongArray()
{
delete[] value;
}
void BasePVLongArray::setCapacity(int capacity)
{
if(PVArray::getCapacity()==capacity) return;
if(!PVArray::isCapacityMutable()) {
std::string message("not capacityMutable");
PVField::message(message, errorMessage);
return;
}
int length = PVArray::getLength();
if(length>capacity) length = capacity;
epicsInt64 *newValue = new epicsInt64[capacity];
for(int i=0; i<length; i++) newValue[i] = value[i];
delete[]value;
value = newValue;
PVArray::setCapacityLength(capacity,length);
}
int BasePVLongArray::get(int offset, int len, LongArrayData *data)
{
int n = len;
int length = PVArray::getLength();
if(offset+len > length) {
n = length-offset;
if(n<0) n = 0;
}
data->data = value;
data->offset = offset;
return n;
}
int BasePVLongArray::put(int offset,int len,
LongArray from,int fromOffset)
{
if(PVField::isImmutable()) {
PVField::message("field is immutable",errorMessage);
return 0;
}
if(from==value) return len;
if(len<1) return 0;
int length = PVArray::getLength();
int capacity = PVArray::getCapacity();
if(offset+len > length) {
int newlength = offset + len;
if(newlength>capacity) {
setCapacity(newlength);
newlength = PVArray::getCapacity();
len = newlength - offset;
if(len<=0) return 0;
}
length = newlength;
}
for(int i=0;i<len;i++) {
value[i+offset] = from[i+fromOffset];
}
PVArray::setLength(length);
PVField::postPut();
return len;
}
void BasePVLongArray::shareData(
epicsInt64 shareValue[],int capacity,int length)
{
delete[] value;
value = shareValue;
PVArray::setCapacityLength(capacity,length);
}
void BasePVLongArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVLongArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVLongArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count)
{
throw std::logic_error(notImplemented);
}
void BasePVLongArray::toString(StringBuilder buf)
{
toString(buf,1);
}
void BasePVLongArray::toString(StringBuilder buf,int indentLevel)
{
getConvert()->getString(buf,this,indentLevel);
PVField::toString(buf,indentLevel);
}
epicsBoolean BasePVLongArray::equals(PVField *pv)
{
return getConvert()->equals(this,pv);
}
}}
#endif /* BASEPVLONGARRAY_H */
+153
View File
@@ -0,0 +1,153 @@
/*BasePVShortArray.h*/
#ifndef BASEPVSHORTARRAY_H
#define BASEPVSHORTARRAY_H
#include <cstddef>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <epicsTypes.h>
#include "pvData.h"
#include "factory.h"
#include "AbstractPVScalarArray.h"
namespace epics { namespace pvData {
PVShortArray::~PVShortArray() {}
PVShortArray::PVShortArray(PVStructure *parent,ScalarArrayConstPtr scalar)
: PVScalarArray(parent,scalar) {}
class BasePVShortArray : public PVShortArray {
public:
BasePVShortArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
virtual ~BasePVShortArray();
virtual void setCapacity(int capacity);
virtual int get(int offset, int length, ShortArrayData *data) ;
virtual int put(int offset,int length,ShortArray from,
int fromOffset);
virtual void shareData(epicsInt16 value[],int capacity,int length);
// from Serializable
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) ;
virtual void toString(StringBuilder buf);
virtual void toString(StringBuilder buf,int indentLevel);
virtual epicsBoolean equals(PVField *pv) ;
private:
epicsInt16 *value;
};
BasePVShortArray::BasePVShortArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
: PVShortArray(parent,scalarArray),value(new epicsInt16[0])
{ }
BasePVShortArray::~BasePVShortArray()
{
delete[] value;
}
void BasePVShortArray::setCapacity(int capacity)
{
if(PVArray::getCapacity()==capacity) return;
if(!PVArray::isCapacityMutable()) {
std::string message("not capacityMutable");
PVField::message(message, errorMessage);
return;
}
int length = PVArray::getLength();
if(length>capacity) length = capacity;
epicsInt16 *newValue = new epicsInt16[capacity];
for(int i=0; i<length; i++) newValue[i] = value[i];
delete[]value;
value = newValue;
PVArray::setCapacityLength(capacity,length);
}
int BasePVShortArray::get(int offset, int len, ShortArrayData *data)
{
int n = len;
int length = PVArray::getLength();
if(offset+len > length) {
n = length-offset;
if(n<0) n = 0;
}
data->data = value;
data->offset = offset;
return n;
}
int BasePVShortArray::put(int offset,int len,
ShortArray from,int fromOffset)
{
if(PVField::isImmutable()) {
PVField::message("field is immutable",errorMessage);
return 0;
}
if(from==value) return len;
if(len<1) return 0;
int length = PVArray::getLength();
int capacity = PVArray::getCapacity();
if(offset+len > length) {
int newlength = offset + len;
if(newlength>capacity) {
setCapacity(newlength);
newlength = PVArray::getCapacity();
len = newlength - offset;
if(len<=0) return 0;
}
length = newlength;
}
for(int i=0;i<len;i++) {
value[i+offset] = from[i+fromOffset];
}
PVArray::setLength(length);
PVField::postPut();
return len;
}
void BasePVShortArray::shareData(
epicsInt16 shareValue[],int capacity,int length)
{
delete[] value;
value = shareValue;
PVArray::setCapacityLength(capacity,length);
}
void BasePVShortArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVShortArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVShortArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count)
{
throw std::logic_error(notImplemented);
}
void BasePVShortArray::toString(StringBuilder buf)
{
toString(buf,1);
}
void BasePVShortArray::toString(StringBuilder buf,int indentLevel)
{
getConvert()->getString(buf,this,indentLevel);
PVField::toString(buf,indentLevel);
}
epicsBoolean BasePVShortArray::equals(PVField *pv)
{
return getConvert()->equals(this,pv);
}
}}
#endif /* BASEPVSHORTARRAY_H */
+153
View File
@@ -0,0 +1,153 @@
/*BasePVStringArray.h*/
#ifndef BASEPVSTRINGARRAY_H
#define BASEPVSTRINGARRAY_H
#include <cstddef>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <epicsTypes.h>
#include "pvData.h"
#include "factory.h"
#include "AbstractPVScalarArray.h"
namespace epics { namespace pvData {
PVStringArray::~PVStringArray() {}
PVStringArray::PVStringArray(PVStructure *parent,ScalarArrayConstPtr scalar)
: PVScalarArray(parent,scalar) {}
class BasePVStringArray : public PVStringArray {
public:
BasePVStringArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
virtual ~BasePVStringArray();
virtual void setCapacity(int capacity);
virtual int get(int offset, int length, StringArrayData *data) ;
virtual int put(int offset,int length,StringArray from,
int fromOffset);
virtual void shareData(String value[],int capacity,int length);
// from Serializable
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) ;
virtual void toString(StringBuilder buf);
virtual void toString(StringBuilder buf,int indentLevel);
virtual epicsBoolean equals(PVField *pv) ;
private:
String *value;
};
BasePVStringArray::BasePVStringArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
: PVStringArray(parent,scalarArray),value(new String[0])
{ }
BasePVStringArray::~BasePVStringArray()
{
delete[] value;
}
void BasePVStringArray::setCapacity(int capacity)
{
if(PVArray::getCapacity()==capacity) return;
if(!PVArray::isCapacityMutable()) {
std::string message("not capacityMutable");
PVField::message(message, errorMessage);
return;
}
int length = PVArray::getLength();
if(length>capacity) length = capacity;
String *newValue = new String[capacity];
for(int i=0; i<length; i++) newValue[i] = value[i];
delete[]value;
value = newValue;
PVArray::setCapacityLength(capacity,length);
}
int BasePVStringArray::get(int offset, int len, StringArrayData *data)
{
int n = len;
int length = PVArray::getLength();
if(offset+len > length) {
n = length-offset;
if(n<0) n = 0;
}
data->data = value;
data->offset = offset;
return n;
}
int BasePVStringArray::put(int offset,int len,
StringArray from,int fromOffset)
{
if(PVField::isImmutable()) {
PVField::message("field is immutable",errorMessage);
return 0;
}
if(from==value) return len;
if(len<1) return 0;
int length = PVArray::getLength();
int capacity = PVArray::getCapacity();
if(offset+len > length) {
int newlength = offset + len;
if(newlength>capacity) {
setCapacity(newlength);
newlength = PVArray::getCapacity();
len = newlength - offset;
if(len<=0) return 0;
}
length = newlength;
}
for(int i=0;i<len;i++) {
value[i+offset] = from[i+fromOffset];
}
PVArray::setLength(length);
PVField::postPut();
return len;
}
void BasePVStringArray::shareData(
String shareValue[],int capacity,int length)
{
delete[] value;
value = shareValue;
PVArray::setCapacityLength(capacity,length);
}
void BasePVStringArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVStringArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void BasePVStringArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count)
{
throw std::logic_error(notImplemented);
}
void BasePVStringArray::toString(StringBuilder buf)
{
toString(buf,1);
}
void BasePVStringArray::toString(StringBuilder buf,int indentLevel)
{
getConvert()->getString(buf,this,indentLevel);
PVField::toString(buf,indentLevel);
}
epicsBoolean BasePVStringArray::equals(PVField *pv)
{
return getConvert()->equals(this,pv);
}
}}
#endif /* BASEPVSTRINGARRAY_H */
+1 -1
View File
@@ -21,7 +21,7 @@ namespace epics { namespace pvData {
};
PVStructurePvt::PVStructurePvt()
: numberFields(0), pvFields(0),extendsStructureName(0)
: numberFields(0), pvFields(0),extendsStructureName("")
{
}
+2 -1
View File
@@ -62,7 +62,8 @@ namespace epics { namespace pvData {
throw std::logic_error(notImplemented);
}
void PVStructureArray::shareData(StructureArrayData *from)
void PVStructureArray::shareData(
PVStructurePtrArray value,int capacity,int length)
{
throw std::logic_error(notImplemented);
}
+168 -4
View File
@@ -199,7 +199,7 @@ int Convert::fromString(PVScalarArray *pv, String from)
int num = fromStringArray(pv,0,length,valueArray,0);
if(num<length) length = num;
pv->setLength(length);
delete valueArray;
delete[] valueArray;
return length;
}
@@ -995,7 +995,171 @@ void convertStructure(StringBuilder buffer,PVStructure *data,int indentLevel)
void convertArray(StringBuilder buffer,PVScalarArray * pv,int indentLevel)
{
throw std::logic_error(notImplemented);
ScalarArrayConstPtr array = pv->getScalarArray();
ScalarType type = array->getElementType();
switch(type) {
case pvBoolean: {
PVBooleanArray *pvdata = (PVBooleanArray*)pv;
BooleanArrayData data = BooleanArrayData();
*buffer += "[";
for(int i=0; i < pvdata->getLength(); i++) {
if(i!=0) *buffer += ",";
int num = pvdata->get(i,1,&data);
if(num==1) {
epicsBoolean * value = data.data;
if(value[data.offset]) {
*buffer += "true";
} else {
*buffer += "false";
}
} else {
*buffer += "???? ";
}
}
*buffer += "]";
break;
}
case pvByte: {
PVByteArray *pvdata = (PVByteArray*)pv;
ByteArrayData data = ByteArrayData();
*buffer += "[";
for(int i=0; i < pvdata->getLength(); i++) {
if(i!=0) *buffer += ",";
int num = pvdata->get(i,1,&data);
if(num==1) {
int val = data.data[data.offset];
char buf[16];
sprintf(buf,"%d",val);
*buffer += buf;
} else {
*buffer += "???? ";
}
}
*buffer += "]";
break;
}
case pvShort: {
PVShortArray *pvdata = (PVShortArray*)pv;
ShortArrayData data = ShortArrayData();
*buffer += "[";
for(int i=0; i < pvdata->getLength(); i++) {
if(i!=0) *buffer += ',';
int num = pvdata->get(i,1,&data);
if(num==1) {
int val = data.data[data.offset];
char buf[16];
sprintf(buf,"%d",val);
*buffer += buf;
} else {
*buffer += "???? ";
}
}
*buffer += "]";
break;
}
case pvInt: {
PVIntArray *pvdata = (PVIntArray*)pv;
IntArrayData data = IntArrayData();
*buffer += "[";
for(int i=0; i < pvdata->getLength(); i++) {
if(i!=0) *buffer += ',';
int num = pvdata->get(i,1,&data);
if(num==1) {
int val = data.data[data.offset];
char buf[16];
sprintf(buf,"%d",val);
*buffer += buf;
} else {
*buffer += "???? ";
}
}
*buffer += "]";
break;
}
case pvLong: {
PVLongArray *pvdata = (PVLongArray*)pv;
LongArrayData data = LongArrayData();
*buffer += "[";
for(int i=0; i < pvdata->getLength(); i++) {
if(i!=0) *buffer += ',';
int num = pvdata->get(i,1,&data);
if(num==1) {
long int val = data.data[data.offset];
char buf[16];
sprintf(buf,"%ld",val);
*buffer += buf;
} else {
*buffer += "???? ";
}
}
*buffer += "]";
break;
}
case pvFloat: {
PVFloatArray *pvdata = (PVFloatArray*)pv;
FloatArrayData data = FloatArrayData();
*buffer += "[";
for(int i=0; i < pvdata->getLength(); i++) {
if(i!=0) *buffer += ',';
int num = pvdata->get(i,1,&data);
if(num==1) {
float val = data.data[data.offset];
char buf[16];
sprintf(buf,"%f",val);
*buffer += buf;
} else {
*buffer += "???? ";
}
}
*buffer += "]";
break;
}
case pvDouble: {
PVDoubleArray *pvdata = (PVDoubleArray*)pv;
DoubleArrayData data = DoubleArrayData();
*buffer += "[";
for(int i=0; i < pvdata->getLength(); i++) {
if(i!=0) *buffer += ',';
int num = pvdata->get(i,1,&data);
if(num==1) {
double val = data.data[data.offset];
char buf[16];
sprintf(buf,"%lf",val);
*buffer += buf;
} else {
*buffer += "???? ";
}
}
*buffer += ("]");
break;
}
case pvString: {
PVStringArray *pvdata = (PVStringArray*)pv;
StringArrayData data = StringArrayData();
*buffer += "[";
for(int i=0; i < pvdata->getLength(); i++) {
if(i!=0) *buffer += ",";
int num = pvdata->get(i,1,&data);
StringPtrArray value = data.data;
if(num==1) {
if(value[data.offset].length()>0) {
*buffer += value[data.offset].c_str();
} else {
*buffer += "null";
}
} else {
*buffer += "null";
}
}
*buffer += "]";
break;
}
default:
*buffer += " array element is unknown ScalarType";
}
if(pv->isImmutable()) {
*buffer += " immutable ";
}
}
void convertStructureArray(StringBuilder buffer,PVStructureArray * pvdata,int indentLevel)
@@ -1019,8 +1183,8 @@ public:
};
Convert * getConvert() {
static Mutex *mutex = new Mutex();
Lock xx(mutex);
static Mutex mutex = Mutex();
Lock xx(&mutex);
if(convert==0){
convert = new ConvertExt();
+3 -3
View File
@@ -110,7 +110,7 @@ namespace epics { namespace pvData {
BaseScalarArray::BaseScalarArray
(String fieldName,ScalarType elementType)
: BaseField(fieldName,scalar),elementType(elementType){}
: BaseField(fieldName,scalarArray),elementType(elementType){}
BaseScalarArray::~BaseScalarArray() {}
@@ -305,8 +305,8 @@ namespace epics { namespace pvData {
};
FieldCreate * getFieldCreate() {
static Mutex *mutex = new Mutex();
Lock xx(mutex);
static Mutex mutex = Mutex();
Lock xx(&mutex);
if(instance==0) instance = new FieldCreateExt();
return instance;
+7
View File
@@ -16,7 +16,14 @@ INC += BasePVLong.h
INC += BasePVFloat.h
INC += BasePVDouble.h
INC += BasePVString.h
INC += BasePVBooleanArray.h
INC += BasePVByteArray.h
INC += BasePVShortArray.h
INC += BasePVIntArray.h
INC += BasePVLongArray.h
INC += BasePVFloatArray.h
INC += BasePVDoubleArray.h
INC += BasePVString.h
INC += BasePVStructure.h
INC += BasePVStructureArray.h
LIBSRCS += TypeFunc.cpp
+23 -9
View File
@@ -21,7 +21,14 @@
#include "BasePVDouble.h"
#include "BasePVString.h"
#include "AbstractPVArray.h"
#include "BasePVBooleanArray.h"
#include "BasePVByteArray.h"
#include "BasePVShortArray.h"
#include "BasePVIntArray.h"
#include "BasePVLongArray.h"
#include "BasePVFloatArray.h"
#include "BasePVDoubleArray.h"
#include "BasePVStringArray.h"
#include "BasePVStructure.h"
#include "BasePVStructureArray.h"
@@ -121,15 +128,22 @@ namespace epics { namespace pvData {
ScalarArrayConstPtr scalarArray)
{
switch(scalarArray->getElementType()) {
case pvBoolean: break;
case pvByte: break;
case pvShort: break;
case pvInt: break;
case pvLong: break;
case pvFloat: break;
case pvBoolean:
return new BasePVBooleanArray(parent,scalarArray);
case pvByte:
return new BasePVByteArray(parent,scalarArray);
case pvShort:
return new BasePVShortArray(parent,scalarArray);
case pvInt:
return new BasePVIntArray(parent,scalarArray);
case pvLong:
return new BasePVLongArray(parent,scalarArray);
case pvFloat:
return new BasePVFloatArray(parent,scalarArray);
case pvDouble:
return new BasePVDoubleArray(parent,scalarArray);
case pvString: break;
case pvString:
return new BasePVStringArray(parent,scalarArray);
}
throw std::logic_error(notImplemented);
@@ -178,8 +192,8 @@ namespace epics { namespace pvData {
};
PVDataCreate * getPVDataCreate() {
static Mutex *mutex = new Mutex();
Lock xx(mutex);
static Mutex mutex = Mutex();
Lock xx(&mutex);
if(pvDataCreate==0) pvDataCreate = new PVDataCreateExt();
return pvDataCreate;
+2 -2
View File
@@ -71,8 +71,8 @@ static String notImplemented("not implemented");
};
StandardField * getStandardField() {
static Mutex *mutex = new Mutex();
Lock xx(mutex);
static Mutex mutex = Mutex();
Lock xx(&mutex);
if(instance==0) instance = new StandardFieldExt();
return instance;
+97 -92
View File
@@ -58,6 +58,7 @@ namespace epics { namespace pvData {
};
class PostHandler {
public:
virtual void postPut() = 0;
};
@@ -81,7 +82,7 @@ namespace epics { namespace pvData {
void setPostHandler(PostHandler *postHandler);
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) ;
virtual epicsBoolean equals(PVField *pv) = 0;
virtual epicsBoolean equals(PVField *pv) = 0;
protected:
PVField(PVStructure *parent,FieldConstPtr field);
void replaceStructure();
@@ -95,8 +96,8 @@ namespace epics { namespace pvData {
public:
virtual ~PVScalar();
ScalarConstPtr getScalar() ;
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
protected:
PVScalar(PVStructure *parent,ScalarConstPtr scalar);
};
@@ -107,19 +108,20 @@ namespace epics { namespace pvData {
int getLength() ;
void setLength(int length);
int getCapacity() ;
epicsBoolean isCapacityImmutable() ;
void setCapacityImmutable(epicsBoolean isMutable);
epicsBoolean isCapacityMutable() ;
void setCapacityMutable(epicsBoolean isMutable);
virtual void setCapacity(int capacity) = 0;
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher) = 0;
SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher) = 0;
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) = 0;
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
SerializableControl *pflusher, int offset, int count) = 0;
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
protected:
PVArray(PVStructure *parent,FieldConstPtr field);
void setCapacityLength(int capacity,int length);
private:
class PVArrayPvt * pImpl;
};
@@ -131,13 +133,13 @@ namespace epics { namespace pvData {
ScalarArrayConstPtr getScalarArray() ;
virtual void setCapacity(int capacity) = 0;
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher) = 0;
SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher) = 0;
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) = 0;
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
SerializableControl *pflusher, int offset, int count) = 0;
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
protected:
PVScalarArray(PVStructure *parent,ScalarArrayConstPtr scalarArray);
private:
@@ -154,21 +156,22 @@ namespace epics { namespace pvData {
class PVStructureArray : public PVArray {
public:
virtual ~PVStructureArray();
virtual StructureArrayConstPtr getStructureArray() ;
virtual StructureArrayConstPtr getStructureArray() = 0;
virtual int get(int offset, int length,
StructureArrayData *data) ;
StructureArrayData *data) = 0;
virtual int put(int offset,int length,
PVStructurePtrArray from, int fromOffset);
virtual void shareData(StructureArrayData *from);
PVStructurePtrArray from, int fromOffset) = 0;
virtual void shareData(
PVStructurePtrArray value,int capacity,int length) = 0;
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher) ;
SerializableControl *pflusher) = 0 ;
virtual void deserialize(ByteBuffer *buffer,
DeserializableControl *pflusher);
DeserializableControl *pflusher) = 0;
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count) ;
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) ;
virtual epicsBoolean equals(PVField *pv) ;
SerializableControl *pflusher, int offset, int count) = 0;
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual epicsBoolean equals(PVField *pv) = 0;
protected:
PVStructureArray(PVStructure *parent,
StructureArrayConstPtr structureArray);
@@ -226,7 +229,7 @@ namespace epics { namespace pvData {
class PVBoolean : public PVScalar {
public:
virtual ~PVBoolean();
virtual epicsBoolean get() = 0;
virtual epicsBoolean get() = 0;
virtual void put(epicsBoolean value) = 0;
protected:
PVBoolean(PVStructure *parent,ScalarConstPtr scalar)
@@ -237,7 +240,7 @@ namespace epics { namespace pvData {
class PVByte : public PVScalar {
public:
virtual ~PVByte();
virtual epicsInt8 get() = 0;
virtual epicsInt8 get() = 0;
virtual void put(epicsInt8 value) = 0;
protected:
PVByte(PVStructure *parent,ScalarConstPtr scalar)
@@ -248,7 +251,7 @@ namespace epics { namespace pvData {
class PVShort : public PVScalar {
public:
virtual ~PVShort();
virtual epicsInt16 get() = 0;
virtual epicsInt16 get() = 0;
virtual void put(epicsInt16 value) = 0;
protected:
PVShort(PVStructure *parent,ScalarConstPtr scalar)
@@ -259,7 +262,7 @@ namespace epics { namespace pvData {
class PVInt : public PVScalar{
public:
virtual ~PVInt();
virtual epicsInt32 get() = 0;
virtual epicsInt32 get() = 0;
virtual void put(epicsInt32 value) = 0;
protected:
PVInt(PVStructure *parent,ScalarConstPtr scalar)
@@ -270,7 +273,7 @@ namespace epics { namespace pvData {
class PVLong : public PVScalar {
public:
virtual ~PVLong();
virtual epicsInt64 get() = 0;
virtual epicsInt64 get() = 0;
virtual void put(epicsInt64 value) = 0;
protected:
PVLong(PVStructure *parent,ScalarConstPtr scalar)
@@ -281,7 +284,7 @@ namespace epics { namespace pvData {
class PVFloat : public PVScalar {
public:
virtual ~PVFloat();
virtual float get() = 0;
virtual float get() = 0;
virtual void put(float value) = 0;
protected:
PVFloat(PVStructure *parent,ScalarConstPtr scalar)
@@ -292,7 +295,7 @@ namespace epics { namespace pvData {
class PVDouble : public PVScalar {
public:
virtual ~PVDouble();
virtual double get() = 0;
virtual double get() = 0;
virtual void put(double value) = 0;
protected:
PVDouble(PVStructure *parent,ScalarConstPtr scalar)
@@ -303,7 +306,7 @@ namespace epics { namespace pvData {
class PVString : public PVScalar {
public:
virtual ~PVString();
virtual String get() = 0;
virtual String get() = 0;
virtual void put(String value) = 0;
protected:
PVString(PVStructure *parent,ScalarConstPtr scalar)
@@ -322,15 +325,15 @@ namespace epics { namespace pvData {
class PVBooleanArray : public PVScalarArray {
public:
virtual ~PVBooleanArray();
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) ;
virtual int get(int offset, int length, BooleanArrayData *data) ;
virtual int put(int offset,int length, BooleanArray from, int fromOffset);
virtual void shareData(BooleanArrayData *from);
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void toString(StringBuilder buf) = 0 ;
virtual void toString(StringBuilder buf,int indentLevel) = 0 ;
virtual int get(int offset, int length, BooleanArrayData *data) = 0;
virtual int put(int offset,int length, BooleanArray from, int fromOffset) = 0;
virtual void shareData(epicsBoolean value[],int capacity,int length) = 0;
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0;
protected:
PVBooleanArray(PVStructure *parent,ScalarConstPtr scalar);
PVBooleanArray(PVStructure *parent,ScalarArrayConstPtr scalar);
private:
};
@@ -345,15 +348,15 @@ namespace epics { namespace pvData {
class PVByteArray : public PVScalarArray {
public:
virtual ~PVByteArray();
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) ;
virtual int get(int offset, int length, ByteArrayData *data) ;
virtual int put(int offset,int length, ByteArray from, int fromOffset);
virtual void shareData(ByteArrayData *from);
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void toString(StringBuilder buf) = 0 ;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual int get(int offset, int length, ByteArrayData *data) = 0;
virtual int put(int offset,int length, ByteArray from, int fromOffset) = 0;
virtual void shareData(epicsInt8 value[],int capacity,int length) = 0;
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0;
protected:
PVByteArray(PVStructure *parent,ScalarConstPtr scalar);
PVByteArray(PVStructure *parent,ScalarArrayConstPtr scalar);
private:
};
@@ -368,15 +371,15 @@ namespace epics { namespace pvData {
class PVShortArray : public PVScalarArray {
public:
virtual ~PVShortArray();
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) ;
virtual int get(int offset, int length, ShortArrayData *data) ;
virtual int put(int offset,int length, ShortArray from, int fromOffset);
virtual void shareData(ShortArrayData *from);
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual int get(int offset, int length, ShortArrayData *data) = 0;
virtual int put(int offset,int length, ShortArray from, int fromOffset) = 0;
virtual void shareData(epicsInt16 value[],int capacity,int length) = 0;
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0;
protected:
PVShortArray(PVStructure *parent,ScalarConstPtr scalar);
PVShortArray(PVStructure *parent,ScalarArrayConstPtr scalar);
private:
};
@@ -390,15 +393,15 @@ namespace epics { namespace pvData {
class PVIntArray : public PVScalarArray {
public:
virtual ~PVIntArray();
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) ;
virtual int get(int offset, int length, IntArrayData *data) ;
virtual int put(int offset,int length, IntArray from, int fromOffset);
virtual void shareData(IntArrayData *from);
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual int get(int offset, int length, IntArrayData *data) = 0;
virtual int put(int offset,int length, IntArray from, int fromOffset)= 0;
virtual void shareData(epicsInt32 value[],int capacity,int length)= 0;
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher)= 0;
protected:
PVIntArray(PVStructure *parent,ScalarConstPtr scalar);
PVIntArray(PVStructure *parent,ScalarArrayConstPtr scalar);
private:
};
@@ -413,15 +416,15 @@ namespace epics { namespace pvData {
class PVLongArray : public PVScalarArray {
public:
virtual ~PVLongArray();
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) ;
virtual int get(int offset, int length, LongArrayData *data) ;
virtual int put(int offset,int length, LongArray from, int fromOffset);
virtual void shareData(LongArrayData *from);
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual int get(int offset, int length, LongArrayData *data) = 0;
virtual int put(int offset,int length, LongArray from, int fromOffset)= 0;
virtual void shareData(epicsInt64 value[],int capacity,int length)= 0;
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher)= 0;
protected:
PVLongArray(PVStructure *parent,ScalarConstPtr scalar);
PVLongArray(PVStructure *parent,ScalarArrayConstPtr scalar);
private:
};
@@ -436,15 +439,15 @@ namespace epics { namespace pvData {
class PVFloatArray : public PVScalarArray {
public:
virtual ~PVFloatArray();
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) ;
virtual int get(int offset, int length, FloatArrayData *data) ;
virtual int put(int offset,int length, FloatArray from, int fromOffset);
virtual void shareData(FloatArrayData *from);
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual int get(int offset, int length, FloatArrayData *data) = 0;
virtual int put(int offset,int length, FloatArray from, int fromOffset)= 0;
virtual void shareData(float value[],int capacity,int length)= 0;
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher)= 0;
protected:
PVFloatArray(PVStructure *parent,ScalarConstPtr scalar);
PVFloatArray(PVStructure *parent,ScalarArrayConstPtr scalar);
private:
};
@@ -452,6 +455,8 @@ namespace epics { namespace pvData {
typedef double * DoubleArray;
class DoubleArrayData {
public:
DoubleArrayData(){}
~DoubleArrayData(){};
DoubleArray data;
int offset;
};
@@ -459,12 +464,12 @@ namespace epics { namespace pvData {
class PVDoubleArray : public PVScalarArray {
public:
virtual ~PVDoubleArray();
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual int get(int offset, int length, DoubleArrayData *data) = 0;
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual int get(int offset, int length, DoubleArrayData *data) = 0;
virtual int put(int offset,int length, DoubleArray from, int fromOffset) = 0;
virtual void shareData(DoubleArrayData *from) = 0;
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
virtual void shareData(double value[],int capacity,int length) = 0;
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0;
protected:
PVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalar);
@@ -482,15 +487,15 @@ namespace epics { namespace pvData {
class PVStringArray : public PVScalarArray {
public:
virtual ~PVStringArray();
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel) ;
virtual int get(int offset, int length, StringArrayData *data) ;
virtual int put(int offset,int length, StringArray from, int fromOffset);
virtual void shareData(StringArrayData from);
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher);
virtual void toString(StringBuilder buf) = 0;
virtual void toString(StringBuilder buf,int indentLevel) = 0;
virtual int get(int offset, int length, StringArrayData *data) = 0;
virtual int put(int offset,int length, StringArray from, int fromOffset)= 0;
virtual void shareData(String value[],int capacity,int length)= 0;
virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0;
virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher)= 0;
protected:
PVStringArray(PVStructure *parent,ScalarConstPtr scalar);
PVStringArray(PVStructure *parent,ScalarArrayConstPtr scalar);
private:
};
+8
View File
@@ -14,6 +14,14 @@ PROD_HOST += testPVScalar
testPVScalar_SRCS += testPVScalar.cpp
testPVScalar_LIBS += pvFactory
PROD_HOST += testPVScalarArray
testPVScalarArray_SRCS += testPVScalarArray.cpp
testPVScalarArray_LIBS += pvFactory
PROD_HOST += testSimpleStructure
testSimpleStructure_SRCS += testSimpleStructure.cpp
testSimpleStructure_LIBS += pvFactory
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE
+2 -2
View File
@@ -1,5 +1,5 @@
/* pvDataMain.cpp */
/* Author: Marty Kraimer Date: 17MAR2000 */
/* testIntrospect.cpp */
/* Author: Marty Kraimer Date: 2010.09 */
#include <stddef.h>
#include <stdlib.h>
+2 -2
View File
@@ -1,5 +1,5 @@
/* pvDataMain.cpp */
/* Author: Marty Kraimer Date: 17MAR2000 */
/* testPVscalar.cpp */
/* Author: Marty Kraimer Date: 2010.09 */
#include <stddef.h>
#include <stdlib.h>
+271
View File
@@ -0,0 +1,271 @@
/* testPVArray.cpp */
/* Author: Marty Kraimer Date: 2010.09 */
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "requester.h"
#include "pvIntrospect.h"
#include "pvData.h"
#include "standardField.h"
using namespace epics::pvData;
static FieldCreate * pfieldCreate = 0;
static PVDataCreate *pvDataCreate = 0;
static String buffer("");
void testBooleanArray() {
printf("\ntestBooleanArray\n");
PVScalarArray *pvScalarArray =
getStandardField()->scalarArrayValue(pvBoolean);
PVBooleanArray *pvValue = (PVBooleanArray *)pvScalarArray;
int length = 5;
epicsBoolean *value = new epicsBoolean[length];
for(int i=0; i<length; i++) value[i] = epicsTrue;
pvValue->put(0,length,value,0);
BooleanArrayData data = BooleanArrayData();
pvValue->get(0,length,&data);
epicsBoolean * getValue = data.data;
printf("(orig,get):");
for(int i=0; i< length; i++) {
printf("(%s,%s) ",
((value[i]==epicsTrue) ? "true" : "false"),
((getValue[i]==epicsTrue) ? "true" : "false"));
}
printf("\n");
FieldConstPtr field = pvValue->getField();
buffer.clear();
field->toString(&buffer);
printf("%s\n",buffer.c_str());
buffer.clear();
buffer += "pv ";
pvValue->toString(&buffer);
printf("%s\n",buffer.c_str());
delete pvValue;
delete[] value;
}
void testByteArray() {
printf("\ntestByteArray\n");
PVScalarArray *pvScalarArray =
getStandardField()->scalarArrayValue(pvByte);
PVByteArray *pvValue = (PVByteArray *)pvScalarArray;
int length = 5;
epicsInt8 *value = new epicsInt8[length];
for(int i=0; i<length; i++) value[i] = i;
pvValue->put(0,length,value,0);
ByteArrayData data = ByteArrayData();
pvValue->get(0,length,&data);
epicsInt8 * getValue = data.data;
printf("(orig,get):");
for(int i=0; i< length; i++) {
printf("(%d,%d) ",(int)value[i],(int)getValue[i]);
}
printf("\n");
FieldConstPtr field = pvValue->getField();
buffer.clear();
field->toString(&buffer);
printf("%s\n",buffer.c_str());
buffer.clear();
buffer += "pv ";
pvValue->toString(&buffer);
printf("%s\n",buffer.c_str());
delete pvValue;
delete[] value;
}
void testShortArray() {
printf("\ntestShortArray\n");
PVScalarArray *pvScalarArray =
getStandardField()->scalarArrayValue(pvShort);
PVShortArray *pvValue = (PVShortArray *)pvScalarArray;
int length = 5;
epicsInt16 *value = new epicsInt16[length];
for(int i=0; i<length; i++) value[i] = i;
pvValue->put(0,length,value,0);
ShortArrayData data = ShortArrayData();
pvValue->get(0,length,&data);
epicsInt16 * getValue = data.data;
printf("(orig,get):");
for(int i=0; i< length; i++) {
printf("(%d,%d) ",(int)value[i],(int)getValue[i]);
}
printf("\n");
FieldConstPtr field = pvValue->getField();
buffer.clear();
field->toString(&buffer);
printf("%s\n",buffer.c_str());
buffer.clear();
buffer += "pv ";
pvValue->toString(&buffer);
printf("%s\n",buffer.c_str());
delete pvValue;
delete[] value;
}
void testIntArray() {
printf("\ntestIntArray\n");
PVScalarArray *pvScalarArray =
getStandardField()->scalarArrayValue(pvInt);
PVIntArray *pvValue = (PVIntArray *)pvScalarArray;
int length = 5;
epicsInt32 *value = new epicsInt32[length];
for(int i=0; i<length; i++) value[i] = i;
pvValue->put(0,length,value,0);
IntArrayData data = IntArrayData();
pvValue->get(0,length,&data);
epicsInt32 * getValue = data.data;
printf("(orig,get):");
for(int i=0; i< length; i++) {
printf("(%d,%d) ",value[i],getValue[i]);
}
printf("\n");
FieldConstPtr field = pvValue->getField();
buffer.clear();
field->toString(&buffer);
printf("%s\n",buffer.c_str());
buffer.clear();
buffer += "pv ";
pvValue->toString(&buffer);
printf("%s\n",buffer.c_str());
delete pvValue;
delete[] value;
}
void testLongArray() {
printf("\ntestLongArray\n");
PVScalarArray *pvScalarArray =
getStandardField()->scalarArrayValue(pvLong);
PVLongArray *pvValue = (PVLongArray *)pvScalarArray;
int length = 5;
epicsInt64 *value = new epicsInt64[length];
for(int i=0; i<length; i++) value[i] = i;
pvValue->put(0,length,value,0);
LongArrayData data = LongArrayData();
pvValue->get(0,length,&data);
epicsInt64 * getValue = data.data;
printf("(orig,get):");
for(int i=0; i< length; i++) {
printf("(%ld,%ld) ",(long int)value[i],(long int)getValue[i]);
}
printf("\n");
FieldConstPtr field = pvValue->getField();
buffer.clear();
field->toString(&buffer);
printf("%s\n",buffer.c_str());
buffer.clear();
buffer += "pv ";
pvValue->toString(&buffer);
printf("%s\n",buffer.c_str());
delete pvValue;
delete[] value;
}
void testFloatArray() {
printf("\ntestFloatArray\n");
PVScalarArray *pvScalarArray =
getStandardField()->scalarArrayValue(pvFloat);
PVFloatArray *pvValue = (PVFloatArray *)pvScalarArray;
int length = 5;
float *value = new float[length];
for(int i=0; i<length; i++) value[i] = i;
pvValue->put(0,length,value,0);
FloatArrayData data = FloatArrayData();
pvValue->get(0,length,&data);
float * getValue = data.data;
printf("(orig,get):");
for(int i=0; i< length; i++) {
printf("(%f,%f) ",value[i],getValue[i]);
}
printf("\n");
FieldConstPtr field = pvValue->getField();
buffer.clear();
field->toString(&buffer);
printf("%s\n",buffer.c_str());
buffer.clear();
buffer += "pv ";
pvValue->toString(&buffer);
printf("%s\n",buffer.c_str());
delete pvValue;
delete[] value;
}
void testDoubleArray() {
printf("\ntestDoubleArray\n");
PVScalarArray *pvScalarArray =
getStandardField()->scalarArrayValue(pvDouble);
PVDoubleArray *pvValue = (PVDoubleArray *)pvScalarArray;
int length = 5;
double *value = new double[length];
for(int i=0; i<length; i++) value[i] = i;
pvValue->put(0,length,value,0);
DoubleArrayData data = DoubleArrayData();
pvValue->get(0,length,&data);
double * getValue = data.data;
printf("(orig,get):");
for(int i=0; i< length; i++) {
printf("(%f,%f) ",value[i],getValue[i]);
}
printf("\n");
FieldConstPtr field = pvValue->getField();
buffer.clear();
field->toString(&buffer);
printf("%s\n",buffer.c_str());
buffer.clear();
buffer += "pv ";
pvValue->toString(&buffer);
printf("%s\n",buffer.c_str());
delete pvValue;
delete[] value;
}
void testStringArray() {
printf("\ntestStringArray\n");
PVScalarArray *pvScalarArray =
getStandardField()->scalarArrayValue(pvString);
PVStringArray *pvValue = (PVStringArray *)pvScalarArray;
int length = 5;
String *value = new String[length];
for(int i=0; i<length; i++) {
char buf[16];
sprintf(buf,"string%d",i);
value[i] = buf;
}
pvValue->put(0,length,value,0);
StringArrayData data = StringArrayData();
pvValue->get(0,length,&data);
String * getValue = data.data;
printf("(orig,get):");
for(int i=0; i< length; i++) {
printf("(%s,%s) ",value[i].c_str(),getValue[i].c_str());
}
printf("\n");
FieldConstPtr field = pvValue->getField();
buffer.clear();
field->toString(&buffer);
printf("%s\n",buffer.c_str());
buffer.clear();
buffer += "pv ";
pvValue->toString(&buffer);
printf("%s\n",buffer.c_str());
delete pvValue;
delete[] value;
}
int main(int argc,char *argv[])
{
pfieldCreate = getFieldCreate();
pvDataCreate = getPVDataCreate();
testBooleanArray();
testByteArray();
testShortArray();
testIntArray();
testLongArray();
testFloatArray();
testDoubleArray();
testStringArray();
printf("main returning\n");
return(0);
}
+75
View File
@@ -0,0 +1,75 @@
/* testSimpleStructure.cpp */
/* Author: Marty Kraimer Date: 2010.09 */
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "requester.h"
#include "pvIntrospect.h"
#include "pvData.h"
#include "standardField.h"
using namespace epics::pvData;
static FieldCreate * pfieldCreate = 0;
static PVDataCreate *pvDataCreate = 0;
static String buffer("");
void testSimpleStructure() {
printf("\ntestSimpleStructure\n");
String secondsPastEpoch("secondsPastEpoch");
String nanoSeconds("nanoSeconds");
String timeStamp("timeStamp");
String severity("severity");
String message("message");
String alarm("alarm");
String value("value");
String top("top");
ScalarConstPtr pseconds = pfieldCreate->createScalar(
secondsPastEpoch,pvLong);
ScalarConstPtr pnano = pfieldCreate->createScalar(
nanoSeconds,pvInt);
FieldConstPtrArray fields = new FieldConstPtr[2];
fields[0] = pseconds;
fields[1] = pnano;
StructureConstPtr ptimeStamp = pfieldCreate->createStructure(
timeStamp,2,fields);
ScalarConstPtr pseverity = pfieldCreate->createScalar(
severity,pvInt);
ScalarConstPtr pmessage = pfieldCreate->createScalar(
message,pvString);
fields = new FieldConstPtr[2];
fields[0] = pseverity;
fields[1] = pmessage;
StructureConstPtr palarm = pfieldCreate->createStructure(
alarm,2,fields);
ScalarConstPtr pvalue = pfieldCreate->createScalar(
value,pvDouble);
fields = new FieldConstPtr[3];
fields[0] = ptimeStamp;
fields[1] = palarm;
fields[2] = pvalue;
StructureConstPtr ptop = pfieldCreate->createStructure(
top,3,fields);
buffer.clear();
ptop->toString(&buffer);
printf("%s\n",buffer.c_str());
PVStructure *pvStructure = pvDataCreate->createPVStructure( 0, ptop);
buffer.clear();
pvStructure->toString(&buffer);
printf("%s\n",buffer.c_str());
}
int main(int argc,char *argv[])
{
pfieldCreate = getFieldCreate();
pvDataCreate = getPVDataCreate();
testSimpleStructure();
return(0);
}