[hydra-commits] kpfleming: branch techdemo/kpfleming/slicing r568 - /techdemo/team/kpfleming/...

SVN commits to the Hydra project hydra-commits at lists.digium.com
Thu Apr 8 18:15:30 CDT 2010


Author: kpfleming
Date: Thu Apr  8 18:15:30 2010
New Revision: 568

URL: https://origsvn.digium.com/svn-view/hydra?view=rev&rev=568
Log:
use some templatey goodness to make usage of this technique in C++ ridiculously simple

Modified:
    techdemo/team/kpfleming/slicing/objects/TestI.cpp
    techdemo/team/kpfleming/slicing/objects/TestI.h

Modified: techdemo/team/kpfleming/slicing/objects/TestI.cpp
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/objects/TestI.cpp?view=diff&rev=568&r1=567&r2=568
==============================================================================
--- techdemo/team/kpfleming/slicing/objects/TestI.cpp (original)
+++ techdemo/team/kpfleming/slicing/objects/TestI.cpp Thu Apr  8 18:15:30 2010
@@ -14,19 +14,34 @@
 using namespace std;
 using namespace Test;
 
-class BPreserverFactory : public Ice::ObjectFactory
+template <typename T>
+class PreserverFactory : public Ice::ObjectFactory
 {
 public:
 	virtual Ice::ObjectPtr create(const string& type) {
-		cout << __FUNCTION__ << " returning object requested for type " << type << endl;
-		return new BPreserver();
+		return new Preserver();
 	}
 	virtual void destroy() {}
+private:
+	class Preserver : virtual public T
+	{
+		vector< ::Ice::Byte > __skippedSlices;
+		virtual void __write(IceInternal::BasicStream* stream) const
+		{
+			stream->writeBlob(__skippedSlices);
+			T::__write(stream);
+		}
+		virtual void __read(IceInternal::BasicStream* stream, bool rid)
+		{
+			stream->readSkippedSliceBlob(__skippedSlices);
+			T::__read(stream, rid);
+		}
+	};
 };
 
 TestI::TestI(const Ice::CommunicatorPtr& communicator)
 {
-	communicator->addObjectFactory(new BPreserverFactory, "::Test::B");
+	communicator->addObjectFactory(new PreserverFactory<B>, B::ice_staticId());
 }
 
 Ice::ObjectPtr
@@ -354,17 +369,3 @@
 {
     current.adapter->getCommunicator()->shutdown();
 }
-
-void
-BPreserver::__write(IceInternal::BasicStream *stream) const
-{
-	stream->writeBlob(__skippedSlices);
-	B::__write(stream);
-}
-
-void
-BPreserver::__read(IceInternal::BasicStream* stream, bool rid)
-{
-	stream->readSkippedSliceBlob(__skippedSlices);
-	B::__read(stream, rid);
-}

Modified: techdemo/team/kpfleming/slicing/objects/TestI.h
URL: https://origsvn.digium.com/svn-view/hydra/techdemo/team/kpfleming/slicing/objects/TestI.h?view=diff&rev=568&r1=567&r2=568
==============================================================================
--- techdemo/team/kpfleming/slicing/objects/TestI.h (original)
+++ techdemo/team/kpfleming/slicing/objects/TestI.h Thu Apr  8 18:15:30 2010
@@ -14,14 +14,6 @@
 #include <Forward.h>
 
 #include <vector>
-
-class BPreserver : virtual public Test::B
-{
-public:
-    virtual void __write(IceInternal::BasicStream*) const;
-    virtual void __read(IceInternal::BasicStream*, bool);
-    ::std::vector< ::Ice::Byte > __skippedSlices;
-};
 
 class TestI : virtual public Test::TestIntf
 {





More information about the asterisk-scf-commits mailing list