Added error messages to PPI and Utils SENF_ASSERTs
g0dil [Mon, 15 Jun 2009 09:27:18 +0000 (09:27 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1230 270642c3-0616-0410-b53a-bc976706d245

PPI/Connectors.cc
PPI/Connectors.cci
PPI/DebugModules.cc
PPI/Events.cti
PPI/IOEvent.cc
Utils/intrusive_refcount.cci
Utils/pool_alloc_mixin.cti

index 22f3929..4c5a3ea 100644 (file)
 prefix_ void senf::ppi::connector::Connector::connect(Connector & target)
 {
     // The connector is not registered -> route() or noroute() statement missing
-    SENF_ASSERT( module_ );
+    SENF_ASSERT( module_ && 
+                 "senf::ppi::connector::Connector::connect(): (source) "
+                 "Missing route() or noroute()" );
     // The connector is already connected
-    SENF_ASSERT( ! peer_ );
+    SENF_ASSERT( ! peer_ &&
+                 "senf::ppi::connector::Connector::connect(): (source) "
+                 "duplicate connection" );
     // The target connector is not registered -> route() or noroute() statement missing
-    SENF_ASSERT( target.module_ );
+    SENF_ASSERT( target.module_ &&
+                 "senf::ppi::connector::Connector::connect(): (target) "
+                 "Missing route() or noroute()" );
     // The target connector is already connected
-    SENF_ASSERT( ! target.peer_ );
+    SENF_ASSERT( ! target.peer_ &&
+                 "senf::ppi::connector::Connector::connect(): (target) "
+                 "duplicate connection" );
     if (! (packetTypeID() == typeid(void) ||
            target.packetTypeID() == typeid(void) || 
            packetTypeID() == target.packetTypeID()) )
@@ -69,7 +77,8 @@ prefix_ void senf::ppi::connector::Connector::connect(Connector & target)
 prefix_ void senf::ppi::connector::Connector::disconnect()
 {
     // Cannot disconnected a non-connected connector
-    SENF_ASSERT( peer_ );
+    SENF_ASSERT( peer_ &&
+                 "senf::ppi::connector::Connector::disconnect(): Not connected" );
     Connector & peer (*peer_);
     peer_ = 0;
     peer.peer_ = 0;
index 3f24b5d..e6a7391 100644 (file)
@@ -37,7 +37,7 @@ prefix_ senf::ppi::connector::Connector & senf::ppi::connector::Connector::peer(
     const
 {
     // The connector is not connected
-    SENF_ASSERT(peer_);
+    SENF_ASSERT(peer_ && "senf::ppi::connect() call missing");
     return *peer_;
 }
 
@@ -46,7 +46,7 @@ prefix_ senf::ppi::module::Module & senf::ppi::connector::Connector::module()
 {
     // The connector is not registered in the module -> probably a route() or noroute() statement is
     // missing.
-    SENF_ASSERT(module_);
+    SENF_ASSERT(module_ && "Connector not registered: Missing route() or noroute()");
     return *module_;
 }
 
@@ -162,8 +162,8 @@ prefix_ senf::ppi::connector::PassiveConnector::PassiveConnector()
 
 prefix_ void senf::ppi::connector::PassiveConnector::emit()
 {
-    // No event callback has been registered (onEvent() call missing)
-    SENF_ASSERT(callback_);
+    // No event callback has been registered (onRequest() call missing)
+    SENF_ASSERT(callback_ && "senf::ppi::connector::PassiveConnector: missing onRequest()");
     if (!throttled())
         callback_();
 }
@@ -232,7 +232,8 @@ prefix_ senf::Packet senf::ppi::connector::InputConnector::peek()
     const
 {
     // Cannot peek() head of empty queue
-    SENF_ASSERT( ! queue_.empty() );
+    SENF_ASSERT( ! queue_.empty() && 
+                 "senf::ppi::connector::InputConnector: cannot call peek() on empty queue" );
     return queue_.back();
 }
 
index 409c5ce..2826166 100644 (file)
@@ -37,7 +37,9 @@
 
 prefix_ void senf::ppi::module::debug::PassiveSource::request()
 {
-    SENF_ASSERT( ! packets_.empty() );
+    SENF_ASSERT( ! packets_.empty() &&
+                 "senf::ppi::module::debug::PassiveSource::request(): "
+                 "Requesting packet from empty source." );
     output(packets_.front());
     packets_.pop_front();
     if (packets_.empty())
index 1dca3da..435fe3a 100644 (file)
@@ -59,7 +59,8 @@ template <class EventType, class Self>
 prefix_ senf::ppi::detail::EventBinding<EventType> &
 senf::ppi::EventImplementationHelper<EventType,Self>::binding()
 {
-    SENF_ASSERT( static_cast<Self*>(this)->binding_ );
+    SENF_ASSERT( static_cast<Self*>(this)->binding_ &&
+                 "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" );
     return * static_cast<Self*>(this)->binding_;
 }
 
@@ -89,7 +90,8 @@ template <class Self>
 prefix_ senf::ppi::detail::EventBinding<void> &
 senf::ppi::EventImplementationHelper<void,Self>::binding()
 {
-    SENF_ASSERT( static_cast<Self*>(this)->binding_ );
+    SENF_ASSERT( static_cast<Self*>(this)->binding_ &&
+                 "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" );
     return * static_cast<Self*>(this)->binding_;
 }
 
index ea70efc..7517e41 100644 (file)
@@ -59,8 +59,7 @@ prefix_ void senf::ppi::IOEvent::cb(int event)
         else if (event & Hup)
             throw HangupException();
         else
-            // This cannot happen.
-            SENF_ASSERT(false);
+            SENF_ASSERT(false && "Internal failure in senf::ppi::IOEvent::cb(int)");
     } else {
         IOEventInfo info = { event };
         callback(info);
index 7ac3df2..99b23bc 100644 (file)
@@ -52,7 +52,9 @@ prefix_ void senf::intrusive_refcount_base::add_ref()
 
 prefix_ bool senf::intrusive_refcount_base::release()
 {
-    SENF_ASSERT(refcount_>0);
+    SENF_ASSERT(refcount_>0 &&
+                "senf::intrusive_refcount_base: Internal inconsistency: "
+                "Calling release on dead object.");
     return --refcount_ == 0;
 }
 
index e2a80ab..93b062f 100644 (file)
@@ -36,7 +36,9 @@ prefix_ void * senf::pool_alloc_mixin<Self>::operator new(size_t size)
 {
     // When deriving from Self you may not change the class's size without
     // inheriting from pool_alloc_mixin again. See pool_alloc_mixin documentation.
-    SENF_ASSERT( size <= sizeof(Self) );
+    SENF_ASSERT( size <= sizeof(Self) &&
+                 "senf::pool_alloc_mixin::operator new(): "
+                 "Bad object size. Missing pool_alloc_mixin base in derived class?" );
 #ifdef SENF_DEBUG
     allocCounter(1);
 #endif