A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
object-base.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef OBJECT_BASE_H
21 #define OBJECT_BASE_H
22 
23 #include "type-id.h"
24 #include "callback.h"
25 #include <string>
26 #include <list>
27 
38 #define NS_OBJECT_ENSURE_REGISTERED(type) \
39  static struct X ## type ## RegistrationClass \
40  { \
41  X ## type ## RegistrationClass () { \
42  ns3::TypeId tid = type::GetTypeId (); \
43  tid.GetParent (); \
44  } \
45  } x_ ## type ## RegistrationVariable
46 
47 namespace ns3 {
48 
49 class AttributeConstructionList;
50 
62 {
63 public:
67  static TypeId GetTypeId (void);
68 
72  virtual ~ObjectBase ();
73 
82  virtual TypeId GetInstanceTypeId (void) const = 0;
83 
91  void SetAttribute (std::string name, const AttributeValue &value);
98  bool SetAttributeFailSafe (std::string name, const AttributeValue &value);
106  void GetAttribute (std::string name, AttributeValue &value) const;
112  bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const;
113 
121  bool TraceConnect (std::string name, std::string context, const CallbackBase &cb);
128  bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb);
136  bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb);
143  bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb);
144 
145 protected:
152  virtual void NotifyConstructionCompleted (void);
164  void ConstructSelf (const AttributeConstructionList &attributes);
165 
166 private:
169  const AttributeValue &value);
170 
171 };
172 
173 } // namespace ns3
174 
175 #endif /* OBJECT_BASE_H */
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
virtual ~ObjectBase()
Virtual destructor.
Definition: object-base.cc:53
Hold a value for an Attribute.
Definition: attribute.h:56
Base class for Callback class.
Definition: callback.h:848
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Definition: object-base.cc:196
static TypeId GetTypeId(void)
Get the type ID.
Definition: object-base.cc:46
implement the ns-3 type and attribute system
Definition: object-base.h:61
bool TraceDisconnect(std::string name, std::string context, const CallbackBase &cb)
Definition: object-base.cc:323
virtual void NotifyConstructionCompleted(void)
This method is invoked once all member attributes have been initialized.
Definition: object-base.cc:59
bool TraceDisconnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: object-base.cc:310
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: object-base.cc:284
void ConstructSelf(const AttributeConstructionList &attributes)
Definition: object-base.cc:65
void GetAttribute(std::string name, AttributeValue &value) const
Definition: object-base.cc:214
bool DoSet(Ptr< const AttributeAccessor > spec, Ptr< const AttributeChecker > checker, const AttributeValue &value)
Definition: object-base.cc:161
virtual TypeId GetInstanceTypeId(void) const =0
bool TraceConnect(std::string name, std::string context, const CallbackBase &cb)
Definition: object-base.cc:297
bool GetAttributeFailSafe(std::string name, AttributeValue &attribute) const
Definition: object-base.cc:249
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:176
a unique identifier for an interface.
Definition: type-id.h:49