Files
pvData/pvDataApp/factory/AbstractPVArray.h
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

86 lines
2.1 KiB
C++

/*AbstractPVArray.h*/
#ifndef ABSTRACTPVARRAY_H
#define ABSTRACTPVARRAY_H
#include <cstddef>
#include <cstdlib>
#include <string>
#include <cstdio>
#include "pvData.h"
#include "factory.h"
namespace epics { namespace pvData {
class PVArrayPvt {
public:
PVArrayPvt() : length(0),capacity(0),capacityMutable(epicsTrue)
{}
int length;
int capacity;
epicsBoolean capacityMutable;
};
PVArray::PVArray(PVStructure *parent,FieldConstPtr field)
: PVField(parent,field),pImpl(new PVArrayPvt())
{ }
PVArray::~PVArray()
{
delete pImpl;
}
int PVArray::getLength() const {return pImpl->length;}
static StringConst fieldImmutable("field is immutable");
void PVArray::setLength(int length) {
if(PVField::isImmutable()) {
PVField::message(fieldImmutable,errorMessage);
return;
}
if(length>pImpl->capacity) this->setCapacity(length);
if(length>pImpl->capacity) length = pImpl->capacity;
pImpl->length = length;
}
epicsBoolean PVArray::isCapacityImmutable() const
{
if(PVField::isImmutable()) {
return epicsFalse;
}
return pImpl->capacityMutable;
}
void PVArray::setCapacityImmutable(epicsBoolean isMutable)
{
if(isMutable && PVField::isImmutable()) {
PVField::message(fieldImmutable,errorMessage);
return;
}
pImpl->capacityMutable = isMutable;
}
static StringConst capacityImmutable("capacity is immutable");
void PVArray::setCapacity(int capacity) {
if(PVField::isImmutable()) {
PVField::message(fieldImmutable,errorMessage);
return;
}
if(pImpl->capacityMutable==epicsFalse) {
PVField::message(capacityImmutable,errorMessage);
return;
}
pImpl->capacity = capacity;
}
void PVArray::toString(StringBuilder buf) const {toString(buf,0);}
void PVArray::toString(StringBuilder buf, int indentLevel) const
{
throw std::logic_error(notImplemented);
}
}}
#endif /* ABSTRACTPVARRAY_H */