changes to queue and to bitSetUtil.

This commit is contained in:
Marty Kraimer
2013-05-16 09:04:42 -04:00
parent 0dd6f01ef6
commit a2ca21a1a6
6 changed files with 3685 additions and 33 deletions
+9 -7
View File
@@ -37,7 +37,7 @@
<h1>EPICS pvDataCPP</h1>
<!-- Maturity: Working Draft or Request for Comments, or Recommendation, and date. -->
<h2 class="nocount">EPICS v4 Working Group, Working Draft, 12-Dec-2012</h2>
<h2 class="nocount">EPICS v4 Working Group, Working Draft, 16-May-2013</h2>
<dl>
<dt>Latest version:</dt>
@@ -46,11 +46,11 @@
</dd>
<dt>This version:</dt>
<dd><a
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20121212.html">pvDataCPP_20121212html</a>
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20130516.html">pvDataCPP_20130516.html</a>
</dd>
<dt>Previous version:</dt>
<dd><a
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20121026.html">pvDataCPP_20121026html</a>
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20121212.html">pvDataCPP_20121212.html</a>
</dd>
<dt>Editors:</dt>
<dd>Marty Kraimer, BNL</dd>
@@ -97,7 +97,9 @@ Control System (EPICS).</a></p>
<h2 class="nocount">Status of this Document</h2>
<p>This is the 12-Dec-2012 version of the C++ implementation of pvData.</p>
<p>This is the 16-May-2013 version of the C++ implementation of pvData.
Since the last version changes were made to queue and to bitSetUtil.
</p>
<p> The text describes software which is a complete implementation of pvData as
currently planned by the EPICS V4 Working Group. </p> </p>
@@ -3179,9 +3181,9 @@ public:
int getNumberFree();
int getNumberUsed();
queueElementPtr &amp; getFree();
void setUsed(queueElementPtr &amp;element);
void setUsed(queueElementPtr const &amp;element);
queueElementPtr &amp; getUsed();
void releaseUsed(queueElementPtr &amp;element);
void releaseUsed(queueElementPtr const &amp;element);
...
};</pre>
@@ -3619,7 +3621,7 @@ be used to schedule multiple callbacks. It has the methods:</p>
<p>The following is also provided:</p>
<pre>class BitSetUtil : private NoDefaultMethods {
public:
static bool compress(BitSet *bitSet,PVStructure *pvStructure);
static bool compress(BitSet const &amp;bitSet,PVStructure const &amp;pvStructure);
};</pre>
<p>This provides functions that operate on a BitSet for a PVStructure. It
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -29,9 +29,9 @@ public:
int getNumberFree();
int getNumberUsed();
queueElementPtr & getFree();
void setUsed(queueElementPtr &element);
void setUsed(queueElementPtr const &element);
queueElementPtr & getUsed();
void releaseUsed(queueElementPtr &element);
void releaseUsed(queueElementPtr const &element);
private:
queueElementPtr nullElement;
queueElementPtrArray elements;
@@ -92,7 +92,7 @@ std::tr1::shared_ptr<T> & Queue<T>::getFree()
}
template <typename T>
void Queue<T>::setUsed(std::tr1::shared_ptr<T> &element)
void Queue<T>::setUsed(std::tr1::shared_ptr<T> const &element)
{
if(element!=elements[nextSetUsed++]) {
throw std::logic_error("not correct queueElement");
@@ -112,7 +112,7 @@ std::tr1::shared_ptr<T> & Queue<T>::getUsed()
}
template <typename T>
void Queue<T>::releaseUsed(std::tr1::shared_ptr<T> &element)
void Queue<T>::releaseUsed(std::tr1::shared_ptr<T> const &element)
{
if(element!=elements[nextReleaseUsed++]) {
throw std::logic_error(
+19 -21
View File
@@ -13,25 +13,31 @@
namespace epics { namespace pvData {
using std::tr1::static_pointer_cast;
using std::size_t;
static bool checkBitSetPVField(
PVField *pvField,BitSet *bitSet,int32 initialOffset)
PVFieldPtr const &pvField,BitSetPtr const &bitSet,int32 initialOffset)
{
bool atLeastOneBitSet = false;
bool allBitsSet = true;
int32 offset = initialOffset;
int32 nbits = pvField->getNumberFields();
if(nbits==1) return bitSet->get(offset);
int32 nextSetBit = bitSet->nextSetBit(offset);
if(nextSetBit>=(offset+nbits)) return false;
if(nextSetBit<0) return false;
if(bitSet->get(offset)) {
if(nbits>1) {
for(int32 i=offset+1; i<offset+nbits; i++) bitSet->clear(i);
}
return true;
}
PVStructure *pvStructure = static_cast<PVStructure *>(pvField);
bool atLeastOneBitSet = false;
bool allBitsSet = true;
PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
offset = pvStructure->getFieldOffset() + 1;
while(offset<initialOffset + nbits) {
PVField *pvSubField = pvStructure->getSubField(offset).get();
PVFieldPtr pvSubField = pvStructure->getSubField(offset);
int32 nbitsNow = pvSubField->getNumberFields();
if(nbitsNow==1) {
if(bitSet->get(offset)) {
@@ -41,24 +47,16 @@ static bool checkBitSetPVField(
}
offset++;
} else {
offset++;
PVStructure *pvSubStructure = static_cast<PVStructure*>(pvField);
PVFieldPtrArray pvSubStructureFields =
pvSubStructure->getPVFields();
int num = pvSubStructure->getStructure()->getNumberFields();
for(int32 i=0; i<num; i++) {
PVField *pvSubSubField = pvSubStructureFields[i].get();
bool result = checkBitSetPVField(pvSubSubField,bitSet,offset);
if(result) {
atLeastOneBitSet = true;
if(!bitSet->get(offset)) {
allBitsSet = false;
}
} else {
bool result = checkBitSetPVField(pvSubField,bitSet,offset);
if(result) {
atLeastOneBitSet = true;
if(!bitSet->get(offset)) {
allBitsSet = false;
}
offset += pvSubSubField->getNumberFields();
} else {
allBitsSet = false;
}
offset += pvSubField->getNumberFields();
}
}
if(allBitsSet) {
@@ -72,7 +70,7 @@ static bool checkBitSetPVField(
return atLeastOneBitSet;
}
bool BitSetUtil::compress(BitSet *bitSet,PVStructure *pvStructure)
bool BitSetUtil::compress(BitSetPtr const &bitSet,PVStructurePtr const &pvStructure)
{
return checkBitSetPVField(pvStructure,bitSet,0);
}
+1 -1
View File
@@ -17,7 +17,7 @@ namespace epics { namespace pvData {
class BitSetUtil : private NoDefaultMethods {
public:
static bool compress(BitSet *bitSet,PVStructure *pvStructure);
static bool compress(BitSetPtr const &bitSet,PVStructurePtr const &pvStructure);
};
}}
+4
View File
@@ -2,6 +2,10 @@ TOP=../..
include $(TOP)/configure/CONFIG
PROD_HOST += testBitSetUtil
testBitSetUtil_SRCS += testBitSetUtil.cpp
testBitSetUtil_LIBS += pvData Com
PROD_HOST += testIntrospect
testIntrospect_SRCS += testIntrospect.cpp
testIntrospect_LIBS += pvData Com