From 4bc7e9c8fe571936bd07fe588c2e358926f74a30 Mon Sep 17 00:00:00 2001
From: Marty Kraimer EPICS pvDataCPP
-EPICS v4 Working Group, Working Draft, 01-Oct-2012
+EPICS v4 Working Group, Working Draft, 12-Dec-2012
This is the 01-Oct-2012 version of the C++ implementation of pvData.
+This is the 12-Dec-2012 version of the C++ implementation of pvData.
The text describes software which is a complete implementation of pvData as currently planned by the EPICS V4 Working Group.
@@ -865,8 +865,7 @@ typedef std::tr1::shared_ptr<PostHandler> PostHandlerPtrPostHandler is a class that must be implemented by any code that calls setPostHandler. It's single virtual method. postPut is called whenever PVField::postPut is called.
-class PostHandler : - public std::tr1::enable_shared_from_this<PostHandler> +class PostHandler { public: POINTER_DEFINITIONS(PostHandler); @@ -3037,6 +3036,7 @@ public: ~Lock(); void lock(); void unlock(); + bool tryLock(); bool ownsLock() ; ... };diff --git a/pvDataApp/factory/PVDataCreateFactory.cpp b/pvDataApp/factory/PVDataCreateFactory.cpp index 9dfe41b..95de04f 100644 --- a/pvDataApp/factory/PVDataCreateFactory.cpp +++ b/pvDataApp/factory/PVDataCreateFactory.cpp @@ -62,7 +62,11 @@ templateT BasePVScalar ::get() const { return value;} template -void BasePVScalar ::put(T val){value = val;} +void BasePVScalar ::put(T val) +{ + value = val; + PVField::postPut(); +} template void BasePVScalar ::serialize(ByteBuffer *pbuffer, @@ -120,7 +124,11 @@ BasePVString::~BasePVString() {} String BasePVString::get() const { return value;} -void BasePVString::put(String val){value = val;} +void BasePVString::put(String val) +{ + value = val; + postPut(); +} void BasePVString::serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) const diff --git a/pvDataApp/factory/PVField.cpp b/pvDataApp/factory/PVField.cpp index c3526f3..da8575e 100644 --- a/pvDataApp/factory/PVField.cpp +++ b/pvDataApp/factory/PVField.cpp @@ -158,7 +158,7 @@ void PVField::renameField(String const & newName) void PVField::postPut() { - if(postHandler!=NULL) postHandler->postPut(); + if(postHandler.get()!=NULL) postHandler->postPut(); } void PVField::setPostHandler(PostHandlerPtr const &handler) diff --git a/pvDataApp/misc/lock.h b/pvDataApp/misc/lock.h index e80d356..2147053 100644 --- a/pvDataApp/misc/lock.h +++ b/pvDataApp/misc/lock.h @@ -44,6 +44,15 @@ public: locked=false; } } + bool tryLock() + { + if(locked) return true; + if(mutexPtr.tryLock()) { + locked = true; + return true; + } + return false; + } bool ownsLock() const{return locked;} private: Mutex &mutexPtr; diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index 77e39cf..b04d737 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -75,6 +75,8 @@ typedef std::vector ::const_iterator PVStructurePtrArray_const__i * typedef for a pointer to a PVStructureArray. */ typedef std::tr1::shared_ptr PVStructureArrayPtr; +typedef std::vector PVStructureArrayPtrArray; +typedef std::tr1::shared_ptr PVStructureArrayPtrArrayPtr; /** * This class provides auxillary information about a PVField. @@ -140,8 +142,7 @@ private: /** * This class is implemented by code that calls setPostHander */ -class PostHandler : - public std::tr1::enable_shared_from_this +class PostHandler { public: POINTER_DEFINITIONS(PostHandler);