diff --git a/pvAccessApp/ca/version.cpp b/pvAccessApp/ca/version.cpp index 1b8523f..942e060 100644 --- a/pvAccessApp/ca/version.cpp +++ b/pvAccessApp/ca/version.cpp @@ -5,47 +5,39 @@ * Author: Miha Vitorovic */ +#include + #include "version.h" +using std::stringstream; +using epics::pvData::String; + namespace epics { namespace pvAccess { - using epics::pvData::String; const String Version::getLongVersionString() const { - String ret; - ret += getProductName(); - ret += " ["; - ret += getImplementationLanguage(); - ret += "] v"; - ret += getMajorVersion(); - ret += "."; - ret += getMinorVersion(); - ret += "."; + stringstream ret; + ret<0) { - ret += "D"; - ret += getDevelopmentVersion(); + ret<<"D"<0) { - ret += "D"; - ret += getDevelopmentVersion(); + ret<<"D"< #include -#include "arrayFIFO.h" - using namespace epics::pvAccess; using std::cout; using std::endl; int main(int argc, char *argv[]) { - ArrayFIFO fifo; + ArrayFIFO fifoInt; - assert(fifo.size()==0); - assert(fifo.isEmpty()); + assert(fifoInt.size()==0); + assert(fifoInt.isEmpty()); - cout<<"Testing clear..."< - #include "hexDump.h" +#include + using namespace epics::pvAccess; using std::cout; using std::endl; diff --git a/pvAccessApp/testUtils/wildcharMatcherTest.cpp b/pvAccessApp/testUtils/wildcharMatcherTest.cpp index b4ff3a1..6f56465 100644 --- a/pvAccessApp/testUtils/wildcharMatcherTest.cpp +++ b/pvAccessApp/testUtils/wildcharMatcherTest.cpp @@ -5,11 +5,11 @@ * Author: Miha Vitorovic */ +#include "wildcharMatcher.h" + #include #include -#include "wildcharMatcher.h" - using namespace epics::pvAccess; using std::cout; @@ -59,4 +59,5 @@ int main(int argc, char *argv[]) { cout<<"Testing for '*[p-z]tring*'.\n"; assert(match("*[p-z]tring*", testString)); cout<<"\nPASSED!\n"; + } diff --git a/pvAccessApp/utils/arrayFIFO.h b/pvAccessApp/utils/arrayFIFO.h index 31ed2da..b122f62 100644 --- a/pvAccessApp/utils/arrayFIFO.h +++ b/pvAccessApp/utils/arrayFIFO.h @@ -8,6 +8,10 @@ #ifndef ARRAYFIFO_H_ #define ARRAYFIFO_H_ +#ifdef ARRAY_FIFO_DEBUG +#include +#endif + #include #include @@ -18,7 +22,7 @@ using epics::pvData::BaseException; namespace epics { namespace pvAccess { - template + template class ArrayFIFO { public: /** @@ -117,6 +121,17 @@ namespace epics { */ bool remove(const T e); +#ifdef ARRAY_FIFO_DEBUG + void debugState() { + size_t mask = _size-1; + std::cout<<"h:"<<_head<<",t:"<<_tail<<",c:"<<_size; + std::cout<<",s:"< void ArrayFIFO::arraycopy(T* src, size_t srcPos, T* dest, size_t destPos, size_t length) { - for(size_t i = 0; i=0; i--) + dest[destPos+i] = src[srcPos+i]; + else + for(size_t i = 0; i @@ -237,10 +257,8 @@ namespace epics { if(isEmpty()) THROW_BASE_EXCEPTION("ArrayFIFO empty"); - size_t h = _head; - T result = _elements[h]; // Element is null if deque empty - _elements[h] = NULL; // Must null out slot - _head = (h+1)&(_size-1); + T result = _elements[_head]; // Element is null if deque empty + _head = (_head+1)&(_size-1); return result; } @@ -250,10 +268,8 @@ namespace epics { if(isEmpty()) THROW_BASE_EXCEPTION("ArrayFIFO empty"); - int t = (_tail-1)&(_size-1); - T result = _elements[t]; - _tail = t; - return result; + _tail = (_tail-1)&(_size-1); + return _elements[_tail]; } template @@ -312,11 +328,12 @@ namespace epics { template bool ArrayFIFO::del(const size_t i) { - int mask = _size-1; - int h = _head; - int t = _tail; - int front = (i-h)&mask; - int back = (t-i)&mask; + // i is absolute index in the array + size_t mask = _size-1; + size_t h = _head; + size_t t = _tail; + size_t front = (i-h)&mask; + size_t back = (t-i)&mask; // Invariant: head <= i < tail mod circularity if(front>=((t-h)&mask)) THROW_BASE_EXCEPTION( @@ -329,11 +346,11 @@ namespace epics { } else { // Wrap around arraycopy(_elements, 0, _elements, 1, i); - _elements[0] = _elements[mask]; + if(t>0) _elements[0] = _elements[mask]; arraycopy(_elements, h, _elements, h+1, mask-h); } - _elements[h] = NULL; _head = (h+1)&mask; + return false; } else { @@ -357,10 +374,10 @@ namespace epics { if(isEmpty()) return false; // nothing to do - int mask = _size-1; - int i = _head; + size_t mask = _size-1; + size_t i = _head; while(i!=_tail) { - if(e == _elements[i]) { + if(e==_elements[i]) { del(i); return true; } @@ -369,7 +386,6 @@ namespace epics { return false; } - } } diff --git a/pvAccessApp/utils/hexDump.cpp b/pvAccessApp/utils/hexDump.cpp index 0de66b1..050c502 100644 --- a/pvAccessApp/utils/hexDump.cpp +++ b/pvAccessApp/utils/hexDump.cpp @@ -5,9 +5,10 @@ * Author: Miha Vitorovic */ +#include "hexDump.h" + #include #include -#include "hexDump.h" using namespace epics::pvData; diff --git a/pvAccessApp/utils/wildcharMatcher.cpp b/pvAccessApp/utils/wildcharMatcher.cpp index 3451ef0..f202318 100644 --- a/pvAccessApp/utils/wildcharMatcher.cpp +++ b/pvAccessApp/utils/wildcharMatcher.cpp @@ -5,10 +5,10 @@ * Author: Miha Vitorovic */ -#include - #include "wildcharMatcher.h" +#include + using std::cout; namespace epics {