From da3541e88d5cd3f9c47f263e8104d0dc238138d4 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 13:15:53 -0700 Subject: [PATCH] cleanup. --- src/core/config.cc | 4 +-- src/core/object-base.cc | 23 ++++++++++++++-- src/core/object-base.h | 61 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 81 insertions(+), 7 deletions(-) diff --git a/src/core/config.cc b/src/core/config.cc index ca03fd25f..cd47003e8 100644 --- a/src/core/config.cc +++ b/src/core/config.cc @@ -369,7 +369,7 @@ ConfigImpl::Connect (std::string path, const CallbackBase &cb) m_cb (cb) {} private: virtual void DoOne (Ptr object, std::string path, std::string name) { - object->TraceConnectWithoutContext (name, path, m_cb); + object->TraceConnect (name, path, m_cb); } CallbackBase m_cb; } resolver = ConnectWithContextResolver (path, cb); @@ -389,7 +389,7 @@ ConfigImpl::Disconnect (std::string path, const CallbackBase &cb) m_cb (cb) {} private: virtual void DoOne (Ptr object, std::string path, std::string name) { - object->TraceDisconnectWithoutContext (name, path, m_cb); + object->TraceDisconnect (name, path, m_cb); } CallbackBase m_cb; } resolver = DisconnectWithContextResolver (path, cb); diff --git a/src/core/object-base.cc b/src/core/object-base.cc index 9c3ea4f4b..09f736628 100644 --- a/src/core/object-base.cc +++ b/src/core/object-base.cc @@ -1,3 +1,22 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008 INRIA + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Mathieu Lacage + */ #include "object-base.h" #include "log.h" #include "trace-source-accessor.h" @@ -254,7 +273,7 @@ ObjectBase::TraceConnectWithoutContext (std::string name, const CallbackBase &cb return ok; } bool -ObjectBase::TraceConnectWithoutContext (std::string name, std::string context, const CallbackBase &cb) +ObjectBase::TraceConnect (std::string name, std::string context, const CallbackBase &cb) { TypeId tid = GetInstanceTypeId (); Ptr accessor = tid.LookupTraceSourceByName (name); @@ -278,7 +297,7 @@ ObjectBase::TraceDisconnectWithoutContext (std::string name, const CallbackBase return ok; } bool -ObjectBase::TraceDisconnectWithoutContext (std::string name, std::string context, const CallbackBase &cb) +ObjectBase::TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) { TypeId tid = GetInstanceTypeId (); Ptr accessor = tid.LookupTraceSourceByName (name); diff --git a/src/core/object-base.h b/src/core/object-base.h index b19eb7f26..91f43b9b3 100644 --- a/src/core/object-base.h +++ b/src/core/object-base.h @@ -1,3 +1,22 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008 INRIA + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Mathieu Lacage + */ #ifndef OBJECT_BASE_H #define OBJECT_BASE_H @@ -89,19 +108,55 @@ public: */ bool GetAttributeFailSafe (std::string name, Attribute &attribute) const; + /** + * \param name the name of the targetted trace source + * \param context the trace context associated to the callback + * \param cb the callback to connect to the trace source. + * + * The targetted trace source should be registered with TypeId::AddTraceSource. + */ + bool TraceConnect (std::string name, std::string context, const CallbackBase &cb); + /** + * \param name the name of the targetted trace source + * \param cb the callback to connect to the trace source. + * + * The targetted trace source should be registered with TypeId::AddTraceSource. + */ bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb); - bool TraceConnectWithoutContext (std::string name, std::string context, const CallbackBase &cb); + /** + * \param name the name of the targetted trace source + * \param context the trace context associated to the callback + * \param cb the callback to disconnect from the trace source. + * + * The targetted trace source should be registered with TypeId::AddTraceSource. + */ + bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb); + /** + * \param name the name of the targetted trace source + * \param cb the callback to disconnect from the trace source. + * + * The targetted trace source should be registered with TypeId::AddTraceSource. + */ bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb); - bool TraceDisconnectWithoutContext (std::string name, std::string context, const CallbackBase &cb); protected: + /** + * This method is invoked once all member attributes have been + * initialized. Subclasses can override this method to be notified + * of this event but if they do this, they must chain up to their + * parent's NotifyConstructionCompleted method. + */ virtual void NotifyConstructionCompleted (void); /** * \param attributes the attribute values used to initialize * the member variables of this object's instance. * * Invoked from subclasses to initialize all of their - * attribute members. + * attribute members. This method will typically be invoked + * automatically from ns3::CreateObject if your class derives + * from ns3::Object. If you derive from ns3::ObjectBase directly, + * you should make sure that you invoke this method from + * your most-derived constructor. */ void ConstructSelf (const AttributeList &attributes);