Fresco/Berlin/include/Berlin KitImpl.hh,1.13,1.14 ServerContextImpl.hh,1.4,1.5 ServerImpl.hh,1.8,1.9

Stefan Seefeld <[email protected]>
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/Fresco/Berlin/include/Berlin
In directory purcel:/tmp/cvs-serv31700/Berlin/include/Berlin

Modified Files:
	KitImpl.hh ServerContextImpl.hh ServerImpl.hh 
Log Message:
a somewhat lengthy fix for http://issues.fresco.org/bug92

Index: KitImpl.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/include/Berlin/KitImpl.hh,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- KitImpl.hh	25 Jan 2003 22:37:00 -0000	1.13
+++ KitImpl.hh	18 Feb 2003 07:26:23 -0000	1.14
@@ -29,6 +29,7 @@
 #include <Berlin/DefaultPOA.hh>
 
 class ServerImpl;
+class ServerContextImpl;
 class ServantBase;
 
 class KitImpl : public virtual POA_Fresco::Kit,
@@ -37,12 +38,12 @@
 {
   friend class ServerImpl;
 public:
-  KitImpl(const std::string &, const Fresco::Kit::PropertySeq &);
+  KitImpl(const std::string &, const Fresco::Kit::PropertySeq &, ServerContextImpl *);
   ~KitImpl();
-  virtual KitImpl *clone(const Fresco::Kit::PropertySeq &) = 0;
-  const std::string &repo_id() const { return _repo_id;}
-  virtual Fresco::Kit::PropertySeq *properties() { return new Fresco::Kit::PropertySeq(*_props);}
-  virtual void bind(Fresco::ServerContext_ptr) {};
+  virtual KitImpl *clone(const Fresco::Kit::PropertySeq &, ServerContextImpl *) = 0;
+  const std::string &repo_id() const { return my_repo_id;}
+  virtual Fresco::Kit::PropertySeq *properties() { return new Fresco::Kit::PropertySeq(*my_props);}
+  virtual void bind(Fresco::ServerContext_ptr) {}
   virtual CORBA::Boolean supports(const Fresco::Kit::PropertySeq &);
 
   void activate(::ServantBase *);
@@ -53,41 +54,42 @@
   virtual void decrement();
 
 protected:
-    template <typename I, typename Im>
-    typename I::_ptr_type create(Im *impl)
-    {
-	activate(impl);
-	return impl->_this();
-    }
-
-    template <typename I, typename Im>
-    typename I::_ptr_type create_and_set_body(Im *impl, Fresco::Graphic_ptr g)
-    {           
-        activate(impl);
-	impl->body(g);
-        return impl->_this();
-    }
+  template <typename I, typename Im>
+  typename I::_ptr_type create(Im *impl)
+  {
+    activate(impl);
+    return impl->_this();
+  }
+  
+  template <typename I, typename Im>
+  typename I::_ptr_type create_and_set_body(Im *impl, Fresco::Graphic_ptr g)
+  {           
+    activate(impl);
+    impl->body(g);
+    return impl->_this();
+  }
 
 private:
   void activate(PortableServer::POA_ptr);
   void deactivate();
-  PortableServer::POA_var         _poa;
-  const std::string               _repo_id;
-  const Fresco::Kit::PropertySeq *_props;
-  int                             _refcount;
+  PortableServer::POA_var         my_poa;
+  const std::string               my_repo_id;
+  const Fresco::Kit::PropertySeq *my_props;
+  int                             my_refcount;
+  ServerContextImpl              *my_context;
 };
 
 template <typename T>
-inline T *create_kit(const std::string &repo, std::string props[], size_t n)
+inline T *create_prototype(const std::string &repo, std::string props[], size_t n)
 {
   Fresco::Kit::PropertySeq properties;
   properties.length(n/2);
   for (size_t i = 0; i != n/2; ++i)
-    {
-      properties[i].name = CORBA::string_dup((props++)->c_str());
-      properties[i].value = CORBA::string_dup((props++)->c_str());
-    }
-  return new T(repo, properties);
+  {
+    properties[i].name = CORBA::string_dup((props++)->c_str());
+    properties[i].value = CORBA::string_dup((props++)->c_str());
+  }
+  return new T(repo, properties, 0);
 }
 
 #endif

