[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
Mon Mar 19 11:14:37 CDT 2012


branch "retry_deux" has been updated
       via  5246276cc8d2546abed711bd81705a864cdd16f2 (commit)
      from  93daa487b3f21b9bb78172961cabd602c537f474 (commit)

Summary of changes:
 .../AsteriskSCF/Operations/OperationContextCache.h |   46 ++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)


- Log -----------------------------------------------------------------
commit 5246276cc8d2546abed711bd81705a864cdd16f2
Author: David M. Lee <dlee at digium.com>
Date:   Mon Mar 19 10:46:49 2012 -0500

    Added ValueOperationContextCookie

diff --git a/include/AsteriskSCF/Operations/OperationContextCache.h b/include/AsteriskSCF/Operations/OperationContextCache.h
index c9a41d9..c4374ce 100644
--- a/include/AsteriskSCF/Operations/OperationContextCache.h
+++ b/include/AsteriskSCF/Operations/OperationContextCache.h
@@ -41,6 +41,52 @@ public:
 };
 typedef ASTSCF_DLL_EXPORT boost::shared_ptr<OperationContextCookie> OperationContextCookiePtr;
 
+/**
+ * An OperationContextCookie which can hold a single, copyable value.
+ * Ice proxies are very typical, as are literal values. Be careful when using
+ * smart pointers, so that you don't change the contents of the stored value
+ * behind the scenes.
+ *
+ * The value may also be set to an Ice exception, which will be thrown on the
+ * call to get().
+ *
+ * The only constraints on T are 1) it must have a default constructor and 2)
+ * must the assignment operator defined.
+ */
+template<typename T>
+class ValueOperationContextCookie : public OperationContextCookie
+{
+public:
+    /** Set the value of this cookie. */
+    void set(const T& v)
+    {
+        val = v;
+    }
+
+    /** Set the exception value of this cookie. */
+    void setException(const IceUtil::Exception& e)
+    {
+        ex.reset(e.ice_clone());
+    }
+
+    /**
+     * If setException has been called, throw that exception. Otherwise,
+     * return the value of this cookie.
+     */
+    T get() const
+    {
+        if (ex)
+        {
+            ex->ice_throw();
+        }
+        return val;
+    }
+
+private:
+    boost::shared_ptr<IceUtil::Exception> ex;
+    T val;
+};
+
 class OperationContextCache;
 typedef boost::shared_ptr<OperationContextCache> OperationContextCachePtr;
 

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


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



More information about the asterisk-scf-commits mailing list