replaced tabs with spaces

This commit is contained in:
2020-04-15 10:54:54 +02:00
committed by mdavidsaver
parent 3d93a80cce
commit f4de6dd9b1
21 changed files with 257 additions and 257 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ struct CreateRequestImpl {
if(pos==string::npos) break;
numValues++;
index = pos +1;
}
}
vector<string> valueList(numValues,"");
index=0;
for(size_t i=0; i<numValues; i++) {
+2 -2
View File
@@ -84,7 +84,7 @@ bool compare(const Structure& a, const Structure& b)
if(&a==&b)
return true;
if (a.getID()!=b.getID())
return false;
return false;
size_t nflds=a.getNumberFields();
if (b.getNumberFields()!=nflds)
return false;
@@ -111,7 +111,7 @@ bool compare(const Union& a, const Union& b)
if(&a==&b)
return true;
if (a.getID()!=b.getID())
return false;
return false;
size_t nflds=a.getNumberFields();
if (b.getNumberFields()!=nflds)
return false;
+44 -44
View File
@@ -113,7 +113,7 @@ std::tr1::shared_ptr<PVField> Field::build() const
std::ostream& operator<<(std::ostream& o, const Field& f)
{
return f.dump(o);
return f.dump(o);
};
Scalar::Scalar(ScalarType scalarType)
@@ -136,18 +136,18 @@ std::ostream& Scalar::dump(std::ostream& o) const
string Scalar::getID() const
{
static const string idScalarLUT[] = {
"boolean", // pvBoolean
"byte", // pvByte
"short", // pvShort
"int", // pvInt
"long", // pvLong
"ubyte", // pvUByte
"ushort", // pvUShort
"uint", // pvUInt
"ulong", // pvULong
"float", // pvFloat
"double", // pvDouble
"string" // pvString
"boolean", // pvBoolean
"byte", // pvByte
"short", // pvShort
"int", // pvInt
"long", // pvLong
"ubyte", // pvUByte
"ushort", // pvUShort
"uint", // pvUInt
"ulong", // pvULong
"float", // pvFloat
"double", // pvDouble
"string" // pvString
};
return idScalarLUT[scalarType];
}
@@ -227,7 +227,7 @@ static void serializeStructureField(const Structure* structure, ByteBuffer* buff
// to optimize default (non-empty) IDs optimization
// empty IDs are not allowed
string id = structure->getID();
if (id == Structure::DEFAULT_ID) // TODO slow comparison
if (id == Structure::DEFAULT_ID) // TODO slow comparison
SerializeHelper::serializeString(string(), buffer, control);
else
SerializeHelper::serializeString(id, buffer, control);
@@ -263,13 +263,13 @@ static StructureConstPtr deserializeStructureField(const FieldCreate* fieldCreat
static void serializeUnionField(const Union* punion, ByteBuffer* buffer, SerializableControl* control)
{
// to optimize default (non-empty) IDs optimization
// empty IDs are not allowed
string id = punion->getID();
if (id == Union::DEFAULT_ID) // TODO slow comparison
// to optimize default (non-empty) IDs optimization
// empty IDs are not allowed
string id = punion->getID();
if (id == Union::DEFAULT_ID) // TODO slow comparison
SerializeHelper::serializeString(string(), buffer, control);
else
SerializeHelper::serializeString(id, buffer, control);
else
SerializeHelper::serializeString(id, buffer, control);
FieldConstPtrArray const & fields = punion->getFields();
StringArray const & fieldNames = punion->getFieldNames();
@@ -297,7 +297,7 @@ static UnionConstPtr deserializeUnionField(const FieldCreate* fieldCreate, ByteB
if (id.empty())
return fieldCreate->createUnion(fieldNames, fields);
else
return fieldCreate->createUnion(id, fieldNames, fields);
return fieldCreate->createUnion(id, fieldNames, fields);
}
Array::Array(Type type)
@@ -323,18 +323,18 @@ ScalarArray::~ScalarArray()
const string ScalarArray::getIDScalarArrayLUT() const
{
static const string idScalarArrayLUT[] = {
"boolean[]", // pvBoolean
"byte[]", // pvByte
"short[]", // pvShort
"int[]", // pvInt
"long[]", // pvLong
"ubyte[]", // pvUByte
"ushort[]", // pvUShort
"uint[]", // pvUInt
"ulong[]", // pvULong
"float[]", // pvFloat
"double[]", // pvDouble
"string[]" // pvString
"boolean[]", // pvBoolean
"byte[]", // pvByte
"short[]", // pvShort
"int[]", // pvInt
"long[]", // pvLong
"ubyte[]", // pvUByte
"ushort[]", // pvUShort
"uint[]", // pvUInt
"ulong[]", // pvULong
"float[]", // pvFloat
"double[]", // pvDouble
"string[]" // pvString
};
return idScalarArrayLUT[elementType];
}
@@ -427,7 +427,7 @@ StructureArray::~StructureArray()
string StructureArray::getID() const
{
return pstructure->getID() + "[]";
return pstructure->getID() + "[]";
}
std::ostream& StructureArray::dump(std::ostream& o) const
@@ -467,7 +467,7 @@ UnionArray::~UnionArray()
string UnionArray::getID() const
{
return punion->getID() + "[]";
return punion->getID() + "[]";
}
std::ostream& UnionArray::dump(std::ostream& o) const
@@ -555,7 +555,7 @@ Structure::~Structure()
string Structure::getID() const
{
return id;
return id;
}
FieldConstPtr Structure::getField(string const & fieldName) const {
@@ -771,7 +771,7 @@ int32 Union::guess(Type t, ScalarType s) const
string Union::getID() const
{
return id;
return id;
}
FieldConstPtr Union::getField(string const & fieldName) const {
@@ -966,7 +966,7 @@ FieldBuilder::FieldBuilder(const FieldBuilderPtr & _parentBuilder,
{}
FieldBuilder::FieldBuilder(FieldBuilderPtr const & _parentBuilder,
string const & _nestedName,
string const & _nestedName,
Type _nestedClassToBuild, bool _nestedArray)
:fieldCreate(_parentBuilder->fieldCreate)
,idSet(false)
@@ -979,10 +979,10 @@ FieldBuilder::FieldBuilder(FieldBuilderPtr const & _parentBuilder,
void FieldBuilder::reset()
{
id.erase();
id.erase();
idSet = false;
fieldNames.clear();
fields.clear();
fieldNames.clear();
fields.clear();
}
FieldBuilderPtr FieldBuilder::begin()
@@ -1023,7 +1023,7 @@ FieldBuilderPtr FieldBuilder::add(string const & name, FieldConstPtr const & fie
} else if(*cur!=*field) {
THROW_EXCEPTION2(std::runtime_error, "duplicate field name w/ different type : "+name);
} // else exact duplicate is silently ignored
return shared_from_this();
return shared_from_this();
}
FieldBuilderPtr FieldBuilder::addArray(string const & name, ScalarType scalarType)
@@ -1100,7 +1100,7 @@ StructureConstPtr FieldBuilder::createStructure()
{
if (parentBuilder.get())
THROW_EXCEPTION2(std::runtime_error, "createStructure() called in nested FieldBuilder");
StructureConstPtr field(static_pointer_cast<const Structure>(createFieldInternal(structure)));
reset();
return field;
@@ -1110,7 +1110,7 @@ UnionConstPtr FieldBuilder::createUnion()
{
if (parentBuilder.get())
THROW_EXCEPTION2(std::runtime_error, "createUnion() called in nested FieldBuilder");
UnionConstPtr field(static_pointer_cast<const Union>(createFieldInternal(union_)));
reset();
return field;
+1 -1
View File
@@ -49,7 +49,7 @@ PVArray::PVArray(FieldConstPtr const & field)
std::ostream& operator<<(format::array_at_internal const& manip, const PVArray& array)
{
return array.dumpValue(manip.stream, manip.index);
return array.dumpValue(manip.stream, manip.index);
}
}}
+9 -9
View File
@@ -160,17 +160,17 @@ void PVString::serialize(ByteBuffer *pbuffer,
void PVString::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, size_t offset, size_t count) const
{
// check bounds
// check bounds
const size_t length = storage.value.length();
/*if (offset < 0) offset = 0;
else*/ if (offset > length) offset = length;
//if (count < 0) count = length;
/*if (offset < 0) offset = 0;
else*/ if (offset > length) offset = length;
//if (count < 0) count = length;
const size_t maxCount = length - offset;
if (count > maxCount)
count = maxCount;
// write
const size_t maxCount = length - offset;
if (count > maxCount)
count = maxCount;
// write
SerializeHelper::serializeSubstring(storage.value, offset, count, pbuffer, pflusher);
}
+1 -1
View File
@@ -91,7 +91,7 @@ bool PVField::equals(PVField &pv)
std::ostream& operator<<(std::ostream& o, const PVField& f)
{
return f.dumpValue(o);
return f.dumpValue(o);
};
string PVField::getFullName() const
+15 -15
View File
@@ -38,7 +38,7 @@ PVStructure::PVStructure(StructureConstPtr const & structurePtr)
pvFields.push_back(pvDataCreate->createPVField(fields[i]));
}
for(size_t i=0; i<numberFields; i++) {
pvFields[i]->setParentAndName(this,fieldNames[i]);
pvFields[i]->setParentAndName(this,fieldNames[i]);
}
}
@@ -307,22 +307,22 @@ std::ostream& PVStructure::dumpValue(std::ostream& o) const
o << format::indent() << getStructure()->getID() << ' ' << getFieldName();
o << std::endl;
{
format::indent_scope s(o);
format::indent_scope s(o);
PVFieldPtrArray const & fieldsData = getPVFields();
if (fieldsData.size() != 0) {
size_t length = getStructure()->getNumberFields();
for(size_t i=0; i<length; i++) {
PVFieldPtr fieldField = fieldsData[i];
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
}
PVFieldPtrArray const & fieldsData = getPVFields();
if (fieldsData.size() != 0) {
size_t length = getStructure()->getNumberFields();
for(size_t i=0; i<length; i++) {
PVFieldPtr fieldField = fieldsData[i];
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
}
}
return o;
return o;
}
+2 -2
View File
@@ -218,10 +218,10 @@ std::ostream& PVStructureArray::dumpValue(std::ostream& o) const
size_t length = getLength();
if (length > 0)
{
format::indent_scope s(o);
format::indent_scope s(o);
for (size_t i = 0; i < length; i++)
dumpValue(o, i);
dumpValue(o, i);
}
return o;
+18 -18
View File
@@ -23,7 +23,7 @@ using std::size_t;
using std::string;
namespace epics { namespace pvData {
#define PVUNION_UNDEFINED_INDEX -1
const int32 PVUnion::UNDEFINED_INDEX = PVUNION_UNDEFINED_INDEX;
@@ -75,13 +75,13 @@ PVFieldPtr PVUnion::select(int32 index)
return value;
}
PVFieldPtr PVUnion::select(string const & fieldName)
{
int32 index = variant ? -1 : static_cast<int32>(unionPtr->getFieldIndex(fieldName));
if (index == -1)
if (index == -1)
throw std::invalid_argument("no such fieldName");
return select(index);
return select(index);
}
void PVUnion::set(int32 index, PVFieldPtr const & value)
@@ -94,14 +94,14 @@ void PVUnion::set(int32 index, PVFieldPtr const & value)
{
// for undefined index we accept only null values
if (value)
throw std::invalid_argument("non-null value for index == UNDEFINED_INDEX");
throw std::invalid_argument("non-null value for index == UNDEFINED_INDEX");
}
else if (index < 0 || size_t(index) >= unionPtr->getFields().size())
throw std::invalid_argument("index out of bounds");
else if (!value)
throw std::invalid_argument("Can't set defined index w/ NULL");
else if (value->getField() != unionPtr->getField(index))
throw std::invalid_argument("selected field and its introspection data do not match");
throw std::invalid_argument("selected field and its introspection data do not match");
}
selector = index;
@@ -180,20 +180,20 @@ std::ostream& PVUnion::dumpValue(std::ostream& o) const
{
o << format::indent() << getUnion()->getID() << ' ' << getFieldName() << std::endl;
{
format::indent_scope s(o);
format::indent_scope s(o);
const PVField::const_shared_pointer& fieldField = get();
if (fieldField.get() == NULL)
o << format::indent() << "(none)" << std::endl;
else
{
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
if (fieldField.get() == NULL)
o << format::indent() << "(none)" << std::endl;
else
{
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
}
return o;
return o;
}
void PVUnion::copy(const PVUnion& from)
+2 -2
View File
@@ -217,10 +217,10 @@ std::ostream& PVUnionArray::dumpValue(std::ostream& o) const
size_t length = getLength();
if (length > 0)
{
format::indent_scope s(o);
format::indent_scope s(o);
for (size_t i = 0; i < length; i++)
dumpValue(o, i);
dumpValue(o, i);
}
return o;
+2 -2
View File
@@ -123,8 +123,8 @@ StructureConstPtr StandardField::createProperties(string id,FieldConstPtr field,
while(gotValueAlarm) {
if(type==epics::pvData::scalar || type==epics::pvData::scalarArray) {
ScalarType scalarType = (type==epics::pvData::scalar) ?
static_pointer_cast<const Scalar>(field)->getScalarType() :
static_pointer_cast<const ScalarArray>(field)->getElementType();
static_pointer_cast<const Scalar>(field)->getScalarType() :
static_pointer_cast<const ScalarArray>(field)->getElementType();
switch(scalarType) {
case pvBoolean: valueAlarm = booleanAlarmField; break;
case pvByte: valueAlarm = byteAlarmField; break;
+1 -1
View File
@@ -338,7 +338,7 @@ namespace epics { namespace pvData {
void BitSet::deserialize(ByteBuffer* buffer, DeserializableControl* control) {
uint32 bytes = static_cast<uint32>(SerializeHelper::readSize(buffer, control)); // in bytes
uint32 bytes = static_cast<uint32>(SerializeHelper::readSize(buffer, control)); // in bytes
size_t wordsInUse = (bytes + 7) / BYTES_PER_WORD;
words.resize(wordsInUse);
+2 -2
View File
@@ -150,7 +150,7 @@ namespace epics { namespace pvData {
*/
virtual void serialize(ByteBuffer *buffer,
SerializableControl *flusher) const = 0;
/**
/**
* Deserialize buffer.
* @param buffer serialization buffer.
* @param flusher deserialization control.
@@ -213,7 +213,7 @@ namespace epics { namespace pvData {
*/
virtual void serialize(ByteBuffer *buffer,
SerializableControl *flusher,BitSet *bitSet) const = 0;
/**
/**
* Deserialize buffer.
* @param buffer serialization buffer.
* @param flusher deserialization control.
+13 -13
View File
@@ -28,10 +28,10 @@ namespace epics { namespace pvData {
class epicsShareClass Status : public epics::pvData::Serializable {
public:
POINTER_DEFINITIONS(Status);
/**
* Status type enum.
*/
enum StatusType {
/**
* Status type enum.
*/
enum StatusType {
/** Operation completed successfully. */
STATUSTYPE_OK,
/** Operation completed successfully, but there is a warning message. */
@@ -40,11 +40,11 @@ namespace epics { namespace pvData {
STATUSTYPE_ERROR,
/** Operation failed due to an unexpected error. */
STATUSTYPE_FATAL
};
static const char* StatusTypeName[];
static Status Ok;
};
static const char* StatusTypeName[];
static Status Ok;
static inline Status warn(const std::string& m) { return Status(STATUSTYPE_WARNING, m); }
static inline Status error(const std::string& m) { return Status(STATUSTYPE_ERROR, m); }
@@ -54,10 +54,10 @@ namespace epics { namespace pvData {
* Creates OK status; STATUSTYPE_OK, empty message and stackDump.
*/
Status() :m_statusType(STATUSTYPE_OK) {}
/**
* Create non-OK status.
*/
/**
* Create non-OK status.
*/
Status(StatusType type, std::string const & message);
/**
+1 -1
View File
@@ -103,7 +103,7 @@ namespace epics {
DeserializableControl* control) {
std::size_t size = SerializeHelper::readSize(buffer, control);
if(size!=(size_t)-1) // TODO null strings check, to be removed in the future
if(size!=(size_t)-1) // TODO null strings check, to be removed in the future
{
if (buffer->getRemaining()>=size)
{
+28 -28
View File
@@ -44,40 +44,40 @@ void Status::maximize(const Status& o)
void Status::serialize(ByteBuffer *buffer, SerializableControl *flusher) const
{
flusher->ensureBuffer(1);
if (m_statusType == STATUSTYPE_OK)
{
// special code for okStatus (optimization)
buffer->putByte((int8)-1);
}
else
{
buffer->putByte((int8)m_statusType);
SerializeHelper::serializeString(m_message, buffer, flusher);
SerializeHelper::serializeString(m_stackDump, buffer, flusher);
}
flusher->ensureBuffer(1);
if (m_statusType == STATUSTYPE_OK)
{
// special code for okStatus (optimization)
buffer->putByte((int8)-1);
}
else
{
buffer->putByte((int8)m_statusType);
SerializeHelper::serializeString(m_message, buffer, flusher);
SerializeHelper::serializeString(m_stackDump, buffer, flusher);
}
}
void Status::deserialize(ByteBuffer *buffer, DeserializableControl *flusher)
{
flusher->ensureData(1);
int8 typeCode = buffer->getByte();
if (typeCode == (int8)-1)
{
// in most of the cases status will be OK, we statistically optimize
if (m_statusType != STATUSTYPE_OK)
{
m_statusType = STATUSTYPE_OK;
flusher->ensureData(1);
int8 typeCode = buffer->getByte();
if (typeCode == (int8)-1)
{
// in most of the cases status will be OK, we statistically optimize
if (m_statusType != STATUSTYPE_OK)
{
m_statusType = STATUSTYPE_OK;
m_message.clear();
m_stackDump.clear();
}
}
else
{
m_statusType = (StatusType)typeCode;
m_message = SerializeHelper::deserializeString(buffer, flusher);
m_stackDump = SerializeHelper::deserializeString(buffer, flusher);
}
}
}
else
{
m_statusType = (StatusType)typeCode;
m_message = SerializeHelper::deserializeString(buffer, flusher);
m_stackDump = SerializeHelper::deserializeString(buffer, flusher);
}
}
void Status::dump(std::ostream& o) const
+8 -8
View File
@@ -948,11 +948,11 @@ public:
typedef PVUnion & reference;
typedef const PVUnion & const_reference;
/**
* Undefined index.
* Default value upon PVUnion construction. Can be set by the user.
* Corresponds to @c null value.
*/
/**
* Undefined index.
* Default value upon PVUnion construction. Can be set by the user.
* Corresponds to @c null value.
*/
static const int32 UNDEFINED_INDEX;
/**
@@ -1081,9 +1081,9 @@ private:
friend class PVDataCreate;
UnionConstPtr unionPtr; // same as PVField::getField()
int32 selector;
PVFieldPtr value;
bool variant;
int32 selector;
PVFieldPtr value;
bool variant;
EPICS_NOT_COPYABLE(PVUnion)
};
+19 -19
View File
@@ -1079,12 +1079,12 @@ public:
//! Create a new instance of in-line @c Field builder pre-initialized with and existing Structure
static FieldBuilderPtr begin(StructureConstPtr S);
/**
* Set ID of an object to be created.
* @param id id to be set.
/**
* Set ID of an object to be created.
* @param id id to be set.
* @return this instance of a @c FieldBuilder.
*/
FieldBuilderPtr setId(std::string const & id);
*/
FieldBuilderPtr setId(std::string const & id);
/**
* Add a @c Scalar.
@@ -1214,20 +1214,20 @@ private:
FieldBuilder(const FieldBuilderPtr & _parentBuilder, const std::string& name, const Union*);
FieldBuilder(const FieldBuilderPtr & _parentBuilder, const std::string& name, const UnionArray*);
FieldBuilder(FieldBuilderPtr const & parentBuilder,
std::string const & nestedName,
Type nestedClassToBuild, bool nestedArray);
std::string const & nestedName,
Type nestedClassToBuild, bool nestedArray);
const Field *findField(const std::string& name, Type ftype);
void reset();
FieldConstPtr createFieldInternal(Type type);
void reset();
FieldConstPtr createFieldInternal(Type type);
friend class FieldCreate;
const FieldCreatePtr fieldCreate;
std::string id;
bool idSet;
std::string id;
bool idSet;
StringArray fieldNames;
FieldConstPtrArray fields;
@@ -1251,11 +1251,11 @@ class epicsShareClass FieldCreate {
friend struct detail::field_factory;
public:
static const FieldCreatePtr &getFieldCreate();
/**
* Create a new instance of in-line @c Field builder.
* @return a new instance of a @c FieldBuilder.
*/
FieldBuilderPtr createFieldBuilder() const;
/**
* Create a new instance of in-line @c Field builder.
* @return a new instance of a @c FieldBuilder.
*/
FieldBuilderPtr createFieldBuilder() const;
/**
* Create a new instance of in-line @c Field builder pre-initialized with and existing Structure
* @return a new instance of a @c FieldBuilder.
@@ -1323,7 +1323,7 @@ public:
* @return a @c Structure interface for the newly created object.
*/
StructureConstPtr createStructure (
std::string const & id,
std::string const & id,
StringArray const & fieldNames,
FieldConstPtrArray const & fields) const;
/**
@@ -1359,7 +1359,7 @@ public:
* @return a @c Union interface for the newly created object.
*/
UnionConstPtr createUnion (
std::string const & id,
std::string const & id,
StringArray const & fieldNames,
FieldConstPtrArray const & fields) const;
/**
+6 -6
View File
@@ -203,8 +203,8 @@ static void testCreateRequestInternal() {
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm})";
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm})";
pvRequest = createRequest->createRequest(request);
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
@@ -241,10 +241,10 @@ static void testCreateRequestInternal() {
testPass("request %s",request.c_str());
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm},"
+ "ps0{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}},"
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm},"
+ "ps0{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}},"
+ "ps1{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}}"
+ ")";
+79 -79
View File
@@ -146,48 +146,48 @@ void testEquals() {
PVDataCreatePtr factory = getPVDataCreate();
testOk1(factory.get()!=NULL);
// be sure all is covered
for (int i = pvBoolean; i < pvString; i++)
{
ScalarType scalarType = static_cast<ScalarType>(i);
// be sure all is covered
for (int i = pvBoolean; i < pvString; i++)
{
ScalarType scalarType = static_cast<ScalarType>(i);
PVScalarPtr scalar1 = factory->createPVScalar(scalarType);
PVScalarPtr scalar2 = factory->createPVScalar(scalarType);
testOk1((*scalar1)==(*scalar2));
PVScalarPtr scalar1 = factory->createPVScalar(scalarType);
PVScalarPtr scalar2 = factory->createPVScalar(scalarType);
testOk1((*scalar1)==(*scalar2));
PVScalarArrayPtr array1 = factory->createPVScalarArray(scalarType);
PVScalarArrayPtr array2 = factory->createPVScalarArray(scalarType);
testOk1((*array1)==(*array2));
}
PVScalarArrayPtr array1 = factory->createPVScalarArray(scalarType);
PVScalarArrayPtr array2 = factory->createPVScalarArray(scalarType);
testOk1((*array1)==(*array2));
}
// and a structure
// and a structure
PVStructurePtr structure1 = factory->createPVStructure(getStandardField()->timeStamp());
PVStructurePtr structure2 = factory->createPVStructure(getStandardField()->timeStamp());
testOk1((*structure1)==(*structure2));
testOk1((*structure1)==(*structure2));
// and a structure array
PVStructureArrayPtr structureArray1 = factory->createPVStructureArray(getFieldCreate()->createStructureArray(structure1->getStructure()));
PVStructureArrayPtr structureArray2 = factory->createPVStructureArray(getFieldCreate()->createStructureArray(structure2->getStructure()));
testOk1((*structureArray1)==(*structureArray2));
// variant union
PVUnionPtr variantUnion1 = factory->createPVVariantUnion();
PVUnionPtr variantUnion2 = factory->createPVVariantUnion();
testOk1((*variantUnion1)==(*variantUnion2));
variantUnion1->set(structure1);
variantUnion2->set(structure1);
testOk1((*variantUnion1)==(*variantUnion2));
testOk1((*structureArray1)==(*structureArray2));
// variant union
PVUnionPtr variantUnion1 = factory->createPVVariantUnion();
PVUnionPtr variantUnion2 = factory->createPVVariantUnion();
testOk1((*variantUnion1)==(*variantUnion2));
variantUnion1->set(structure1);
variantUnion2->set(structure1);
testOk1((*variantUnion1)==(*variantUnion2));
variantUnion2->set(structureArray1);
testOk1((*variantUnion1)!=(*variantUnion2));
// variant union array
PVUnionArrayPtr variantUnionArray1 = factory->createPVVariantUnionArray();
PVUnionArrayPtr variantUnionArray2 = factory->createPVVariantUnionArray();
testOk1((*variantUnionArray1)==(*variantUnionArray2));
variantUnion2->set(structureArray1);
testOk1((*variantUnion1)!=(*variantUnion2));
// variant union array
PVUnionArrayPtr variantUnionArray1 = factory->createPVVariantUnionArray();
PVUnionArrayPtr variantUnionArray2 = factory->createPVVariantUnionArray();
testOk1((*variantUnionArray1)==(*variantUnionArray2));
// union
// union
UnionConstPtr punion = getFieldCreate()->createFieldBuilder()->
add("double", pvDouble)->
add("double2", pvDouble)->
@@ -198,30 +198,30 @@ void testEquals() {
endNested()->
addArray("intArray", pvInt)->
createUnion();
PVUnionPtr union1 = factory->createPVUnion(punion);
PVUnionPtr union2 = factory->createPVUnion(punion);
testOk1((*union1)==(*union2));
union1->select<PVDouble>("double")->put(1.2);
union2->select<PVDouble>("double")->put(1.2);
testOk1((*union1)==(*union2));
union2->select<PVDouble>("double")->put(2.2);
testOk1((*union1)!=(*union2));
PVUnionPtr union1 = factory->createPVUnion(punion);
PVUnionPtr union2 = factory->createPVUnion(punion);
testOk1((*union1)==(*union2));
union1->select<PVDouble>("double")->put(1.2);
union2->select<PVDouble>("double")->put(1.2);
testOk1((*union1)==(*union2));
union2->select<PVDouble>("double")->put(2.2);
testOk1((*union1)!=(*union2));
union2->select<PVDouble>("double2")->put(1.2);
testOk1((*union1)!=(*union2));
union2->select<PVDouble>("double2")->put(1.2);
testOk1((*union1)!=(*union2));
union2->select("nested");
testOk1((*union1)!=(*union2));
union2->select("nested");
testOk1((*union1)!=(*union2));
testOk1((*union1)!=(*variantUnion2));
PVUnionArrayPtr unionArray1 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion));
PVUnionArrayPtr unionArray2 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion));
testOk1((*unionArray1)==(*unionArray2));
testOk1((*union1)!=(*variantUnion2));
PVUnionArrayPtr unionArray1 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion));
PVUnionArrayPtr unionArray2 = factory->createPVUnionArray(getFieldCreate()->createUnionArray(punion));
testOk1((*unionArray1)==(*unionArray2));
testOk1((*variantUnionArray1)!=(*unionArray2));
testOk1((*variantUnionArray1)!=(*unionArray2));
}
template<typename PVT>
@@ -264,7 +264,7 @@ void testScalar() {
testDiag("type %s", ScalarTypeFunc::name(pvBoolean));
PVBooleanPtr pvBoolean =
std::tr1::static_pointer_cast<PVBoolean>(factory->createPVScalar(epics::pvData::pvBoolean));
std::tr1::static_pointer_cast<PVBoolean>(factory->createPVScalar(epics::pvData::pvBoolean));
pvBoolean->put(false);
serializationTest(pvBoolean);
pvBoolean->put(true);
@@ -284,7 +284,7 @@ void testScalar() {
testDiag("type %s", ScalarTypeFunc::name(pvString));
PVStringPtr pvString =
std::tr1::static_pointer_cast<PVString>(factory->createPVScalar(epics::pvData::pvString));
std::tr1::static_pointer_cast<PVString>(factory->createPVScalar(epics::pvData::pvString));
pvString->put("");
serializationTest(pvString);
pvString->put("s");
@@ -382,7 +382,7 @@ void testStructure() {
testOk1(factory.get()!=NULL);
testDiag("\tSimple structure serialization");
PVStructurePtr pvStructure = factory->createPVStructure(getStandardField()->timeStamp());
PVStructurePtr pvStructure = factory->createPVStructure(getStandardField()->timeStamp());
pvStructure->getSubField<PVLong>("secondsPastEpoch")->put(123);
pvStructure->getSubField<PVInt>("nanoseconds")->put(456);
pvStructure->getSubField<PVInt>("userTag")->put(789);
@@ -390,11 +390,11 @@ void testStructure() {
serializationTest(pvStructure);
testDiag("\tComplex structure serialization");
pvStructure = factory->createPVStructure(
getStandardField()->structureArray(
getStandardField()->timeStamp(), "alarm,control,display,timeStamp")
);
// TODO fill with data
pvStructure = factory->createPVStructure(
getStandardField()->structureArray(
getStandardField()->timeStamp(), "alarm,control,display,timeStamp")
);
// TODO fill with data
serializationTest(pvStructure);
}
@@ -469,7 +469,7 @@ void testUnion() {
u = factory->createPVUnion(punion);
testOk1(NULL!=u.get());
// null union test
// null union test
testOk1(NULL==u->get().get());
testOk1(PVUnion::UNDEFINED_INDEX == u->getSelectedIndex());
testOk1("" == u->getSelectedFieldName());
@@ -633,38 +633,38 @@ void serializationFieldTest(FieldConstPtr const & field)
{
testShow()<<CURRENT_FUNCTION<<"\n"<<field;
buffer->clear();
buffer->clear();
// serialize
field->serialize(buffer, flusher);
// serialize
field->serialize(buffer, flusher);
// deserialize
buffer->flip();
// deserialize
buffer->flip();
FieldConstPtr deserializedField = getFieldCreate()->deserialize(buffer, control);
FieldConstPtr deserializedField = getFieldCreate()->deserialize(buffer, control);
testShow()<<" after "<<(void*)field.get()<<" == "<<(void*)deserializedField.get();
testOk1(*field == *deserializedField);
testOk1(*field == *deserializedField);
}
void testIntrospectionSerialization()
{
testDiag("Testing introspection serialization...");
testDiag("Testing introspection serialization...");
FieldCreatePtr factory = getFieldCreate();
testOk1(factory.get()!=NULL);
FieldCreatePtr factory = getFieldCreate();
testOk1(factory.get()!=NULL);
// be sure all is covered
for (int i = pvBoolean; i < pvString; i++)
{
ScalarType scalarType = static_cast<ScalarType>(i);
// be sure all is covered
for (int i = pvBoolean; i < pvString; i++)
{
ScalarType scalarType = static_cast<ScalarType>(i);
ScalarConstPtr scalar = factory->createScalar(scalarType);
serializationFieldTest(scalar);
ScalarConstPtr scalar = factory->createScalar(scalarType);
serializationFieldTest(scalar);
ScalarArrayConstPtr array = factory->createScalarArray(scalarType);
serializationFieldTest(array);
}
ScalarArrayConstPtr array = factory->createScalarArray(scalarType);
serializationFieldTest(array);
}
// and a structure
StructureConstPtr structure = getStandardField()->timeStamp();
+3 -3
View File
@@ -25,7 +25,7 @@ void test_factory()
testOk1(fb.get() != 0);
FieldBuilderPtr fb2 = fieldCreate->createFieldBuilder();
testOk1(fb.get() != fb2.get());
testOk1(fb.get() != fb2.get());
}
void test_structure()
@@ -185,8 +185,8 @@ void test_nestedStructure()
testOk1("intArray" == s->getFieldName(2));
testOk(pvInt == std::tr1::static_pointer_cast<const ScalarArray>(f2)->getElementType(), "f2 element type == int");
}
}
void test_nestedStructureArray()
{