diff --git a/src/common/trace-container.h b/src/common/trace-container.h index b110dad7a..bc32e5257 100644 --- a/src/common/trace-container.h +++ b/src/common/trace-container.h @@ -196,9 +196,7 @@ private: }; // namespace ns3 -#ifndef NDEBUG #include -#endif namespace ns3 { @@ -210,13 +208,18 @@ TraceContainer::SetCallback (char const *name, Callback callback) { if (i->second == name) { - static_cast *> (i->first)->SetCallback (callback); - return; + if (i->first->CheckCallbackType (callback)) + { + static_cast *> (i->first)->SetCallback (callback); + return; + } + else + { + assert (!"non-matching callback"); + } } } -#ifndef NDEBUG assert (false); -#endif } template void @@ -226,13 +229,18 @@ TraceContainer::SetCallback (char const *name, Callback callback) { if (i->second == name) { - static_cast *> (i->first)->SetCallback (callback); - return; + if (i->first->CheckCallbackType (callback)) + { + static_cast *> (i->first)->SetCallback (callback); + return; + } + else + { + assert (!"non-matching callback"); + } } } -#ifndef NDEBUG assert (false); -#endif } template void @@ -242,13 +250,18 @@ TraceContainer::SetCallback (char const *name, Callback callback) { if (i->second == name) { - static_cast *> (i->first)->SetCallback (callback); - return; + if (i->first->CheckCallbackType (callback)) + { + static_cast *> (i->first)->SetCallback (callback); + return; + } + else + { + assert (!"non-matching callback"); + } } } -#ifndef NDEBUG assert (false); -#endif } template void @@ -258,13 +271,18 @@ TraceContainer::SetCallback (char const *name, Callback callba { if (i->second == name) { - static_cast *> (i->first)->SetCallback (callback); - return; + if (i->first->CheckCallbackType (callback)) + { + static_cast *> (i->first)->SetCallback (callback); + return; + } + else + { + assert (!"non-matching callback"); + } } } -#ifndef NDEBUG assert (false); -#endif } template void @@ -274,13 +292,18 @@ TraceContainer::SetCallback (char const *name, Callback cal { if (i->second == name) { - static_cast *> (i->first)->SetCallback (callback); - return; + if (i->first->CheckCallbackType (callback)) + { + static_cast *> (i->first)->SetCallback (callback); + return; + } + else + { + assert (!"non-matching callback"); + } } } -#ifndef NDEBUG assert (false); -#endif }