This commit is contained in:
Matej Sekoranja
2010-10-25 00:21:36 +02:00
12 changed files with 619 additions and 524 deletions
-30
View File
@@ -1,30 +0,0 @@
#RELEASE Location of external products
#
# IF YOU MAKE ANY CHANGES to this file you MUST at least run
# "gnumake" in this directory afterwards; you usually need
# to run "gnumake rebuild" in the application's top level
# directory each time this file is changed.
#
# NOTE: The build does not check dependencies against files
# that are outside this application, thus you should run
# "gnumake distclean install" in the top directory each time
# EPICS_BASE, SNCSEQ, or any other external module defined
# in the RELEASE file is rebuilt.
#
# Host/target specific settings can be specified in files named
# RELEASE.$(EPICS_HOST_ARCH).Common
# RELEASE.Common.$(T_A)
# RELEASE.$(EPICS_HOST_ARCH).$(T_A)
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
#If using the sequencer, point SNCSEQ at its top directory:
#SNCSEQ=$(EPICS_BASE)/../modules/soft/seq
# EPICS_BASE usually appears last so other apps can override stuff:
EPICS_BASE=/home/install/epics/base
#Capfast users may need the following definitions
#CAPFAST_TEMPLATES=
#SCH2EDIF_PATH=
+233 -178
View File
@@ -10,206 +10,261 @@
namespace epics { namespace pvData {
static String notImplemented("not implemented");
class PVFieldPvt {
public:
PVFieldPvt(PVStructure *parent,FieldConstPtr field);
~PVFieldPvt();
PVStructure *parent;
FieldConstPtr field;
int fieldOffset;
int nextFieldOffset;
PVAuxInfo *pvAuxInfo;
bool immutable;
Requester *requester;
PostHandler *postHandler;
};
class PVFieldPvt {
public:
PVFieldPvt(PVStructure *parent,FieldConstPtr field);
~PVFieldPvt();
PVStructure *parent;
FieldConstPtr field;
int fieldOffset;
int nextFieldOffset;
PVAuxInfo *pvAuxInfo;
bool immutable;
Requester *requester;
PostHandler *postHandler;
};
PVFieldPvt::PVFieldPvt(PVStructure *parent,FieldConstPtr field)
: parent(parent),field(field),
fieldOffset(0), nextFieldOffset(0),
pvAuxInfo(0),
immutable(epicsFalse),requester(0),postHandler(0)
{
delete pvAuxInfo;
field->incReferenceCount();
}
PVFieldPvt::PVFieldPvt(PVStructure *parent,FieldConstPtr field)
: parent(parent),field(field),
fieldOffset(0), nextFieldOffset(0),
pvAuxInfo(0),
immutable(epicsFalse),requester(0),postHandler(0)
{
delete pvAuxInfo;
field->incReferenceCount();
}
PVFieldPvt::~PVFieldPvt()
{
field->decReferenceCount();
}
PVFieldPvt::~PVFieldPvt()
{
field->decReferenceCount();
}
PVField::PVField(PVStructure *parent,FieldConstPtr field)
: pImpl(new PVFieldPvt(parent,field))
{}
PVField::PVField(PVStructure *parent,FieldConstPtr field)
: pImpl(new PVFieldPvt(parent,field))
{}
PVField::~PVField()
{
delete pImpl;
}
PVField::~PVField()
{
delete pImpl;
}
String PVField::getRequesterName()
{
static String none("none");
if(pImpl->requester!=0) return pImpl->requester->getRequesterName();
return none;
}
String PVField::getRequesterName()
{
static String none("none");
if(pImpl->requester!=0) return pImpl->requester->getRequesterName();
return none;
}
void PVField::message(String message,MessageType messageType)
{
if(pImpl->requester) {
pImpl->requester->message(message,messageType);
} else {
printf("%s %s %s\n",
messageTypeName[messageType].c_str(),
pImpl->field->getFieldName().c_str(),
message.c_str());
}
}
void PVField::setRequester(Requester *prequester)
{
static String requesterPresent =
"Logic Error. requester is already present";
if(pImpl->requester==0) {
pImpl->requester = prequester;
return;
}
throw std::logic_error(requesterPresent);
}
void PVField::message(String message,MessageType messageType)
{
if(pImpl->requester) {
pImpl->requester->message(message,messageType);
} else {
printf("%s %s %s\n",
messageTypeName[messageType].c_str(),
pImpl->field->getFieldName().c_str(),
message.c_str());
}
}
void PVField::setRequester(Requester *prequester)
{
static String requesterPresent =
"Logic Error. requester is already present";
if(pImpl->requester==0) {
pImpl->requester = prequester;
return;
}
throw std::logic_error(requesterPresent);
}
int PVField::getFieldOffset()
{
if(pImpl->nextFieldOffset==0) computeOffset(this);
return pImpl->fieldOffset;
}
int PVField::getFieldOffset()
{
if(pImpl->nextFieldOffset==0) computeOffset(this);
return pImpl->fieldOffset;
}
int PVField::getNextFieldOffset()
{
if(pImpl->nextFieldOffset==0) computeOffset(this);
return pImpl->nextFieldOffset;
}
int PVField::getNextFieldOffset()
{
if(pImpl->nextFieldOffset==0) computeOffset(this);
return pImpl->nextFieldOffset;
}
int PVField::getNumberFields()
{
if(pImpl->nextFieldOffset==0) computeOffset(this);
return (pImpl->nextFieldOffset - pImpl->fieldOffset);
}
int PVField::getNumberFields()
{
if(pImpl->nextFieldOffset==0) computeOffset(this);
return (pImpl->nextFieldOffset - pImpl->fieldOffset);
}
PVAuxInfo * PVField::getPVAuxInfo(){
if(pImpl->pvAuxInfo==0) {
pImpl->pvAuxInfo = new PVAuxInfo(this);
}
return pImpl->pvAuxInfo;
}
PVAuxInfo * PVField::getPVAuxInfo(){
if(pImpl->pvAuxInfo==0) {
pImpl->pvAuxInfo = new PVAuxInfo(this);
}
return pImpl->pvAuxInfo;
}
bool PVField::isImmutable() {return pImpl->immutable;}
bool PVField::isImmutable() {return pImpl->immutable;}
void PVField::setImmutable() {pImpl->immutable = epicsTrue;}
void PVField::setImmutable() {pImpl->immutable = epicsTrue;}
FieldConstPtr PVField::getField() {return pImpl->field;}
FieldConstPtr PVField::getField() {return pImpl->field;}
PVStructure * PVField::getParent() {return pImpl->parent;}
PVStructure * PVField::getParent() {return pImpl->parent;}
void PVField::replacePVField(PVField * newPVField)
{
throw std::logic_error(notImplemented);
}
void PVField::replacePVField(PVField * newPVField)
{
PVStructure *parent = getParent();
if(parent==0) {
String message("PVField::replacePVField no parent");
throw std::invalid_argument(message);
}
PVFieldPtrArray pvFields = parent->getPVFields();
int index = -1;
String fieldName = pImpl->field->getFieldName();
int length = parent->getStructure()->getNumberFields();
for(int i=0; i<length; i++) {
PVField *pvField = pvFields[i];
if(pvField->getField()->getFieldName().compare(fieldName) ==0) {
index = i;
break;
}
}
if(index==-1) {
String message("PVField::replacePVField did not find field in parent");
throw std::logic_error(message);
}
pvFields[index] = newPVField;
parent->replaceStructure();
}
void PVField::renameField(String newName)
{
throw std::logic_error(notImplemented);
}
void PVField::postPut()
{
if(pImpl->postHandler!=0) pImpl->postHandler->postPut();
}
void PVField::setPostHandler(PostHandler *ppostHandler)
{
throw std::logic_error(notImplemented);
}
void PVField::toString(StringBuilder buf) {toString(buf,0);}
void PVField::toString(StringBuilder buf,int indentLevel)
{
if(pImpl->pvAuxInfo==0) return;
pImpl->pvAuxInfo->toString(buf,indentLevel);
}
void PVField::computeOffset(PVField * pvField) {
PVStructure *pvTop = pvField->getParent();
Type type = pvField->getField()->getType();
if(type!=structure) {
pvField->pImpl->nextFieldOffset = 1;
return;
void PVField::renameField(String newName)
{
FieldCreate *fieldCreate = getFieldCreate();
switch(pImpl->field->getType()) {
case scalar: {
ScalarConstPtr scalar = (ScalarConstPtr)pImpl->field;
scalar = fieldCreate->createScalar(newName, scalar->getScalarType());
pImpl->field = scalar;
break;
}
if(pvTop==0) {
pvTop = (PVStructure *)pvField;
} else {
while(pvTop->getParent()!=0) {
pvTop = pvTop->getParent();
}
}
int offset = 0;
int nextOffset = 1;
PVFieldPtrArray pvFields = pvTop->getPVFields();
for(int i=0; i < pvTop->getStructure()->getNumberFields(); i++) {
offset = nextOffset;
PVField *pvField = pvFields[i];
FieldConstPtr field = pvField->getField();
switch(field->getType()) {
case scalar:
case scalarArray:
case structureArray:{
nextOffset++;
pvField->pImpl->fieldOffset = offset;
pvField->pImpl->nextFieldOffset = nextOffset;
break;
}
case structure: {
pvField->computeOffset(pvField,offset);
nextOffset = pvField->getNextFieldOffset();
}
}
case scalarArray: {
ScalarArrayConstPtr array = (ScalarArrayConstPtr)pImpl->field;
array = fieldCreate->createScalarArray(newName, array->getElementType());
pImpl->field = array;
break;
}
PVField *top = (PVField *)pvTop;
top->pImpl->fieldOffset = 0;
top->pImpl->nextFieldOffset = nextOffset;
}
case structure: {
StructureConstPtr structure = (StructureConstPtr)pImpl->field;
FieldConstPtrArray origFields = structure->getFields();
int numberFields = structure->getNumberFields();
structure = fieldCreate->createStructure(newName,numberFields,origFields);
pImpl->field = structure;
break;
}
case structureArray: {
StructureArrayConstPtr structureArray = (StructureArrayConstPtr)pImpl->field;
structureArray = fieldCreate->createStructureArray(newName,
structureArray->getStructure());
pImpl->field = structureArray;
}
}
String message("PVField::renameField logic error. should not get here");
throw std::logic_error(message);
}
void PVField::computeOffset(PVField * pvField,int offset) {
int beginOffset = offset;
int nextOffset = offset + 1;
PVStructure *pvStructure = (PVStructure *)pvField;
PVFieldPtrArray pvFields = pvStructure->getPVFields();
for(int i=0; i < pvStructure->getStructure()->getNumberFields(); i++) {
offset = nextOffset;
PVField *pvSubField = pvFields[i];
FieldConstPtr field = pvSubField->getField();
switch(field->getType()) {
case scalar:
case scalarArray:
case structureArray: {
nextOffset++;
pvSubField->pImpl->fieldOffset = offset;
pvSubField->pImpl->nextFieldOffset = nextOffset;
break;
}
case structure: {
pvSubField->computeOffset(pvSubField,offset);
nextOffset = pvSubField->getNextFieldOffset();
}
}
}
pvField->pImpl->fieldOffset = beginOffset;
pvField->pImpl->nextFieldOffset = nextOffset;
}
void PVField::postPut()
{
if(pImpl->postHandler!=0) pImpl->postHandler->postPut();
}
void PVField::setPostHandler(PostHandler *postHandler)
{
if(pImpl->postHandler!=0) {
if(postHandler==pImpl->postHandler) return;
String message("PVField::setPostHandler a postHandler is already registered");
throw std::logic_error(message);
}
pImpl->postHandler = postHandler;
}
void PVField::toString(StringBuilder buf) {toString(buf,0);}
void PVField::toString(StringBuilder buf,int indentLevel)
{
if(pImpl->pvAuxInfo==0) return;
pImpl->pvAuxInfo->toString(buf,indentLevel);
}
void PVField::computeOffset(PVField * pvField) {
PVStructure *pvTop = pvField->getParent();
Type type = pvField->getField()->getType();
if(type!=structure) {
pvField->pImpl->nextFieldOffset = 1;
return;
}
if(pvTop==0) {
pvTop = (PVStructure *)pvField;
} else {
while(pvTop->getParent()!=0) {
pvTop = pvTop->getParent();
}
}
int offset = 0;
int nextOffset = 1;
PVFieldPtrArray pvFields = pvTop->getPVFields();
for(int i=0; i < pvTop->getStructure()->getNumberFields(); i++) {
offset = nextOffset;
PVField *pvField = pvFields[i];
FieldConstPtr field = pvField->getField();
switch(field->getType()) {
case scalar:
case scalarArray:
case structureArray:{
nextOffset++;
pvField->pImpl->fieldOffset = offset;
pvField->pImpl->nextFieldOffset = nextOffset;
break;
}
case structure: {
pvField->computeOffset(pvField,offset);
nextOffset = pvField->getNextFieldOffset();
}
}
}
PVField *top = (PVField *)pvTop;
top->pImpl->fieldOffset = 0;
top->pImpl->nextFieldOffset = nextOffset;
}
void PVField::computeOffset(PVField * pvField,int offset) {
int beginOffset = offset;
int nextOffset = offset + 1;
PVStructure *pvStructure = (PVStructure *)pvField;
PVFieldPtrArray pvFields = pvStructure->getPVFields();
for(int i=0; i < pvStructure->getStructure()->getNumberFields(); i++) {
offset = nextOffset;
PVField *pvSubField = pvFields[i];
FieldConstPtr field = pvSubField->getField();
switch(field->getType()) {
case scalar:
case scalarArray:
case structureArray: {
nextOffset++;
pvSubField->pImpl->fieldOffset = offset;
pvSubField->pImpl->nextFieldOffset = nextOffset;
break;
}
case structure: {
pvSubField->computeOffset(pvSubField,offset);
nextOffset = pvSubField->getNextFieldOffset();
}
}
}
pvField->pImpl->fieldOffset = beginOffset;
pvField->pImpl->nextFieldOffset = nextOffset;
}
}}
#endif /* ABSTRACTPVFIELD_H */
+5
View File
@@ -198,6 +198,11 @@ namespace epics { namespace pvData {
throw std::logic_error(notImplemented);
}
void PVStructure::replaceStructure()
{
throw std::logic_error(notImplemented);
}
class BasePVStructure : public PVStructure {
public:
BasePVStructure(PVStructure *parent,StructureConstPtr structure);
+31 -21
View File
@@ -68,24 +68,6 @@ namespace epics { namespace pvData {
throw std::logic_error(notImplemented);
}
void PVStructureArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void PVStructureArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void PVStructureArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count)
{
throw std::logic_error(notImplemented);
}
void PVStructureArray::toString(StringBuilder buf) {toString(buf,0);}
void PVStructureArray::toString(StringBuilder buf,int indentLevel)
@@ -93,6 +75,24 @@ namespace epics { namespace pvData {
throw std::logic_error(notImplemented);
}
void PVStructureArray::serialize(
ByteBuffer *pbuffer,SerializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void PVStructureArray::deserialize(
ByteBuffer *pbuffer,DeserializableControl *pflusher)
{
throw std::logic_error(notImplemented);
}
void PVStructureArray::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, int offset, int count)
{
throw std::logic_error(notImplemented);
}
bool PVStructureArray::operator==(PVField *pv)
{
throw std::logic_error(notImplemented);
@@ -106,11 +106,21 @@ namespace epics { namespace pvData {
class BasePVStructureArray : public PVStructureArray {
public:
BasePVStructureArray(PVStructure *parent,
StructureArrayConstPtr structureArray)
: PVStructureArray(parent,structureArray) {}
~BasePVStructureArray(){}
StructureArrayConstPtr structureArray);
~BasePVStructureArray();
virtual void setCapacity(int capacity);
private:
};
BasePVStructureArray::BasePVStructureArray(
PVStructure *parent,StructureArrayConstPtr structureArray)
: PVStructureArray(parent,structureArray) {}
BasePVStructureArray::~BasePVStructureArray() {}
void BasePVStructureArray::setCapacity(int capacity) {
throw std::logic_error(notImplemented);
}
}}
#endif /* BASEPVSTRUCTUREARRAY_H */
+3 -1
View File
@@ -12,6 +12,7 @@
namespace epics { namespace pvData {
static Convert* convert = 0;
static PVDataCreate* pvDataCreate = 0;
static String trueString("true");
static String falseString("false");
@@ -592,7 +593,7 @@ void Convert::copyStructureArray(
} else {
if(toArray[i]==0) {
StructureConstPtr structure = to->getStructureArray()->getStructure();
toArray[i] = getPVDataCreate()->createPVStructure(0,structure);
toArray[i] = pvDataCreate->createPVStructure(0,structure);
}
copyStructure(fromArray[i],toArray[i]);
}
@@ -3567,6 +3568,7 @@ Convert * getConvert() {
if(convert==0){
convert = new ConvertExt();
pvDataCreate = getPVDataCreate();
}
return convert;
}
+61 -61
View File
@@ -9,72 +9,72 @@
namespace epics { namespace pvData {
class PVAuxInfoPvt {
public:
PVAuxInfoPvt(PVField *pvField)
: pvField(pvField),
theMap(std::map<String, PVScalar * >())
{}
PVField *pvField;
std::map<String, PVScalar * > theMap;
};
class PVAuxInfoPvt {
public:
PVAuxInfoPvt(PVField *pvField)
: pvField(pvField),
theMap(std::map<String, PVScalar * >())
{}
PVField *pvField;
std::map<String, PVScalar * > theMap;
};
PVAuxInfo::PVAuxInfo(PVField *pvField)
: pImpl(new PVAuxInfoPvt(pvField))
{ }
PVAuxInfo::PVAuxInfo(PVField *pvField)
: pImpl(new PVAuxInfoPvt(pvField))
{ }
PVAuxInfo::~PVAuxInfo() { delete pImpl;}
PVField * PVAuxInfo::getPVField() {
return pImpl->pvField;
PVAuxInfo::~PVAuxInfo() { delete pImpl;}
PVField * PVAuxInfo::getPVField() {
return pImpl->pvField;
}
typedef std::map<String,PVScalar * >::const_iterator map_iterator;
PVScalar * PVAuxInfo::createInfo(String key,ScalarType scalarType)
{
map_iterator i = pImpl->theMap.find(key);
if(i!=pImpl->theMap.end()) {
String message("AuxoInfo:create key ");
message += key.c_str();
message += " already exists with scalarType ";
ScalarTypeFunc::toString(&message,scalarType);
pImpl->pvField->message(message,errorMessage);
}
PVScalar *pvScalar = getPVDataCreate()->createPVScalar(0,key,scalarType);
pImpl->theMap.insert(std::pair<String,PVScalar * >(key, pvScalar));
return pvScalar;
typedef std::map<String,PVScalar * >::const_iterator map_iterator;
}
PVScalar * PVAuxInfo::createInfo(String key,ScalarType scalarType)
{
map_iterator i = pImpl->theMap.find(key);
if(i!=pImpl->theMap.end()) {
String message("AuxoInfo:create key ");
message += key.c_str();
message += " already exists with scalarType ";
ScalarTypeFunc::toString(&message,scalarType);
pImpl->pvField->message(message,errorMessage);
}
PVScalar *pvScalar = getPVDataCreate()->createPVScalar(0,key,scalarType);
pImpl->theMap.insert(std::pair<String,PVScalar * >(key, pvScalar));
return pvScalar;
PVScalarMap PVAuxInfo::getInfos()
{
return pImpl->theMap;
}
PVScalar * PVAuxInfo::getInfo(String key)
{
map_iterator i = pImpl->theMap.find(key);
if(i!=pImpl->theMap.end()) return i->second;
return 0;
}
void PVAuxInfo::toString(StringBuilder buf)
{
return PVAuxInfo::toString(buf,0);
}
void PVAuxInfo::toString(StringBuilder buf,int indentLevel)
{
map_iterator i = pImpl->theMap.begin();
while(i!=pImpl->theMap.end()) {
String key = i->first;
PVScalar *value = i->second;
*buf += " ";
*buf += key.c_str();
*buf += " ";
value->toString(buf);
i++;
}
std::map<String, PVScalar * > *PVAuxInfo::getInfos()
{
return &pImpl->theMap;
}
PVScalar * PVAuxInfo::getInfo(String key)
{
map_iterator i = pImpl->theMap.find(key);
if(i!=pImpl->theMap.end()) return i->second;
return 0;
}
void PVAuxInfo::toString(StringBuilder buf)
{
return PVAuxInfo::toString(buf,0);
}
void PVAuxInfo::toString(StringBuilder buf,int indentLevel)
{
map_iterator i = pImpl->theMap.begin();
while(i!=pImpl->theMap.end()) {
String key = i->first;
PVScalar *value = i->second;
*buf += " ";
*buf += key.c_str();
*buf += " ";
value->toString(buf);
i++;
}
}
}
}}
+195 -154
View File
@@ -34,169 +34,210 @@
namespace epics { namespace pvData {
static FieldCreate * fieldCreate = 0;
static PVDataCreate* pvDataCreate = 0;
static Convert* convert = 0;
static FieldCreate * fieldCreate = 0;
static PVDataCreate* pvDataCreate = 0;
PVDataCreate::PVDataCreate(){};
PVDataCreate::PVDataCreate(){}
PVField *PVDataCreate::createPVField(PVStructure *parent,
FieldConstPtr field)
{
switch(field->getType()) {
case scalar:
return createPVScalar(parent,(ScalarConstPtr)field);
case scalarArray:
return (PVField *)createPVScalarArray(parent,
(ScalarArrayConstPtr)field);
case structure:
return (PVField *)createPVStructure(parent,
(StructureConstPtr)field);
case structureArray:
return createPVStructureArray(parent,
(StructureArrayConstPtr)field);
}
String message("PVDataCreate::createPVField");
PVField *PVDataCreate::createPVField(PVStructure *parent,
FieldConstPtr field)
{
switch(field->getType()) {
case scalar:
return createPVScalar(parent,(ScalarConstPtr)field);
case scalarArray:
return (PVField *)createPVScalarArray(parent,
(ScalarArrayConstPtr)field);
case structure:
return (PVField *)createPVStructure(parent,
(StructureConstPtr)field);
case structureArray:
return createPVStructureArray(parent,
(StructureArrayConstPtr)field);
}
String message("PVDataCreate::createPVField should never get here");
throw std::logic_error(message);
}
PVField *PVDataCreate::createPVField(PVStructure *parent,
String fieldName,PVField * fieldToClone)
{
switch(fieldToClone->getField()->getType()) {
case scalar:
return createPVScalar(parent,fieldName,(PVScalar*)fieldToClone);
case scalarArray:
return (PVField *)createPVScalarArray(parent,fieldName,
(PVScalarArray *)fieldToClone);
case structure:
return (PVField *)createPVStructure(parent,fieldName,
(PVStructure *)fieldToClone);
case structureArray:
String message(
"PVDataCreate::createPVField structureArray not valid fieldToClone");
throw std::invalid_argument(message);
};
}
String message("PVDataCreate::createPVField should never get here");
throw std::logic_error(message);
}
PVField *PVDataCreate::createPVField(PVStructure *parent,
String fieldName,PVField * fieldToClone)
{
switch(fieldToClone->getField()->getType()) {
case scalar:
return createPVScalar(parent,fieldName,(PVScalar*)fieldToClone);
case scalarArray:
return (PVField *)createPVScalarArray(parent,fieldName,
(PVScalarArray *)fieldToClone);
case structure:
return (PVField *)createPVStructure(parent,fieldName,
(PVStructure *)fieldToClone);
case structureArray:
String message(
"PVDataCreate::createPVField structureArray not valid fieldToClone");
throw std::invalid_argument(message);
}
String message("PVDataCreate::createPVField");
throw std::logic_error(message);
};
PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,ScalarConstPtr scalar)
{
ScalarType scalarType = scalar->getScalarType();
switch(scalarType) {
case pvBoolean:
return new BasePVBoolean(parent,scalar);
case pvByte:
return new BasePVByte(parent,scalar);
case pvShort:
return new BasePVShort(parent,scalar);
case pvInt:
return new BasePVInt(parent,scalar);
case pvLong:
return new BasePVLong(parent,scalar);
case pvFloat:
return new BasePVFloat(parent,scalar);
case pvDouble:
return new BasePVDouble(parent,scalar);
case pvString:
return new BasePVString(parent,scalar);
}
String message("PVDataCreate::createPVScalar should never get here");
throw std::logic_error(message);
}
PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,ScalarConstPtr scalar)
{
ScalarType scalarType = scalar->getScalarType();
switch(scalarType) {
case pvBoolean:
return new BasePVBoolean(parent,scalar);
case pvByte:
return new BasePVByte(parent,scalar);
case pvShort:
return new BasePVShort(parent,scalar);
case pvInt:
return new BasePVInt(parent,scalar);
case pvLong:
return new BasePVLong(parent,scalar);
case pvFloat:
return new BasePVFloat(parent,scalar);
case pvDouble:
return new BasePVDouble(parent,scalar);
case pvString:
return new BasePVString(parent,scalar);
default:
throw std::logic_error(notImplemented);
}
throw std::logic_error(notImplemented);
};
PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,
String fieldName,ScalarType scalarType)
{
if(fieldCreate==0) fieldCreate = getFieldCreate();
ScalarConstPtr scalar = fieldCreate->createScalar(fieldName,scalarType);
return createPVScalar(parent,scalar);
};
PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,
String fieldName,PVScalar * scalarToClone)
{
PVScalar *pvScalar = createPVScalar(parent,fieldName,
scalarToClone->getScalar()->getScalarType());
//MARTY MUST CALL CONVERT
//MARTY MUST COPY AUXInfo
return pvScalar;
};
PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
{
switch(scalarArray->getElementType()) {
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:
return new BasePVStringArray(parent,scalarArray);
}
throw std::logic_error(notImplemented);
};
PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent,
String fieldName,ScalarType elementType)
{
throw std::logic_error(notImplemented);
};
PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent,
String fieldName,PVScalarArray * scalarArrayToClone)
{
throw std::logic_error(notImplemented);
};
PVStructureArray *PVDataCreate::createPVStructureArray(PVStructure *parent,
StructureArrayConstPtr structureArray)
{
throw std::logic_error(notImplemented);
};
PVStructure *PVDataCreate::createPVStructure(PVStructure *parent,
StructureConstPtr structure)
{
return new BasePVStructure(parent,structure);
};
PVStructure *PVDataCreate::createPVStructure(PVStructure *parent,
String fieldName,FieldConstPtrArray fields)
{
throw std::logic_error(notImplemented);
};
PVStructure *PVDataCreate::createPVStructure(PVStructure *parent,
String fieldName,PVStructure *structToClone)
{
throw std::logic_error(notImplemented);
};
PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,
String fieldName,ScalarType scalarType)
{
ScalarConstPtr scalar = fieldCreate->createScalar(fieldName,scalarType);
return createPVScalar(parent,scalar);
}
class PVDataCreateExt : public PVDataCreate {
public:
PVDataCreateExt(): PVDataCreate(){};
};
PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,
String fieldName,PVScalar * scalarToClone)
{
PVScalar *pvScalar = createPVScalar(parent,fieldName,
scalarToClone->getScalar()->getScalarType());
convert->copyScalar(scalarToClone, pvScalar);
PVScalarMap attributes = scalarToClone->getPVAuxInfo()->getInfos();
PVAuxInfo *pvAttribute = pvScalar->getPVAuxInfo();
PVScalarMapIter p;
for(p=attributes.begin(); p!=attributes.end(); p++) {
String key = p->first;
PVScalar *fromAttribute = p->second;
PVScalar *toAttribute = pvAttribute->createInfo(key,
fromAttribute->getScalar()->getScalarType());
convert->copyScalar(fromAttribute,toAttribute);
}
return pvScalar;
}
PVDataCreate * getPVDataCreate() {
static Mutex mutex = Mutex();
Lock xx(&mutex);
PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent,
ScalarArrayConstPtr scalarArray)
{
switch(scalarArray->getElementType()) {
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:
return new BasePVStringArray(parent,scalarArray);
}
String message("PVDataCreate::createPVScalarArray should never get here");
throw std::logic_error(message);
}
if(pvDataCreate==0) pvDataCreate = new PVDataCreateExt();
return pvDataCreate;
PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent,
String fieldName,ScalarType elementType)
{
return createPVScalarArray(parent,
fieldCreate->createScalarArray(fieldName, elementType));
}
PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent,
String fieldName,PVScalarArray * arrayToClone)
{
PVScalarArray *pvArray = createPVScalarArray(parent,fieldName,
arrayToClone->getScalarArray()->getElementType());
convert->copyScalarArray(arrayToClone,0, pvArray,0,arrayToClone->getLength());
PVScalarMap attributes = arrayToClone->getPVAuxInfo()->getInfos();
PVAuxInfo *pvAttribute = pvArray->getPVAuxInfo();
PVScalarMapIter p;
for(p=attributes.begin(); p!=attributes.end(); p++) {
String key = p->first;
PVScalar *fromAttribute = p->second;
PVScalar *toAttribute = pvAttribute->createInfo(key,
fromAttribute->getScalar()->getScalarType());
convert->copyScalar(fromAttribute,toAttribute);
}
return pvArray;
}
PVStructureArray *PVDataCreate::createPVStructureArray(PVStructure *parent,
StructureArrayConstPtr structureArray)
{
return new BasePVStructureArray(parent,structureArray);
}
PVStructure *PVDataCreate::createPVStructure(PVStructure *parent,
StructureConstPtr structure)
{
return new BasePVStructure(parent,structure);
}
PVStructure *PVDataCreate::createPVStructure(PVStructure *parent,
String fieldName,int numberFields,FieldConstPtrArray fields)
{
StructureConstPtr structure = fieldCreate->createStructure(
fieldName,numberFields, fields);
return new BasePVStructure(parent,structure);
}
PVStructure *PVDataCreate::createPVStructure(PVStructure *parent,
String fieldName,PVStructure *structToClone)
{
FieldConstPtrArray fields = 0;
int numberFields = 0;
if(structToClone==0) {
fields = new FieldConstPtr[0];
} else {
fields = structToClone->getStructure()->getFields();
numberFields = structToClone->getStructure()->getNumberFields();
}
StructureConstPtr structure = fieldCreate->createStructure(fieldName,numberFields,fields);
PVStructure *pvStructure = new BasePVStructure(parent,structure);
if(structToClone!=0) convert->copyStructure(structToClone,pvStructure);
return pvStructure;
}
class PVDataCreateExt : public PVDataCreate {
public:
PVDataCreateExt(): PVDataCreate(){}
};
PVDataCreate * getPVDataCreate() {
static Mutex mutex = Mutex();
Lock xx(&mutex);
if(pvDataCreate==0){
pvDataCreate = new PVDataCreateExt();
convert = getConvert();
fieldCreate = getFieldCreate();
}
return pvDataCreate;
}
}}
+69 -63
View File
@@ -10,72 +10,78 @@
namespace epics { namespace pvData {
static String notImplemented("not implemented");
static FieldCreate* fieldCreate = 0;
static PVDataCreate* pvDataCreate = 0;
StandardField::StandardField(){}
StandardField::StandardField(){}
StandardField::~StandardField(){}
StandardField::~StandardField(){}
PVScalar * StandardField::scalarValue(ScalarType scalarType)
{
ScalarConstPtr scalar = getFieldCreate()->createScalar(
String("value"),scalarType);
return getPVDataCreate()->createPVScalar(0,scalar);
PVScalar * StandardField::scalarValue(ScalarType scalarType)
{
ScalarConstPtr scalar = fieldCreate->createScalar(
String("value"),scalarType);
return getPVDataCreate()->createPVScalar(0,scalar);
}
PVScalarArray * StandardField::scalarArrayValue(ScalarType elementType)
{
ScalarArrayConstPtr scalarArray = fieldCreate->createScalarArray(
String("value"),elementType);
return pvDataCreate->createPVScalarArray(0,scalarArray);
}
PVStructure * StandardField::scalarValue(ScalarType type,String properties)
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::scalarArrayValue(ScalarType elementType,
String properties)
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::enumeratedValue(StringArray choices)
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::enumeratedValue(StringArray choices,
String properties)
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::alarm()
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::timeStamp()
{
throw std::logic_error(notImplemented);
}
static StandardField* instance = 0;
class StandardFieldExt : public StandardField {
public:
StandardFieldExt(): StandardField(){};
};
StandardField * getStandardField() {
static Mutex mutex = Mutex();
Lock xx(&mutex);
if(instance==0) {
instance = new StandardFieldExt();
fieldCreate = getFieldCreate();
pvDataCreate = getPVDataCreate();
}
return instance;
}
PVScalarArray * StandardField::scalarArrayValue(ScalarType elementType)
{
ScalarArrayConstPtr scalarArray = getFieldCreate()->createScalarArray(
String("value"),elementType);
return getPVDataCreate()->createPVScalarArray(0,scalarArray);
}
PVStructure * StandardField::scalarValue(ScalarType type,String properties)
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::scalarArrayValue(ScalarType elementType,
String properties)
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::enumeratedValue(StringArray choices)
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::enumeratedValue(StringArray choices,
String properties)
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::alarm()
{
throw std::logic_error(notImplemented);
}
PVStructure * StandardField::timeStamp()
{
throw std::logic_error(notImplemented);
}
static StandardField* instance = 0;
class StandardFieldExt : public StandardField {
public:
StandardFieldExt(): StandardField(){};
};
StandardField * getStandardField() {
static Mutex mutex = Mutex();
Lock xx(&mutex);
if(instance==0) instance = new StandardFieldExt();
return instance;
}
}}
+1
View File
@@ -5,6 +5,7 @@
* Author: Matej Sekoranja
*/
#include <cstdio>
#ifndef EPICSEXCEPTION_H_
#define EPICSEXCEPTION_H_
+19 -16
View File
@@ -38,15 +38,17 @@ namespace epics { namespace pvData {
class PVStructure;
class PVStructureArray;
// NOTE this prevents compiler from generating default methods for this and
// derived classes
typedef std::map<String,PVScalar * > PVScalarMap;
typedef PVScalarMap::const_iterator PVScalarMapIter;
class PVAuxInfo : private NoDefaultMethods {
public:
PVAuxInfo(PVField *pvField);
~PVAuxInfo();
PVField * getPVField();
PVScalar * createInfo(String key,ScalarType scalarType);
std::map<String, PVScalar * > *getInfos();
PVScalarMap getInfos();
PVScalar * getInfo(String key);
void toString(StringBuilder buf);
void toString(StringBuilder buf,int indentLevel);
@@ -84,7 +86,6 @@ namespace epics { namespace pvData {
virtual bool operator!=(PVField *pv) = 0;
protected:
PVField(PVStructure *parent,FieldConstPtr field);
void replaceStructure();
private:
class PVFieldPvt *pImpl;
static void computeOffset(PVField *pvField);
@@ -155,22 +156,22 @@ namespace epics { namespace pvData {
class PVStructureArray : public PVArray {
public:
virtual ~PVStructureArray();
virtual StructureArrayConstPtr getStructureArray() = 0;
virtual StructureArrayConstPtr getStructureArray();
virtual int get(int offset, int length,
StructureArrayData *data) = 0;
StructureArrayData *data);
virtual int put(int offset,int length,
PVStructurePtrArray from, int fromOffset) = 0;
virtual void shareData( PVStructurePtrArray value,int capacity,int length) = 0;
PVStructurePtrArray from, int fromOffset);
virtual void shareData( PVStructurePtrArray value,int capacity,int length);
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher) = 0 ;
SerializableControl *pflusher) ;
virtual void deserialize(ByteBuffer *buffer,
DeserializableControl *pflusher) = 0;
DeserializableControl *pflusher);
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;
virtual bool operator==(PVField *pv) = 0;
virtual bool operator!=(PVField *pv) = 0;
SerializableControl *pflusher, int offset, int count);
virtual void toString(StringBuilder buf);
virtual void toString(StringBuilder buf,int indentLevel);
virtual bool operator==(PVField *pv);
virtual bool operator!=(PVField *pv);
protected:
PVStructureArray(PVStructure *parent,
StructureArrayConstPtr structureArray);
@@ -222,6 +223,8 @@ namespace epics { namespace pvData {
DeserializableControl*pflusher,BitSet *pbitSet);
protected:
PVStructure(PVStructure *parent,StructureConstPtr structure);
void replaceStructure();
friend class PVField;
private:
class PVStructurePvt * pImpl;
};
@@ -521,7 +524,7 @@ namespace epics { namespace pvData {
PVStructure *createPVStructure(PVStructure *parent,
StructureConstPtr structure);
PVStructure *createPVStructure(PVStructure *parent,
String fieldName,FieldConstPtrArray fields);
String fieldName,int numberFields,FieldConstPtrArray fields);
PVStructure *createPVStructure(PVStructure *parent,
String fieldName,PVStructure *structToClone);
protected:
+1
View File
@@ -13,6 +13,7 @@ testPVAuxInfo_LIBS += pvFactory
PROD_HOST += testPVScalar
testPVScalar_SRCS += testPVScalar.cpp
testPVScalar_LIBS += pvFactory
testPVScalar_LIBS += pvMisc Com
PROD_HOST += testPVScalarArray
testPVScalarArray_SRCS += testPVScalarArray.cpp
+1
View File
@@ -6,6 +6,7 @@
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <epicsAssert.h>
#include "requester.h"
#include "pvIntrospect.h"