Index: ServerContextImpl.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/include/Berlin/ServerContextImpl.hh,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ServerContextImpl.hh	2 Jun 2002 23:42:19 -0000	1.4
+++ ServerContextImpl.hh	18 Feb 2003 07:26:23 -0000	1.5
@@ -39,7 +39,8 @@
 			  public DefaultPOA
 {
   typedef std::multimap<std::string, KitImpl *> klist_t;
- public:
+  friend class KitImpl;
+public:
   ServerContextImpl(ServerImpl *, const CORBA::PolicyList &, Fresco::ClientContext_ptr);
   ~ServerContextImpl();
   PortableServer::POA_ptr _default_POA() { return DefaultPOA::_default_POA();}
@@ -54,13 +55,14 @@
   CORBA::Object_ptr get_singleton(const char *) 
     throw (Fresco::SecurityException, Fresco::SingletonFailureException);
   bool ping();
- private:
-  static unsigned long      _counter;
-  ServerImpl               *_server;
-  CORBA::PolicyList         _policies;
-  Fresco::ClientContext_var _client;
-  klist_t                   _kits;
-  Prague::Mutex             _mutex;
+private:
+  void erase(KitImpl *);
+  static unsigned long      my_counter;
+  ServerImpl               *my_server;
+  CORBA::PolicyList         my_policies;
+  Fresco::ClientContext_var my_client;
+  klist_t                   my_kits;
+  Prague::Mutex             my_mutex;
 };
 
 #endif

Index: ServerImpl.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/include/Berlin/ServerImpl.hh,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ServerImpl.hh	23 Jan 2003 00:43:01 -0000	1.8
+++ ServerImpl.hh	18 Feb 2003 07:26:23 -0000	1.9
@@ -50,7 +50,7 @@
   typedef std::map<std::string, CORBA::Object_var> smap_t;
 
 public:
-  PortableServer::POA_ptr _default_POA() { return PortableServer::POA::_duplicate(_poa);}
+  PortableServer::POA_ptr _default_POA() { return PortableServer::POA::_duplicate(my_poa);}
 
   typedef std::multimap<std::string, Fresco::Kit::PropertySeq_var> PluginList;
 
@@ -85,8 +85,8 @@
   //. Finds the requested Kit and returns a reference to it.
   template <class K>
   typename K::_ptr_type resolve(const char *,
-	  const Fresco::Kit::PropertySeq &,
-	  PortableServer::POA_ptr);
+				const Fresco::Kit::PropertySeq &,
+				PortableServer::POA_ptr);
 
   //. Starts the server.
   void start();
@@ -108,7 +108,8 @@
   //. Use resolve,
   KitImpl *create(const char *,
 		  const Fresco::Kit::PropertySeq &,
-		  PortableServer::POA_ptr);
+		  PortableServer::POA_ptr,
+		  ServerContextImpl *);
 
 private:
   ServerImpl(const CORBA::PolicyList &);
@@ -119,39 +120,41 @@
   //. Destroys a given Servercontext (and with that the client's resources
   //. in this server).
   static void destroy_context(ServerContextImpl *);
-  PortableServer::POA_var _poa;
-  CORBA::PolicyList       _policies;
-  Prague::Thread          _thread;
-  Prague::Mutex           _mutex;
-  smap_t                  _singletons;
-  clist_t                 _contexts;
-  pmap_t                  _plugins;
-  kmap_t                  _kits;
-  static ServerImpl      *_server;
+  PortableServer::POA_var my_poa;
+  CORBA::PolicyList       my_policies;
+  Prague::Thread          my_thread;
+  Prague::Mutex           my_mutex;
+  smap_t                  my_singletons;
+  clist_t                 my_contexts;
+  pmap_t                  my_plugins;
+  kmap_t                  my_kits;
+  static ServerImpl      *my_server;
 };
 
 template <class K>
-typename K::_ptr_type ServerImpl::resolve(const char *type, const Fresco::Kit::PropertySeq &properties, PortableServer::POA_ptr poa)
+typename K::_ptr_type ServerImpl::resolve(const char *type,
+					  const Fresco::Kit::PropertySeq &properties,
+					  PortableServer::POA_ptr poa)
 {
-    KitImpl *kit = create(type, properties, poa);
-    if (!kit) return K::_nil();
-    typename K::_var_type reference;
-    try
-      {
-	reference = K::_narrow(Fresco::Kit_var(kit->_this()));
-      }
-    catch (CORBA::Exception &e)
-      {
-	std::cerr << "Cannot narrow reference: " << e << std::endl;
-	return K::_nil();
-      }
-    if (CORBA::is_nil(reference))
-      {
-	std::cerr << "Reference has incorrect type" << std::endl;
-	return K::_nil();
-      }
-    _kits.push_back(kit);
-    return reference._retn();
+  KitImpl *kit = create(type, properties, poa, 0);
+  if (!kit) return K::_nil();
+  typename K::_var_type reference;
+  try
+  {
+    reference = K::_narrow(Fresco::Kit_var(kit->_this()));
+  }
+  catch (CORBA::Exception &e)
+  {
+    std::cerr << "Cannot narrow reference: " << e << std::endl;
+    return K::_nil();
+  }
+  if (CORBA::is_nil(reference))
+  {
+    std::cerr << "Reference has incorrect type" << std::endl;
+    return K::_nil();
+  }
+  my_kits.push_back(kit);
+  return reference._retn();
 }
 
 #endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.