src/core/model/object-base.cc
changeset 9134 7a750f032acd
parent 9063 32755d0516f4
child 10410 4d4eb8097fa3
equal deleted inserted replaced
9133:bcf7cef191c1 9134:7a750f032acd
    34 NS_OBJECT_ENSURE_REGISTERED (ObjectBase);
    34 NS_OBJECT_ENSURE_REGISTERED (ObjectBase);
    35 
    35 
    36 static TypeId
    36 static TypeId
    37 GetObjectIid (void)
    37 GetObjectIid (void)
    38 {
    38 {
       
    39   NS_LOG_FUNCTION_NOARGS ();
    39   TypeId tid = TypeId ("ns3::ObjectBase");
    40   TypeId tid = TypeId ("ns3::ObjectBase");
    40   tid.SetParent (tid);
    41   tid.SetParent (tid);
    41   return tid;
    42   return tid;
    42 }
    43 }
    43 
    44 
    44 TypeId 
    45 TypeId 
    45 ObjectBase::GetTypeId (void)
    46 ObjectBase::GetTypeId (void)
    46 {
    47 {
       
    48   NS_LOG_FUNCTION_NOARGS ();
    47   static TypeId tid = GetObjectIid ();
    49   static TypeId tid = GetObjectIid ();
    48   return tid;
    50   return tid;
    49 }
    51 }
    50 
    52 
    51 ObjectBase::~ObjectBase () 
    53 ObjectBase::~ObjectBase () 
    52 {
    54 {
       
    55   NS_LOG_FUNCTION (this);
    53 }
    56 }
    54 
    57 
    55 void
    58 void
    56 ObjectBase::NotifyConstructionCompleted (void)
    59 ObjectBase::NotifyConstructionCompleted (void)
    57 {}
    60 {
       
    61   NS_LOG_FUNCTION (this);
       
    62 }
    58 
    63 
    59 void
    64 void
    60 ObjectBase::ConstructSelf (const AttributeConstructionList &attributes)
    65 ObjectBase::ConstructSelf (const AttributeConstructionList &attributes)
    61 {
    66 {
    62   // loop over the inheritance tree back to the Object base class.
    67   // loop over the inheritance tree back to the Object base class.
       
    68   NS_LOG_FUNCTION (this << &attributes);
    63   TypeId tid = GetInstanceTypeId ();
    69   TypeId tid = GetInstanceTypeId ();
    64   do {
    70   do {
    65       // loop over all attributes in object type
    71       // loop over all attributes in object type
    66       NS_LOG_DEBUG ("construct tid="<<tid.GetName ()<<", params="<<tid.GetAttributeN ());
    72       NS_LOG_DEBUG ("construct tid="<<tid.GetName ()<<", params="<<tid.GetAttributeN ());
    67       for (uint32_t i = 0; i < tid.GetAttributeN (); i++)
    73       for (uint32_t i = 0; i < tid.GetAttributeN (); i++)
   138 bool
   144 bool
   139 ObjectBase::DoSet (Ptr<const AttributeAccessor> accessor, 
   145 ObjectBase::DoSet (Ptr<const AttributeAccessor> accessor, 
   140                    Ptr<const AttributeChecker> checker,
   146                    Ptr<const AttributeChecker> checker,
   141                    const AttributeValue &value)
   147                    const AttributeValue &value)
   142 {
   148 {
       
   149   NS_LOG_FUNCTION (this << accessor << checker << &value);
   143   Ptr<AttributeValue> v = checker->CreateValidValue (value);
   150   Ptr<AttributeValue> v = checker->CreateValidValue (value);
   144   if (v == 0)
   151   if (v == 0)
   145     {
   152     {
   146       return false;
   153       return false;
   147     }
   154     }
   148   bool ok = accessor->Set (this, *v);
   155   bool ok = accessor->Set (this, *v);
   149   return ok;
   156   return ok;
   150 }
   157 }
       
   158 
   151 void
   159 void
   152 ObjectBase::SetAttribute (std::string name, const AttributeValue &value)
   160 ObjectBase::SetAttribute (std::string name, const AttributeValue &value)
   153 {
   161 {
       
   162   NS_LOG_FUNCTION (this << name << &value);
   154   struct TypeId::AttributeInformation info;
   163   struct TypeId::AttributeInformation info;
   155   TypeId tid = GetInstanceTypeId ();
   164   TypeId tid = GetInstanceTypeId ();
   156   if (!tid.LookupAttributeByName (name, &info))
   165   if (!tid.LookupAttributeByName (name, &info))
   157     {
   166     {
   158       NS_FATAL_ERROR ("Attribute name="<<name<<" does not exist for this object: tid="<<tid.GetName ());
   167       NS_FATAL_ERROR ("Attribute name="<<name<<" does not exist for this object: tid="<<tid.GetName ());
   168     }
   177     }
   169 }
   178 }
   170 bool 
   179 bool 
   171 ObjectBase::SetAttributeFailSafe (std::string name, const AttributeValue &value)
   180 ObjectBase::SetAttributeFailSafe (std::string name, const AttributeValue &value)
   172 {
   181 {
       
   182   NS_LOG_FUNCTION (this << name << &value);
   173   struct TypeId::AttributeInformation info;
   183   struct TypeId::AttributeInformation info;
   174   TypeId tid = GetInstanceTypeId ();
   184   TypeId tid = GetInstanceTypeId ();
   175   if (!tid.LookupAttributeByName (name, &info))
   185   if (!tid.LookupAttributeByName (name, &info))
   176     {
   186     {
   177       return false;
   187       return false;
   185 }
   195 }
   186 
   196 
   187 void
   197 void
   188 ObjectBase::GetAttribute (std::string name, AttributeValue &value) const
   198 ObjectBase::GetAttribute (std::string name, AttributeValue &value) const
   189 {
   199 {
       
   200   NS_LOG_FUNCTION (this << name << &value);
   190   struct TypeId::AttributeInformation info;
   201   struct TypeId::AttributeInformation info;
   191   TypeId tid = GetInstanceTypeId ();
   202   TypeId tid = GetInstanceTypeId ();
   192   if (!tid.LookupAttributeByName (name, &info))
   203   if (!tid.LookupAttributeByName (name, &info))
   193     {
   204     {
   194       NS_FATAL_ERROR ("Attribute name="<<name<<" does not exist for this object: tid="<<tid.GetName ());
   205       NS_FATAL_ERROR ("Attribute name="<<name<<" does not exist for this object: tid="<<tid.GetName ());
   219 
   230 
   220 
   231 
   221 bool
   232 bool
   222 ObjectBase::GetAttributeFailSafe (std::string name, AttributeValue &value) const
   233 ObjectBase::GetAttributeFailSafe (std::string name, AttributeValue &value) const
   223 {
   234 {
       
   235   NS_LOG_FUNCTION (this << name << &value);
   224   struct TypeId::AttributeInformation info;
   236   struct TypeId::AttributeInformation info;
   225   TypeId tid = GetInstanceTypeId ();
   237   TypeId tid = GetInstanceTypeId ();
   226   if (!tid.LookupAttributeByName (name, &info))
   238   if (!tid.LookupAttributeByName (name, &info))
   227     {
   239     {
   228       return false;
   240       return false;
   253 }
   265 }
   254 
   266 
   255 bool 
   267 bool 
   256 ObjectBase::TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
   268 ObjectBase::TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
   257 {
   269 {
       
   270   NS_LOG_FUNCTION (this << name << &cb);
   258   TypeId tid = GetInstanceTypeId ();
   271   TypeId tid = GetInstanceTypeId ();
   259   Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name);
   272   Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name);
   260   if (accessor == 0)
   273   if (accessor == 0)
   261     {
   274     {
   262       return false;
   275       return false;
   265   return ok;
   278   return ok;
   266 }
   279 }
   267 bool 
   280 bool 
   268 ObjectBase::TraceConnect (std::string name, std::string context, const CallbackBase &cb)
   281 ObjectBase::TraceConnect (std::string name, std::string context, const CallbackBase &cb)
   269 {
   282 {
       
   283   NS_LOG_FUNCTION (this << name << context << &cb);
   270   TypeId tid = GetInstanceTypeId ();
   284   TypeId tid = GetInstanceTypeId ();
   271   Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name);
   285   Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name);
   272   if (accessor == 0)
   286   if (accessor == 0)
   273     {
   287     {
   274       return false;
   288       return false;
   277   return ok;
   291   return ok;
   278 }
   292 }
   279 bool 
   293 bool 
   280 ObjectBase::TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
   294 ObjectBase::TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
   281 {
   295 {
       
   296   NS_LOG_FUNCTION (this << name << &cb);
   282   TypeId tid = GetInstanceTypeId ();
   297   TypeId tid = GetInstanceTypeId ();
   283   Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name);
   298   Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name);
   284   if (accessor == 0)
   299   if (accessor == 0)
   285     {
   300     {
   286       return false;
   301       return false;
   289   return ok;
   304   return ok;
   290 }
   305 }
   291 bool 
   306 bool 
   292 ObjectBase::TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
   307 ObjectBase::TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
   293 {
   308 {
       
   309   NS_LOG_FUNCTION (this << name << context << &cb);
   294   TypeId tid = GetInstanceTypeId ();
   310   TypeId tid = GetInstanceTypeId ();
   295   Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name);
   311   Ptr<const TraceSourceAccessor> accessor = tid.LookupTraceSourceByName (name);
   296   if (accessor == 0)
   312   if (accessor == 0)
   297     {
   313     {
   298       return false;
   314       return false;