Files
pvData/pvDataApp/test/testPVAuxInfo.cpp
Marty Kraimer f6c9b0eea3 1) implemented noDefaultMethods. See effective C++ Item 6. There it is called Uncopyable
2) implemented Lock. See effective C++ item 14.
     This is as easy to use as Java synchronize.
3) wrapper on top of std::string. All usage of string in pvData is one of:
      String - Just a std::string
     StringBuilder - Used where StringBuilder is used in Java
     StringConst - Just a "std::string const". This is used wherever String is used in Java
     StringConstArray - Just like a String[] in Java.
4) The reference counting (incReferenceCount and decReferenceCount) are now private. It is completely handled by the implenentaion.
    NO code that uses pvData needs even know about reference counting.
2010-09-27 08:33:10 -04:00

51 lines
1.3 KiB
C++

/* testPVAuxInfo.cpp */
/* Author: Marty Kraimer Date: 2010.09.21 */
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "pvData.h"
using namespace epics::pvData;
static FieldCreate * fieldCreate = 0;
static PVDataCreate *pvDataCreate = 0;
static String buffer("");
void testDouble() {
printf("\ntestDouble\n");
StringConst valueName("value");
ScalarConstPtr pscalar = fieldCreate->createScalar(valueName,pvDouble);
PVScalar *pvScalar = pvDataCreate->createPVScalar(0,pscalar);
PVDouble *pvValue = dynamic_cast<PVDouble *>(pvScalar);
double value = 2;
pvValue->put(value);
double getValue = pvValue->get();
if(value!=getValue) {
fprintf(stderr,"ERROR getValue put %f get %f\n",value,getValue);
}
PVAuxInfo *auxInfo = pvValue->getPVAuxInfo();
StringConst stringName("string");
pvScalar = auxInfo->createInfo(stringName,pvDouble);
PVDouble *doubleInfo = dynamic_cast<PVDouble *>(pvScalar);
doubleInfo->put(100.0);
pvScalar = auxInfo->getInfo(stringName);
buffer.clear();
buffer += "stringInfo ";
pvScalar->toString(&buffer);
printf("%s\n",buffer.c_str());
delete pvValue;
}
int main(int argc,char *argv[])
{
fieldCreate = getFieldCreate();
pvDataCreate = getPVDataCreate();
testDouble();
return(0);
}