[asterisk-scf-commits] asterisk-scf/integration/ice-util-cpp.git branch "retry_deux" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Apr 10 23:09:55 CDT 2012


branch "retry_deux" has been updated
       via  0a25aef8e805309a8ba2acc85eacf50a86d0ed25 (commit)
      from  54946d2c286325ab9172a330b30bfab2ed3f853c (commit)

Summary of changes:
 include/AsteriskSCF/Operations/OperationContext.h |   10 ++++-
 include/AsteriskSCF/Operations/OperationMonitor.h |   47 ++++++++++++++++++++-
 src/Operations/OperationContext.cpp               |    9 ++++
 3 files changed, 64 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit 0a25aef8e805309a8ba2acc85eacf50a86d0ed25
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Apr 10 23:09:42 2012 -0500

    Minor updates.

diff --git a/include/AsteriskSCF/Operations/OperationContext.h b/include/AsteriskSCF/Operations/OperationContext.h
index 230f7a0..fef2d01 100644
--- a/include/AsteriskSCF/Operations/OperationContext.h
+++ b/include/AsteriskSCF/Operations/OperationContext.h
@@ -32,7 +32,15 @@ ASTSCF_DLL_EXPORT AsteriskSCF::System::V1::OperationContextPtr createContext();
  * Create a new OperationContext that has the same transaction id as the input argument.
  *  @param context The source OperationContext that contains the transaction id to use. 
  */
-ASTSCF_DLL_EXPORT AsteriskSCF::System::V1::OperationContextPtr createContext(const AsteriskSCF::System::V1::OperationContextPtr& context);
+ASTSCF_DLL_EXPORT AsteriskSCF::System::V1::OperationContextPtr createContext(const AsteriskSCF::System::V1::OperationContextPtr& sourceContext);
+
+/** 
+ * Create a new OperationContext using a name calculated from the sourceContext, 
+ * and having the same transactionId as the source context. 
+ */
+ASTSCF_DLL_EXPORT AsteriskSCF::System::V1::OperationContextPtr calculateOperationContext(
+    const AsteriskSCF::System::V1::OperationContextPtr& sourceContext, 
+    const std::string& modifier);
 
 } // End namespace Operations
 } // End namespace AsteriskSCF
diff --git a/include/AsteriskSCF/Operations/OperationMonitor.h b/include/AsteriskSCF/Operations/OperationMonitor.h
index 8e3cda0..ce9712c 100755
--- a/include/AsteriskSCF/Operations/OperationMonitor.h
+++ b/include/AsteriskSCF/Operations/OperationMonitor.h
@@ -205,6 +205,9 @@ public:
         return mResult;
     }
 
+    // A smart pointer for this type. 
+    typedef boost::shared_ptr<ContextResultData<RT> > ptr_type;
+
 protected:
     virtual void onSetResult() {}
     RT mResult;
@@ -311,7 +314,10 @@ public:
         return mAMDProxy;
     }
 
-    typedef boost::shared_ptr<AMDContextData<CB> > Ptr;
+    // A smart pointer for this type. 
+    typedef boost::shared_ptr<AMDContextData<CB> > ptr_type;
+
+    typedef CB callback_type;
 
 private:
     void onSetException();
@@ -473,6 +479,11 @@ public:
         mCallbacks.push_back(cbPtr);
     }
 
+    // A smart pointer for this type. 
+    typedef boost::shared_ptr<AMDContextResultData<RT,CB> > ptr_type;
+
+    typedef CB callback_type;
+
 private:
     void onSetResult()
     {
@@ -571,5 +582,39 @@ ASTSCF_DLL_EXPORT DT getContext(const AsteriskSCF::Operations::OperationContextC
     }
 }
 
+/**
+ * Gets a OperationContextCookie subclass for a given context, creating it if necessary.
+ *
+ * If the context is already in the cache, the amdCallback is added to the existing cookie and null is
+ * returned; nothing else need be done.
+ *
+ * If the context is not in the cache, a new cookie is created, the amdCallback is added to it, and the
+ * new cookie is returned. The caller then needs to complete normal execution, and either setException() or
+ * setResult() on the cookie when finished.
+ *
+ * NOTE: This version assumes the cookie type T is either an instance of AMDContextResultData or AMDContextData. 
+ * It uses the exposed callback_type and ptr_type. It needs a test. 
+ *
+ * @param  T AMDContextResultData or AMDContextData instance
+ */
+template <class T>
+ASTSCF_DLL_EXPORT typename T::ptr_type getContext(const AsteriskSCF::Operations::OperationContextCachePtr& cache,
+    const AsteriskSCF::System::V1::OperationContextPtr& context,
+    const typename T::callback_type& amdCallback)
+{
+    std::pair<bool, typename T::ptr_type> cacheHit = getContextSync<typename T::ptr_type>(cache, context);
+
+    cacheHit.second->addCB(amdCallback);
+
+    typename T::ptr_type c(new typename T);
+    AsteriskSCF::Operations::OperationContextCookiePtr o;
+
+    if (cacheHit.first)
+    {
+        return T::ptr_type();
+    }
+    return cacheHit.second;
+}
+
 } /* End of namespace Operations */
 } /* End of namespace AsteriskSCF */
diff --git a/src/Operations/OperationContext.cpp b/src/Operations/OperationContext.cpp
index 0848914..58fc3f9 100755
--- a/src/Operations/OperationContext.cpp
+++ b/src/Operations/OperationContext.cpp
@@ -51,5 +51,14 @@ OperationContextPtr createContext(const OperationContextPtr& operationContext)
     return newContext;
 }
 
+OperationContextPtr calculateOperationContext(
+    const OperationContextPtr& sourceContext, 
+    const std::string& modifier)
+{
+    std::string calculateId = sourceContext->id + "." + modifier;
+    
+    return new OperationContext(calculateId, sourceContext->transactionId);
+}
+
 } // End namespace Operations
 } // End namespace AsteriskSCF

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list