[ekiga] Added a "close" method to Ekiga::ServiceCore



commit 686424f432385c653d16e9ff26e4a2495aca7255
Author: Julien Puydt <jpuydt free fr>
Date:   Tue Jan 22 09:33:47 2013 +0100

    Added a "close" method to Ekiga::ServiceCore
    
    This method will make it easier to find out places where things aren't
    completely initialized at startup. The fact that it returns null pointers
    is a little extreme, but since it's only in debug mode it's ok for now.

 lib/engine/engine.cpp             |    3 +++
 lib/engine/framework/services.cpp |   26 ++++++++++++++++++++++++--
 lib/engine/framework/services.h   |    6 +++++-
 3 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index 4e8f3de..34755bd 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -212,6 +212,9 @@ engine_init (Ekiga::ServiceCorePtr service_core,
   hal_core->audioinput_device_added.connect (boost::bind (&Ekiga::AudioInputCore::add_device, boost::ref (*audioinput_core), _1, _2, _3));
   hal_core->audioinput_device_removed.connect (boost::bind (&Ekiga::AudioInputCore::remove_device, boost::ref (*audioinput_core), _1, _2, _3));
 
+  // from now on, things should have taken their final place
+  service_core->close ();
+
 #if DEBUG_STARTUP
   std::cout << "Here is what ekiga is made of for this run :" << std::endl;
   service_core->dump (std::cout);
diff --git a/lib/engine/framework/services.cpp b/lib/engine/framework/services.cpp
index ce7ec12..5591ad4 100644
--- a/lib/engine/framework/services.cpp
+++ b/lib/engine/framework/services.cpp
@@ -69,6 +69,10 @@ Ekiga::Service::get_string_property (const std::string /*name*/) const
   return result;
 }
 
+Ekiga::ServiceCore::ServiceCore (): closed(false)
+{
+}
+
 Ekiga::ServiceCore::~ServiceCore ()
 {
 #if DEBUG
@@ -127,6 +131,12 @@ Ekiga::ServiceCore::add (ServicePtr service)
   return result;
 }
 
+void
+Ekiga::ServiceCore::close ()
+{
+  closed = true;
+}
+
 Ekiga::ServicePtr
 Ekiga::ServiceCore::get (const std::string name)
 {
@@ -142,13 +152,25 @@ Ekiga::ServiceCore::get (const std::string name)
 
 
 #if DEBUG
+
   if (result)
-    std::cout << "Ekiga::ServiceCore returns " << name << std::endl;
+    if (closed)
+      std::cout << "Ekiga::ServiceCore refuses to return " << name << std::endl;
+    else
+      std::cout << "Ekiga::ServiceCore returns " << name << std::endl;
   else
     std::cout << "Ekiga::ServiceCore doesn't have " << name << std::endl;
-#endif
+
+  if (closed)
+    return ServicePtr();
+  else
+    return result;
+
+#else
 
   return result;
+
+#endif
 }
 
 void
diff --git a/lib/engine/framework/services.h b/lib/engine/framework/services.h
index 1c92d90..ecc4a71 100644
--- a/lib/engine/framework/services.h
+++ b/lib/engine/framework/services.h
@@ -87,7 +87,7 @@ namespace Ekiga
   {
   public:
 
-    ServiceCore () {}
+    ServiceCore ();
 
     ~ServiceCore ();
 
@@ -99,12 +99,16 @@ namespace Ekiga
     boost::shared_ptr<T> get (const std::string name)
     { return boost::dynamic_pointer_cast<T> (get (name)); }
 
+    void close ();
+
     void dump (std::ostream &stream) const;
 
     boost::signal1<void, ServicePtr> service_added;
 
   private:
 
+    bool closed;
+
     typedef std::list<ServicePtr> services_type;
     services_type services;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]