src/core/object.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 11 Mar 2008 13:46:22 -0700
changeset 2594 a8f89acd17a1
parent 2593 5f22033d1408
child 2602 d9262bff6df2
permissions -rw-r--r--
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2007 INRIA, Gustavo Carneiro
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Authors: Gustavo Carneiro <gjcarneiro@gmail.com>,
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 *          Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
 */
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
    21
#include "object.h"
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "assert.h"
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include "singleton.h"
2438
e2ac9f9aeeb9 value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2436
diff changeset
    24
#include "attribute.h"
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    25
#include "trace-source-accessor.h"
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1420
diff changeset
    26
#include "log.h"
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2489
diff changeset
    27
#include "string.h"
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
#include <vector>
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    29
#include <sstream>
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1420
diff changeset
    31
NS_LOG_COMPONENT_DEFINE ("Object");
1374
77468496f7e0 avoid problems with recursive use of Object::DoCollectSources
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1372
diff changeset
    32
2233
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    33
/*********************************************************************
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    34
 *         Helper code
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    35
 *********************************************************************/
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
    36
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
namespace {
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    39
class IidManager
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
{
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
public:
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    42
  IidManager ();
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    43
  uint16_t AllocateUid (std::string name);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    44
  void SetParent (uint16_t uid, uint16_t parent);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    45
  void SetTypeName (uint16_t uid, std::string typeName);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    46
  void SetGroupName (uint16_t uid, std::string groupName);
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
    47
  void AddConstructor (uint16_t uid, ns3::CallbackBase callback);
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    48
  uint16_t GetUid (std::string name) const;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    49
  std::string GetName (uint16_t uid) const;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    50
  uint16_t GetParent (uint16_t uid) const;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    51
  std::string GetTypeName (uint16_t uid) const;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    52
  std::string GetGroupName (uint16_t uid) const;
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
    53
  ns3::CallbackBase GetConstructor (uint16_t uid);
2241
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
    54
  bool HasConstructor (uint16_t uid);
2239
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
    55
  uint32_t GetRegisteredN (void);
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
    56
  uint16_t GetRegistered (uint32_t i);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    57
  void AddAttribute (uint16_t uid, 
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    58
                     std::string name,
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    59
                     std::string help, 
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    60
                     uint32_t flags,
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
    61
                     ns3::Attribute initialValue,
2436
23415bac7eaf Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2435
diff changeset
    62
                     ns3::Ptr<const ns3::AttributeAccessor> spec,
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
    63
                     ns3::Ptr<const ns3::AttributeChecker> checker);
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
    64
  uint32_t GetAttributeListN (uint16_t uid) const;
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    65
  std::string GetAttributeName (uint16_t uid, uint32_t i) const;
2573
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
    66
  std::string GetAttributeHelp (uint16_t uid, uint32_t i) const;
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    67
  uint32_t GetAttributeFlags (uint16_t uid, uint32_t i) const;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    68
  ns3::Attribute GetAttributeInitialValue (uint16_t uid, uint32_t i) const;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    69
  ns3::Ptr<const ns3::AttributeAccessor> GetAttributeAccessor (uint16_t uid, uint32_t i) const;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    70
  ns3::Ptr<const ns3::AttributeChecker> GetAttributeChecker (uint16_t uid, uint32_t i) const;
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    71
  void AddTraceSource (uint16_t uid,
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    72
                       std::string name, 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    73
                       std::string help,
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    74
                       ns3::Ptr<const ns3::TraceSourceAccessor> accessor);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    75
  uint32_t GetTraceSourceN (uint16_t uid) const;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    76
  std::string GetTraceSourceName (uint16_t uid, uint32_t i) const;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    77
  std::string GetTraceSourceHelp (uint16_t uid, uint32_t i) const;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    78
  ns3::Ptr<const ns3::TraceSourceAccessor> GetTraceSourceAccessor (uint16_t uid, uint32_t i) const;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    79
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    80
private:
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    81
  struct AttributeInformation {
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    82
    std::string name;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    83
    std::string help;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    84
    uint32_t flags;
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
    85
    ns3::Attribute initialValue;
2436
23415bac7eaf Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2435
diff changeset
    86
    ns3::Ptr<const ns3::AttributeAccessor> param;
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
    87
    ns3::Ptr<const ns3::AttributeChecker> checker;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    88
  };
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    89
  struct TraceSourceInformation {
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    90
    std::string name;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    91
    std::string help;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    92
    ns3::Ptr<const ns3::TraceSourceAccessor> accessor;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
    93
  };
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    94
  struct IidInformation {
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    95
    std::string name;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
    96
    uint16_t parent;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    97
    std::string typeName;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    98
    std::string groupName;
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
    99
    bool hasConstructor;
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   100
    ns3::CallbackBase constructor;
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   101
    std::vector<struct AttributeInformation> attributes;
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   102
    std::vector<struct TraceSourceInformation> traceSources;
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   103
  };
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   104
  typedef std::vector<struct IidInformation>::const_iterator Iterator;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   105
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   106
  struct IidManager::IidInformation *LookupInformation (uint16_t uid) const;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   107
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   108
  std::vector<struct IidInformation> m_information;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   109
};
1346
47de68729c86 an untested interface id trace resolver
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1340
diff changeset
   110
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   111
IidManager::IidManager ()
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   112
{}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   113
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   114
uint16_t 
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   115
IidManager::AllocateUid (std::string name)
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   116
{
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   117
  uint16_t j = 1;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   118
  for (Iterator i = m_information.begin (); i != m_information.end (); i++)
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   119
    {
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   120
      if (i->name == name)
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   121
        {
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   122
          NS_FATAL_ERROR ("Trying to allocate twice the same uid: " << name);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   123
          return 0;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   124
        }
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   125
      j++;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   126
    }
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   127
  struct IidInformation information;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   128
  information.name = name;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   129
  information.parent = 0;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   130
  information.typeName = "";
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   131
  information.groupName = "";
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   132
  information.hasConstructor = false;
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   133
  m_information.push_back (information);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   134
  uint32_t uid = m_information.size ();
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   135
  NS_ASSERT (uid <= 0xffff);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   136
  return uid;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   137
}
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   138
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   139
struct IidManager::IidInformation *
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   140
IidManager::LookupInformation (uint16_t uid) const
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   141
{
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   142
  NS_ASSERT (uid <= m_information.size ());
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   143
  return const_cast<struct IidInformation *> (&m_information[uid-1]);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   144
}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   145
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
void 
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   147
IidManager::SetParent (uint16_t uid, uint16_t parent)
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   148
{
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   149
  NS_ASSERT (parent <= m_information.size ());
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   150
  struct IidInformation *information = LookupInformation (uid);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   151
  information->parent = parent;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   152
}
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   153
void 
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   154
IidManager::SetTypeName (uint16_t uid, std::string typeName)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   155
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   156
  struct IidInformation *information = LookupInformation (uid);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   157
  information->typeName = typeName;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   158
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   159
void 
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   160
IidManager::SetGroupName (uint16_t uid, std::string groupName)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   161
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   162
  struct IidInformation *information = LookupInformation (uid);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   163
  information->groupName = groupName;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   164
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   165
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   166
void 
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   167
IidManager::AddConstructor (uint16_t uid, ns3::CallbackBase callback)
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   168
{
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   169
  struct IidInformation *information = LookupInformation (uid);
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   170
  if (information->hasConstructor)
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   171
    {
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   172
      NS_FATAL_ERROR (information->name<<" already has a constructor.");
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   173
    }
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   174
  information->hasConstructor = true;
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   175
  information->constructor = callback;
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   176
}
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   177
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   178
uint16_t 
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   179
IidManager::GetUid (std::string name) const
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   180
{
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   181
  uint32_t j = 1;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   182
  for (Iterator i = m_information.begin (); i != m_information.end (); i++)
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   183
    {
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   184
      if (i->name == name)
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   185
        {
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   186
          NS_ASSERT (j <= 0xffff);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   187
          return j;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   188
        }
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   189
      j++;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   190
    }
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   191
  return 0;
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   192
}
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   193
std::string 
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   194
IidManager::GetName (uint16_t uid) const
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   195
{
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   196
  struct IidInformation *information = LookupInformation (uid);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   197
  return information->name;
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
}
712
0708bee3dbf3 use a 16 bit interface id
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 711
diff changeset
   199
uint16_t 
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   200
IidManager::GetParent (uint16_t uid) const
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   201
{
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   202
  struct IidInformation *information = LookupInformation (uid);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   203
  return information->parent;
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
}
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   205
std::string 
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   206
IidManager::GetTypeName (uint16_t uid) const
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   207
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   208
  struct IidInformation *information = LookupInformation (uid);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   209
  return information->typeName;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   210
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   211
std::string 
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   212
IidManager::GetGroupName (uint16_t uid) const
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   213
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   214
  struct IidInformation *information = LookupInformation (uid);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   215
  return information->groupName;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   216
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   217
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   218
ns3::CallbackBase 
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   219
IidManager::GetConstructor (uint16_t uid)
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   220
{
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   221
  struct IidInformation *information = LookupInformation (uid);
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   222
  if (!information->hasConstructor)
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   223
    {
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   224
      NS_FATAL_ERROR ("Requested constructor for "<<information->name<<" but it does not have one.");
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   225
    }
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   226
  return information->constructor;
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   227
}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   228
2241
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   229
bool 
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   230
IidManager::HasConstructor (uint16_t uid)
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   231
{
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   232
  struct IidInformation *information = LookupInformation (uid);
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   233
  return information->hasConstructor;
2241
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   234
}
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   235
2239
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   236
uint32_t 
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   237
IidManager::GetRegisteredN (void)
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   238
{
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   239
  return m_information.size ();
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   240
}
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   241
uint16_t 
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   242
IidManager::GetRegistered (uint32_t i)
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   243
{
2247
56b3591fa3b0 use NS_OBJECT_ENSURE_REGISTERED and fix off-by-one in IidManager::GetRegistered
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2243
diff changeset
   244
  return i + 1;
2239
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   245
}
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   246
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   247
void 
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   248
IidManager::AddAttribute (uint16_t uid, 
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   249
                          std::string name,
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   250
                          std::string help, 
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   251
                          uint32_t flags,
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
   252
                          ns3::Attribute initialValue,
2436
23415bac7eaf Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2435
diff changeset
   253
                          ns3::Ptr<const ns3::AttributeAccessor> spec,
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   254
                          ns3::Ptr<const ns3::AttributeChecker> checker)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   255
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   256
  struct IidInformation *information = LookupInformation (uid);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   257
  for (std::vector<struct AttributeInformation>::const_iterator j = information->attributes.begin ();
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   258
       j != information->attributes.end (); j++)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   259
    {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   260
      if (j->name == name)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   261
        {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   262
          NS_FATAL_ERROR ("Registered the same attribute twice name=\""<<name<<"\" in TypeId=\""<<information->name<<"\"");
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   263
          return;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   264
        }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   265
    }
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   266
  struct AttributeInformation param;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   267
  param.name = name;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   268
  param.help = help;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   269
  param.flags = flags;
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   270
  param.initialValue = initialValue;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   271
  param.param = spec;
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   272
  param.checker = checker;
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   273
  information->attributes.push_back (param);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   274
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   275
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   276
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   277
uint32_t 
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   278
IidManager::GetAttributeListN (uint16_t uid) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   279
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   280
  struct IidInformation *information = LookupInformation (uid);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   281
  return information->attributes.size ();
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   282
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   283
std::string 
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   284
IidManager::GetAttributeName (uint16_t uid, uint32_t i) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   285
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   286
  struct IidInformation *information = LookupInformation (uid);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   287
  NS_ASSERT (i < information->attributes.size ());
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   288
  return information->attributes[i].name;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   289
}
2573
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   290
std::string 
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   291
IidManager::GetAttributeHelp (uint16_t uid, uint32_t i) const
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   292
{
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   293
  struct IidInformation *information = LookupInformation (uid);
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   294
  NS_ASSERT (i < information->attributes.size ());
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   295
  return information->attributes[i].help;
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   296
}
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   297
uint32_t
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   298
IidManager::GetAttributeFlags (uint16_t uid, uint32_t i) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   299
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   300
  struct IidInformation *information = LookupInformation (uid);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   301
  NS_ASSERT (i < information->attributes.size ());
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   302
  return information->attributes[i].flags;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   303
}
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
   304
ns3::Attribute 
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   305
IidManager::GetAttributeInitialValue (uint16_t uid, uint32_t i) const
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   306
{
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   307
  struct IidInformation *information = LookupInformation (uid);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   308
  NS_ASSERT (i < information->attributes.size ());
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   309
  return information->attributes[i].initialValue;
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   310
}
2436
23415bac7eaf Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2435
diff changeset
   311
ns3::Ptr<const ns3::AttributeAccessor>
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   312
IidManager::GetAttributeAccessor (uint16_t uid, uint32_t i) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   313
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   314
  struct IidInformation *information = LookupInformation (uid);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   315
  NS_ASSERT (i < information->attributes.size ());
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   316
  return information->attributes[i].param;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   317
}
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   318
ns3::Ptr<const ns3::AttributeChecker>
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   319
IidManager::GetAttributeChecker (uint16_t uid, uint32_t i) const
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   320
{
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   321
  struct IidInformation *information = LookupInformation (uid);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   322
  NS_ASSERT (i < information->attributes.size ());
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   323
  return information->attributes[i].checker;
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   324
}
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   325
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   326
void 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   327
IidManager::AddTraceSource (uint16_t uid,
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   328
                            std::string name, 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   329
                            std::string help,
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   330
                            ns3::Ptr<const ns3::TraceSourceAccessor> accessor)
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   331
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   332
  struct IidInformation *information  = LookupInformation (uid);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   333
  struct TraceSourceInformation source;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   334
  source.name = name;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   335
  source.help = help;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   336
  source.accessor = accessor;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   337
  information->traceSources.push_back (source);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   338
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   339
uint32_t 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   340
IidManager::GetTraceSourceN (uint16_t uid) const
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   341
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   342
  struct IidInformation *information = LookupInformation (uid);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   343
  return information->traceSources.size ();
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   344
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   345
std::string 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   346
IidManager::GetTraceSourceName (uint16_t uid, uint32_t i) const
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   347
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   348
  struct IidInformation *information = LookupInformation (uid);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   349
  NS_ASSERT (i < information->traceSources.size ());
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   350
  return information->traceSources[i].name;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   351
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   352
std::string 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   353
IidManager::GetTraceSourceHelp (uint16_t uid, uint32_t i) const
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   354
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   355
  struct IidInformation *information = LookupInformation (uid);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   356
  NS_ASSERT (i < information->traceSources.size ());
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   357
  return information->traceSources[i].help;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   358
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   359
ns3::Ptr<const ns3::TraceSourceAccessor> 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   360
IidManager::GetTraceSourceAccessor (uint16_t uid, uint32_t i) const
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   361
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   362
  struct IidInformation *information = LookupInformation (uid);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   363
  NS_ASSERT (i < information->traceSources.size ());
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   364
  return information->traceSources[i].accessor;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   365
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   366
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   367
} // anonymous namespace
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   368
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   369
namespace ns3 {
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   370
2233
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   371
/*********************************************************************
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   372
 *         The TypeId class
2233
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   373
 *********************************************************************/
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   374
2394
bc7abfdb0748 add a default constructor for the TypeId class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2382
diff changeset
   375
TypeId::TypeId ()
bc7abfdb0748 add a default constructor for the TypeId class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2382
diff changeset
   376
  : m_tid (0)
bc7abfdb0748 add a default constructor for the TypeId class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2382
diff changeset
   377
{}
bc7abfdb0748 add a default constructor for the TypeId class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2382
diff changeset
   378
2583
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   379
TypeId::TypeId (const char *name)
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   380
{
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   381
  uint16_t uid = Singleton<IidManager>::Get ()->AllocateUid (name);
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   382
  NS_ASSERT (uid != 0);
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   383
  m_tid = uid;
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   384
}
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   385
1346
47de68729c86 an untested interface id trace resolver
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1340
diff changeset
   386
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   387
TypeId::TypeId (uint16_t tid)
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   388
  : m_tid (tid)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   389
{}
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   390
TypeId::~TypeId ()
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
   391
{}
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   392
TypeId 
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   393
TypeId::LookupByName (std::string name)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   394
{
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   395
  uint16_t uid = Singleton<IidManager>::Get ()->GetUid (name);
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
   396
  NS_ASSERT (uid != 0);
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   397
  return TypeId (uid);
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   398
}
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   399
bool
2570
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   400
TypeId::LookupByNameFailSafe (std::string name, TypeId *tid)
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   401
{
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   402
  uint16_t uid = Singleton<IidManager>::Get ()->GetUid (name);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   403
  if (uid == 0)
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   404
    {
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   405
      return false;
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   406
    }
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   407
  *tid = TypeId (uid);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   408
  return true;
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   409
}
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   410
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   411
bool
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   412
TypeId::LookupAttributeByFullName (std::string fullName, struct TypeId::AttributeInfo *info)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   413
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   414
  std::string::size_type pos = fullName.find ("::");
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   415
  if (pos == std::string::npos)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   416
    {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   417
      return 0;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   418
    }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   419
  std::string tidName = fullName.substr (0, pos);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   420
  std::string paramName = fullName.substr (pos+2, fullName.size () - (pos+2));
2570
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   421
  TypeId tid;
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   422
  bool ok = LookupByNameFailSafe (tidName, &tid);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   423
  if (!ok)
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   424
    {
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   425
      return false;
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   426
    }
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   427
  return tid.LookupAttributeByName (paramName, info);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   428
}
2239
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   429
uint32_t 
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   430
TypeId::GetRegisteredN (void)
2239
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   431
{
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   432
  return Singleton<IidManager>::Get ()->GetRegisteredN ();
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   433
}
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   434
TypeId 
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   435
TypeId::GetRegistered (uint32_t i)
2239
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   436
{
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   437
  return TypeId (Singleton<IidManager>::Get ()->GetRegistered (i));
2239
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   438
}
b500773d7eae add support to browse the list of existing InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   439
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   440
bool
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   441
TypeId::LookupAttributeByName (std::string name, struct TypeId::AttributeInfo *info) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   442
{
2489
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   443
  TypeId tid;
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   444
  TypeId nextTid = *this;
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   445
  do {
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   446
    tid = nextTid;
2465
2c3c870a5f3c invoke getters on tid temp variable to allow proper iteration over tid list.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2463
diff changeset
   447
    for (uint32_t i = 0; i < tid.GetAttributeListN (); i++)
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   448
      {
2465
2c3c870a5f3c invoke getters on tid temp variable to allow proper iteration over tid list.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2463
diff changeset
   449
        std::string paramName = tid.GetAttributeName (i);
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   450
        if (paramName == name)
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   451
          {
2465
2c3c870a5f3c invoke getters on tid temp variable to allow proper iteration over tid list.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2463
diff changeset
   452
            info->accessor = tid.GetAttributeAccessor (i);
2c3c870a5f3c invoke getters on tid temp variable to allow proper iteration over tid list.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2463
diff changeset
   453
            info->flags = tid.GetAttributeFlags (i);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   454
            info->initialValue = tid.GetAttributeInitialValue (i);
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   455
            info->checker = tid.GetAttributeChecker (i);
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   456
            return true;
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   457
          }
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   458
      }
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   459
    nextTid = tid.GetParent ();
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   460
  } while (nextTid != tid);
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   461
  return false;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   462
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   463
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   464
TypeId 
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   465
TypeId::SetParent (TypeId tid)
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   466
{
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   467
  Singleton<IidManager>::Get ()->SetParent (m_tid, tid.m_tid);
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   468
  return *this;
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   469
}
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   470
TypeId 
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   471
TypeId::SetGroupName (std::string groupName)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   472
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   473
  Singleton<IidManager>::Get ()->SetGroupName (m_tid, groupName);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   474
  return *this;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   475
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   476
TypeId 
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   477
TypeId::SetTypeName (std::string typeName)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   478
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   479
  Singleton<IidManager>::Get ()->SetTypeName (m_tid, typeName);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   480
  return *this;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   481
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   482
TypeId 
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   483
TypeId::GetParent (void) const
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   484
{
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   485
  uint16_t parent = Singleton<IidManager>::Get ()->GetParent (m_tid);
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   486
  return TypeId (parent);
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   487
}
1371
bebf690257c9 replace TraceResolver::PrintAvailable with TraceResolver::CollectSources
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1368
diff changeset
   488
std::string 
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   489
TypeId::GetGroupName (void) const
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   490
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   491
  std::string groupName = Singleton<IidManager>::Get ()->GetGroupName (m_tid);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   492
  return groupName;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   493
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   494
std::string 
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   495
TypeId::GetTypeName (void) const
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   496
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   497
  std::string typeName = Singleton<IidManager>::Get ()->GetTypeName (m_tid);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   498
  return typeName;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   499
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   500
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   501
std::string 
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   502
TypeId::GetName (void) const
1371
bebf690257c9 replace TraceResolver::PrintAvailable with TraceResolver::CollectSources
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1368
diff changeset
   503
{
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   504
  std::string name = Singleton<IidManager>::Get ()->GetName (m_tid);
1371
bebf690257c9 replace TraceResolver::PrintAvailable with TraceResolver::CollectSources
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1368
diff changeset
   505
  return name;
bebf690257c9 replace TraceResolver::PrintAvailable with TraceResolver::CollectSources
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1368
diff changeset
   506
}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   507
2241
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   508
bool 
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   509
TypeId::HasConstructor (void) const
2241
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   510
{
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   511
  bool hasConstructor = Singleton<IidManager>::Get ()->HasConstructor (m_tid);
2241
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   512
  return hasConstructor;
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   513
}
daef67e18b79 add InterfaceId::HasConstructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2240
diff changeset
   514
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   515
void
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   516
TypeId::DoAddConstructor (CallbackBase cb)
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   517
{
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   518
  Singleton<IidManager>::Get ()->AddConstructor (m_tid, cb);
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   519
}
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   520
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   521
TypeId 
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   522
TypeId::AddAttribute (std::string name,
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   523
                      std::string help, 
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
   524
                      Attribute initialValue,
2436
23415bac7eaf Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2435
diff changeset
   525
                      Ptr<const AttributeAccessor> param,
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   526
                      Ptr<const AttributeChecker> checker)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   527
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   528
  Singleton<IidManager>::Get ()->AddAttribute (m_tid, name, help, ATTR_SGC, initialValue, param, checker);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   529
  return *this;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   530
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   531
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   532
TypeId 
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   533
TypeId::AddAttribute (std::string name,
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   534
                      std::string help, 
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   535
                      uint32_t flags,
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
   536
                      Attribute initialValue,
2436
23415bac7eaf Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2435
diff changeset
   537
                      Ptr<const AttributeAccessor> param,
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   538
                      Ptr<const AttributeChecker> checker)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   539
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   540
  Singleton<IidManager>::Get ()->AddAttribute (m_tid, name, help, flags, initialValue, param, checker);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   541
  return *this;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   542
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   543
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   544
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   545
CallbackBase
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   546
TypeId::LookupConstructor (void) const
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   547
{
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   548
  CallbackBase constructor = Singleton<IidManager>::Get ()->GetConstructor (m_tid);
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   549
  return constructor;
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   550
}
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   551
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   552
Ptr<Object> 
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   553
TypeId::CreateObject (void) const
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   554
{
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   555
  return CreateObject (AttributeList ());
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   556
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   557
Ptr<Object> 
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   558
TypeId::CreateObject (const AttributeList &attributes) const
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   559
{
2589
38274d42d73b kill multiple constructors per TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2583
diff changeset
   560
  CallbackBase cb = LookupConstructor ();
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   561
  Callback<Ptr<Object>,const AttributeList &> realCb;
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   562
  realCb.Assign (cb);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   563
  Ptr<Object> object = realCb (attributes);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   564
  return object;  
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   565
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   566
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   567
uint32_t 
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   568
TypeId::GetAttributeListN (void) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   569
{
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   570
  uint32_t n = Singleton<IidManager>::Get ()->GetAttributeListN (m_tid);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   571
  return n;
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   572
}
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   573
std::string 
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   574
TypeId::GetAttributeName (uint32_t i) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   575
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   576
  std::string name = Singleton<IidManager>::Get ()->GetAttributeName (m_tid, i);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   577
  return name;
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   578
}
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   579
std::string 
2573
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   580
TypeId::GetAttributeHelp (uint32_t i) const
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   581
{
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   582
  std::string help = Singleton<IidManager>::Get ()->GetAttributeHelp (m_tid, i);
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   583
  return help;
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   584
}
b45af20ffe2b make GetAttributeFlags and GetAttributeChecker public. add GetAttributeHelp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2572
diff changeset
   585
std::string 
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   586
TypeId::GetAttributeFullName (uint32_t i) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   587
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   588
  return GetName () + "::" + GetAttributeName (i);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   589
}
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
   590
Attribute 
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   591
TypeId::GetAttributeInitialValue (uint32_t i) const
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   592
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   593
  Attribute value = Singleton<IidManager>::Get ()->GetAttributeInitialValue (m_tid, i);
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   594
  return value;
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   595
}
2436
23415bac7eaf Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2435
diff changeset
   596
Ptr<const AttributeAccessor>
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   597
TypeId::GetAttributeAccessor (uint32_t i) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   598
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   599
  // Used exclusively by the Object class.
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   600
  Ptr<const AttributeAccessor> param = Singleton<IidManager>::Get ()->GetAttributeAccessor (m_tid, i);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   601
  return param;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   602
}
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   603
uint32_t 
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   604
TypeId::GetAttributeFlags (uint32_t i) const
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   605
{
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   606
  // Used exclusively by the Object class.
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   607
  uint32_t flags = Singleton<IidManager>::Get ()->GetAttributeFlags (m_tid, i);
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   608
  return flags;
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   609
}
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   610
Ptr<const AttributeChecker>
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   611
TypeId::GetAttributeChecker (uint32_t i) const
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   612
{
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   613
  // Used exclusively by the Object class.
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   614
  Ptr<const AttributeChecker> checker = Singleton<IidManager>::Get ()->GetAttributeChecker (m_tid, i);
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   615
  return checker;
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   616
}
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   617
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   618
uint32_t 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   619
TypeId::GetTraceSourceN (void) const
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   620
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   621
  return Singleton<IidManager>::Get ()->GetTraceSourceN (m_tid);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   622
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   623
std::string 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   624
TypeId::GetTraceSourceName (uint32_t i) const
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   625
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   626
  return Singleton<IidManager>::Get ()->GetTraceSourceName (m_tid, i);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   627
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   628
std::string 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   629
TypeId::GetTraceSourceHelp (uint32_t i) const
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   630
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   631
  return Singleton<IidManager>::Get ()->GetTraceSourceHelp (m_tid, i);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   632
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   633
Ptr<const TraceSourceAccessor> 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   634
TypeId::GetTraceSourceAccessor (uint32_t i) const
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   635
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   636
  return Singleton<IidManager>::Get ()->GetTraceSourceAccessor (m_tid, i);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   637
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   638
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   639
TypeId 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   640
TypeId::AddTraceSource (std::string name,
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   641
                        std::string help,
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   642
                        Ptr<const TraceSourceAccessor> accessor)
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   643
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   644
  Singleton<IidManager>::Get ()->AddTraceSource (m_tid, name, help, accessor);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   645
  return *this;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   646
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   647
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   648
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   649
Ptr<const TraceSourceAccessor> 
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   650
TypeId::LookupTraceSourceByName (std::string name) const
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   651
{
2489
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   652
  TypeId tid;
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   653
  TypeId nextTid = *this;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   654
  do {
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   655
    tid = nextTid;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   656
    for (uint32_t i = 0; i < tid.GetTraceSourceN (); i++)
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   657
      {
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   658
        std::string srcName = tid.GetTraceSourceName (i);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   659
        if (srcName == name)
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   660
          {
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   661
            return tid.GetTraceSourceAccessor (i);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   662
          }
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   663
      }
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   664
    nextTid = tid.GetParent ();
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   665
  } while (nextTid != tid);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   666
  return 0;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
   667
}
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
   668
2489
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   669
std::ostream & operator << (std::ostream &os, TypeId tid)
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   670
{
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   671
  os << tid.GetName ();
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   672
  return os;
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   673
}
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   674
std::istream & operator >> (std::istream &is, TypeId &tid)
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   675
{
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   676
  std::string tidString;
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   677
  is >> tidString;
2570
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   678
  bool ok = TypeId::LookupByNameFailSafe (tidString, &tid);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   679
  if (!ok)
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   680
    {
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   681
      is.setstate (std::ios_base::badbit);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   682
    }
2489
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   683
  return is;
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   684
}
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   685
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   686
2582
3e28107b870f rename old VALUE leftovers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2573
diff changeset
   687
ATTRIBUTE_HELPER_CPP (TypeId);
2489
c3341ba4cbf8 do not use the private constructor to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2471
diff changeset
   688
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   689
bool operator == (TypeId a, TypeId b)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   690
{
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   691
  return a.m_tid == b.m_tid;
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   692
}
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   693
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   694
bool operator != (TypeId a, TypeId b)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   695
{
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   696
  return a.m_tid != b.m_tid;
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   697
}
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   698
2233
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   699
/*********************************************************************
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   700
 *         The AttributeList container implementation
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   701
 *********************************************************************/
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   702
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   703
AttributeList::AttributeList ()
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   704
{}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   705
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   706
AttributeList::AttributeList (const AttributeList &o)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   707
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   708
  for (Attrs::const_iterator i = o.m_attributes.begin (); i != o.m_attributes.end (); i++)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   709
    {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   710
      struct Attr attr;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   711
      attr.checker = i->checker;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   712
      attr.value = i->value.Copy ();
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   713
      m_attributes.push_back (attr);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   714
    }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   715
}
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   716
AttributeList &
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   717
AttributeList::operator = (const AttributeList &o)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   718
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   719
  Reset ();
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   720
  for (Attrs::const_iterator i = o.m_attributes.begin (); i != o.m_attributes.end (); i++)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   721
    {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   722
      struct Attr attr;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   723
      attr.checker = i->checker;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   724
      attr.value = i->value.Copy ();
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   725
      m_attributes.push_back (attr);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   726
    }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   727
  return *this;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   728
}
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   729
AttributeList::~AttributeList ()
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   730
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   731
  Reset ();
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   732
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   733
2570
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   734
void
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   735
AttributeList::Set (std::string name, Attribute value)
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   736
{
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   737
  struct TypeId::AttributeInfo info;
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   738
  bool ok = TypeId::LookupAttributeByFullName (name, &info);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   739
  if (!ok)
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   740
    {
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   741
      NS_FATAL_ERROR ("Could not find attribute "<<name);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   742
    }
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   743
  ok = DoSet (&info, value);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   744
  if (!ok)
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   745
    {
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   746
      NS_FATAL_ERROR ("Could not set value for attribute "<<name);
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   747
    }
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   748
}
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   749
bool 
2570
15d5421022a1 add FailSafe versions of setters which could fail.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2569
diff changeset
   750
AttributeList::SetFailSafe (std::string name, Attribute value)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   751
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   752
  struct TypeId::AttributeInfo info;
2590
4b09d2511d4f check all errors.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2589
diff changeset
   753
  bool ok = TypeId::LookupAttributeByFullName (name, &info);
4b09d2511d4f check all errors.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2589
diff changeset
   754
  if (!ok)
4b09d2511d4f check all errors.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2589
diff changeset
   755
    {
4b09d2511d4f check all errors.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2589
diff changeset
   756
      return false;
4b09d2511d4f check all errors.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2589
diff changeset
   757
    }
4b09d2511d4f check all errors.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2589
diff changeset
   758
  ok = DoSet (&info, value);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   759
  return ok;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   760
}
2583
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   761
void
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   762
AttributeList::SetWithTid (TypeId tid, std::string name, Attribute value)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   763
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   764
  struct TypeId::AttributeInfo info;
2583
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   765
  bool ok = tid.LookupAttributeByName (name, &info);
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   766
  if (!ok)
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   767
    {
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   768
      NS_FATAL_ERROR ("Could not find attribute "<<tid.GetName ()<<"::"<<name);
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   769
    }
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   770
  ok = DoSet (&info, value);
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   771
  if (!ok)
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   772
    {
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   773
      NS_FATAL_ERROR ("Could not set value for attribute "<<tid.GetName ()<<"::"<<name);
c09faa6c90bf doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   774
    }
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   775
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   776
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   777
void
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   778
AttributeList::DoSetOne (Ptr<const AttributeChecker> checker, Attribute value)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   779
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   780
  // get rid of any previous value stored in this
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   781
  // vector of values.
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   782
  for (Attrs::iterator k = m_attributes.begin (); k != m_attributes.end (); k++)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   783
    {
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   784
      if (k->checker == checker)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   785
        {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   786
          m_attributes.erase (k);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   787
          break;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   788
        }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   789
    }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   790
  // store the new value.
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   791
  struct Attr attr;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   792
  attr.checker = checker;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   793
  attr.value = value.Copy ();
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   794
  m_attributes.push_back (attr);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   795
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   796
bool
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   797
AttributeList::DoSet (struct TypeId::AttributeInfo *info, Attribute value)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   798
{
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   799
  if (info->checker == 0)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   800
    {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   801
      return false;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   802
    }
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   803
  bool ok = info->checker->Check (value);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   804
  if (!ok)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   805
    {
2421
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
   806
      // attempt to convert to string.
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   807
      const StringValue *str = value.DynCast<const StringValue *> ();
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   808
      if (str == 0)
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   809
        {
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   810
          return false;
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
   811
        }
2421
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
   812
      // attempt to convert back to value.
2520
a4896ebf6e1d introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2502
diff changeset
   813
      Attribute v = info->checker->Create ();
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2489
diff changeset
   814
      ok = v.DeserializeFromString (str->Get ().Get (), info->checker);
2397
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
   815
      if (!ok)
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
   816
        {
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
   817
          return false;
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
   818
        }
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   819
      ok = info->checker->Check (v);
2421
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
   820
      if (!ok)
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
   821
        {
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
   822
          return false;
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
   823
        }
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
   824
      value = v;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   825
    }
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   826
  DoSetOne (info->checker, value);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   827
  return true;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   828
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   829
void 
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   830
AttributeList::Reset (void)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   831
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   832
  m_attributes.clear ();
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   833
}
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   834
AttributeList *
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   835
AttributeList::GetGlobal (void)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   836
{
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   837
  return Singleton<AttributeList>::Get ();
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   838
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   839
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   840
std::string
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   841
AttributeList::LookupAttributeFullNameByChecker (Ptr<const AttributeChecker> checker) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   842
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   843
  for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   844
    {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   845
      TypeId tid = TypeId::GetRegistered (i);
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   846
      for (uint32_t j = 0; j < tid.GetAttributeListN (); j++)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   847
        {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   848
          if (checker == tid.GetAttributeChecker (j))
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   849
            {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   850
              return tid.GetAttributeFullName (j);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   851
            }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   852
        }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   853
    }
2435
3128175f5866 ParamSpec -> Accessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
   854
  NS_FATAL_ERROR ("Could not find requested Accessor.");
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   855
  // quiet compiler.
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   856
  return "";
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   857
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   858
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   859
std::string 
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   860
AttributeList::SerializeToString (void) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   861
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   862
  std::ostringstream oss;
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   863
  for (Attrs::const_iterator i = m_attributes.begin (); i != m_attributes.end (); i++)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   864
    {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   865
      std::string name = LookupAttributeFullNameByChecker (i->checker);
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   866
      oss << name << "=" << i->value.SerializeToString (i->checker);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   867
      if (i != m_attributes.end ())
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   868
        {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   869
          oss << "|";
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   870
        }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   871
    }  
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   872
  return oss.str ();
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   873
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   874
bool 
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   875
AttributeList::DeserializeFromString (std::string str)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   876
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   877
  Reset ();
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   878
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   879
  std::string::size_type cur;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   880
  cur = 0;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   881
  do {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   882
    std::string::size_type equal = str.find ("=", cur);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   883
    if (equal == std::string::npos)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   884
      {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   885
        // XXX: invalid attribute.
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   886
        break;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   887
      }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   888
    else
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   889
      {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   890
        std::string name = str.substr (cur, equal-cur);
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   891
        struct TypeId::AttributeInfo info;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   892
        if (!TypeId::LookupAttributeByFullName (name, &info))
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   893
          {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   894
            // XXX invalid name.
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   895
            break;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   896
          }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   897
        else
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   898
          {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   899
            std::string::size_type next = str.find ("|", cur);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   900
            std::string value;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   901
            if (next == std::string::npos)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   902
              {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   903
                value = str.substr (equal+1, str.size () - (equal+1));
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   904
                cur = str.size ();
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   905
              }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   906
            else
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   907
              {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   908
                value = str.substr (equal+1, next - (equal+1));
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   909
                cur++;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   910
              }
2520
a4896ebf6e1d introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2502
diff changeset
   911
            Attribute val = info.checker->Create ();
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   912
            bool ok = val.DeserializeFromString (value, info.checker);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   913
            if (!ok)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   914
              {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   915
                // XXX invalid value
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   916
                break;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   917
              }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   918
            else
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   919
              {
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   920
                DoSetOne (info.checker, val);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   921
              }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   922
          }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   923
      }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   924
  } while (cur != str.size ());
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   925
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   926
  return true;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   927
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   928
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   929
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   930
/*********************************************************************
2233
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   931
 *         The Object implementation
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   932
 *********************************************************************/
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   933
2247
56b3591fa3b0 use NS_OBJECT_ENSURE_REGISTERED and fix off-by-one in IidManager::GetRegistered
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2243
diff changeset
   934
NS_OBJECT_ENSURE_REGISTERED (Object);
56b3591fa3b0 use NS_OBJECT_ENSURE_REGISTERED and fix off-by-one in IidManager::GetRegistered
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2243
diff changeset
   935
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   936
static TypeId
2238
05affd9d0dc1 get rid of MakeInterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2237
diff changeset
   937
GetObjectIid (void)
05affd9d0dc1 get rid of MakeInterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2237
diff changeset
   938
{
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   939
  TypeId tid = TypeId ("Object");
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   940
  tid.SetParent (tid);
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   941
  return tid;
2238
05affd9d0dc1 get rid of MakeInterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2237
diff changeset
   942
}
2233
b359c83c5fbe add some separation markers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   943
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
   944
TypeId 
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
   945
Object::GetTypeId (void)
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
   946
{
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   947
  static TypeId tid = GetObjectIid ();
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   948
  return tid;
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
   949
}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   950
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   951
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
   952
Object::Object ()
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   953
  : m_count (1),
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   954
    m_tid (Object::GetTypeId ()),
713
c3c745a80610 add a m_disposed field and check it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 712
diff changeset
   955
    m_disposed (false),
1374
77468496f7e0 avoid problems with recursive use of Object::DoCollectSources
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1372
diff changeset
   956
    m_collecting (false),
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
   957
    m_next (this)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   958
{}
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
   959
Object::~Object () 
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
   960
{
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
   961
  m_next = 0;
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
   962
}
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   963
void
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   964
Object::Construct (const AttributeList &attributes)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   965
{
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   966
  // loop over the inheritance tree back to the Object base class.
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   967
  TypeId tid = m_tid;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   968
  do {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   969
    // loop over all attributes in object type
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   970
    NS_LOG_DEBUG ("construct tid="<<tid.GetName ()<<", params="<<tid.GetAttributeListN ());
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   971
    for (uint32_t i = 0; i < tid.GetAttributeListN (); i++)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   972
      {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   973
        Ptr<const AttributeAccessor> paramSpec = tid.GetAttributeAccessor (i);
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   974
        Attribute initial = tid.GetAttributeInitialValue (i);
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   975
        Ptr<const AttributeChecker> checker = tid.GetAttributeChecker (i);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   976
        NS_LOG_DEBUG ("try to construct \""<< tid.GetName ()<<"::"<<
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   977
                      tid.GetAttributeName (i)<<"\"");
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   978
        if (!(tid.GetAttributeFlags (i) & TypeId::ATTR_CONSTRUCT))
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   979
          {
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   980
            continue;
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
   981
          }
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   982
        bool found = false;
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   983
        // is this attribute stored in this AttributeList instance ?
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
   984
        for (AttributeList::Attrs::const_iterator j = attributes.m_attributes.begin ();
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   985
             j != attributes.m_attributes.end (); j++)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   986
          {
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   987
            if (j->checker == checker)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   988
              {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   989
                // We have a matching attribute value.
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
   990
                DoSet (paramSpec, initial, checker, j->value);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   991
                NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<<
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   992
                              tid.GetAttributeName (i)<<"\"");
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   993
                found = true;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   994
                break;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   995
              }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   996
          }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   997
        if (!found)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   998
          {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
   999
            // is this attribute stored in the global instance instance ?
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
  1000
            for (AttributeList::Attrs::const_iterator j = AttributeList::GetGlobal ()->m_attributes.begin ();
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
  1001
                 j != AttributeList::GetGlobal ()->m_attributes.end (); j++)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1002
              {
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
  1003
                if (j->checker == checker)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1004
                  {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1005
                    // We have a matching attribute value.
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
  1006
                    DoSet (paramSpec, initial, checker, j->value);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1007
                    NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<<
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1008
                                  tid.GetAttributeName (i)<<"\" from global");
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1009
                    found = true;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1010
                    break;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1011
                  }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1012
              }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1013
          }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1014
        if (!found)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1015
          {
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1016
            // No matching attribute value so we set the default value.
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1017
            paramSpec->Set (this, initial);
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1018
            NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<<
2523
58182a1561cc improve debugging output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2522
diff changeset
  1019
                          tid.GetAttributeName (i)<<"\" from initial value.");
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1020
          }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1021
      }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1022
    tid = tid.GetParent ();
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1023
  } while (tid != Object::GetTypeId ());
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1024
  NotifyConstructionCompleted ();
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1025
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1026
bool
2436
23415bac7eaf Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2435
diff changeset
  1027
Object::DoSet (Ptr<const AttributeAccessor> spec, Attribute initialValue, 
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
  1028
               Ptr<const AttributeChecker> checker, Attribute value)
2397
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1029
{
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
  1030
  bool ok = checker->Check (value);
2397
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1031
  if (!ok)
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1032
    {
2421
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
  1033
      // attempt to convert to string
2424
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
  1034
      const StringValue *str = value.DynCast<const StringValue *> ();
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
  1035
      if (str == 0)
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
  1036
        {
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
  1037
          return false;
217a447122a6 split initial value from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2423
diff changeset
  1038
        }
2421
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
  1039
      // attempt to convert back from string.
2520
a4896ebf6e1d introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2502
diff changeset
  1040
      Attribute v = checker->Create ();
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2489
diff changeset
  1041
      ok = v.DeserializeFromString (str->Get ().Get (), checker);
2421
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
  1042
      if (!ok)
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
  1043
        {
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
  1044
          return false;
00ef5829bbe8 get rid of Value::ConvertFrom method.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2420
diff changeset
  1045
        }
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
  1046
      ok = checker->Check (v);
2397
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1047
      if (!ok)
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1048
        {
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1049
          return false;
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1050
        }
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1051
      value = v;
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1052
    }
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1053
  ok = spec->Set (this, value);
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1054
  return ok;
45cd59c6ddf8 add automatic conversion from string to PValue.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2394
diff changeset
  1055
}
2572
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1056
void
2460
7f5679184b79 Object::Set/Get -> Object::SetAttribute/GetAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
  1057
Object::SetAttribute (std::string name, Attribute value)
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1058
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1059
  struct TypeId::AttributeInfo info;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1060
  if (!m_tid.LookupAttributeByName (name, &info))
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1061
    {
2572
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1062
      NS_FATAL_ERROR ("Attribute name="<<name<<" does not exist for this object: tid="<<m_tid.GetName ());
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1063
    }
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1064
  if (!(info.flags & TypeId::ATTR_SET))
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1065
    {
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1066
      NS_FATAL_ERROR ("Attribute name="<<name<<" is not settable for this object: tid="<<m_tid.GetName ());
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1067
    }
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1068
  if (!DoSet (info.accessor, info.initialValue, info.checker, value))
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1069
    {
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1070
      NS_FATAL_ERROR ("Attribute name="<<name<<" could not be set for this object: tid="<<m_tid.GetName ());
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1071
    }
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1072
}
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1073
bool 
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1074
Object::SetAttributeFailSafe (std::string name, Attribute value)
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1075
{
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1076
  struct TypeId::AttributeInfo info;
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1077
  if (!m_tid.LookupAttributeByName (name, &info))
5f3bdaf2a77c more FailSafe methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2570
diff changeset
  1078
    {
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1079
      return false;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1080
    }
2432
b946f13bc8cb PARAM -> ATTR
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
  1081
  if (!(info.flags & TypeId::ATTR_SET))
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
  1082
    {
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
  1083
      return false;
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
  1084
    }
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1085
  return DoSet (info.accessor, info.initialValue, info.checker, value);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1086
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1087
bool 
2460
7f5679184b79 Object::Set/Get -> Object::SetAttribute/GetAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
  1088
Object::GetAttribute (std::string name, std::string &value) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1089
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1090
  struct TypeId::AttributeInfo info;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1091
  if (!m_tid.LookupAttributeByName (name, &info))
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1092
    {
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1093
      return false;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1094
    }
2432
b946f13bc8cb PARAM -> ATTR
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
  1095
  if (!(info.flags & TypeId::ATTR_GET))
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
  1096
    {
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
  1097
      return false;
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
  1098
    }
2520
a4896ebf6e1d introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2502
diff changeset
  1099
  Attribute v = info.checker->Create ();
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1100
  bool ok = info.accessor->Get (this, v);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1101
  if (ok)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1102
    {
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2426
diff changeset
  1103
      value = v.SerializeToString (info.checker);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1104
    }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1105
  return ok;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1106
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1107
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
  1108
Attribute
2460
7f5679184b79 Object::Set/Get -> Object::SetAttribute/GetAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
  1109
Object::GetAttribute (std::string name) const
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1110
{
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1111
  struct TypeId::AttributeInfo info;
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1112
  if (!m_tid.LookupAttributeByName (name, &info))
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1113
    {
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
  1114
      return Attribute ();
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1115
    }
2432
b946f13bc8cb PARAM -> ATTR
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
  1116
  if (!(info.flags & TypeId::ATTR_GET))
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
  1117
    {
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
  1118
      return Attribute ();
2382
b05c2d0bcd23 enforce TypeId::PARAM_* flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2380
diff changeset
  1119
    }
2520
a4896ebf6e1d introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2502
diff changeset
  1120
  Attribute value = info.checker->Create ();
2458
e8f7c4960576 AddParameter -> AddAttribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
  1121
  bool ok = info.accessor->Get (this, value);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1122
  if (!ok)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1123
    {
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2432
diff changeset
  1124
      return Attribute ();
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1125
    }
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1126
  return value;
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1127
}
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1128
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1129
bool 
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
  1130
Object::TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1131
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1132
  Ptr<const TraceSourceAccessor> accessor = m_tid.LookupTraceSourceByName (name);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1133
  if (accessor == 0)
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1134
    {
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1135
      return false;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1136
    }
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
  1137
  bool ok = accessor->ConnectWithoutContext (this, cb);
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1138
  return ok;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1139
}
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1140
bool 
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
  1141
Object::TraceConnectWithoutContext (std::string name, std::string context, const CallbackBase &cb)
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2529
diff changeset
  1142
{
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2529
diff changeset
  1143
  Ptr<const TraceSourceAccessor> accessor = m_tid.LookupTraceSourceByName (name);
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2529
diff changeset
  1144
  if (accessor == 0)
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2529
diff changeset
  1145
    {
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2529
diff changeset
  1146
      return false;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2529
diff changeset
  1147
    }
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
  1148
  bool ok = accessor->Connect (this, context, cb);
2531
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2529
diff changeset
  1149
  return ok;
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2529
diff changeset
  1150
}
b451b5fc8b57 implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2529
diff changeset
  1151
bool 
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
  1152
Object::TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1153
{
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1154
  Ptr<const TraceSourceAccessor> accessor = m_tid.LookupTraceSourceByName (name);
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1155
  if (accessor == 0)
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1156
    {
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1157
      return false;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1158
    }
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
  1159
  bool ok = accessor->DisconnectWithoutContext (this, cb);
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1160
  return ok;
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1161
}
2569
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
  1162
bool 
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
  1163
Object::TraceDisconnectWithoutContext (std::string name, std::string context, const CallbackBase &cb)
2569
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
  1164
{
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
  1165
  Ptr<const TraceSourceAccessor> accessor = m_tid.LookupTraceSourceByName (name);
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
  1166
  if (accessor == 0)
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
  1167
    {
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
  1168
      return false;
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
  1169
    }
2594
a8f89acd17a1 Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2593
diff changeset
  1170
  bool ok = accessor->Disconnect (this, context, cb);
2569
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
  1171
  return ok;
d5cff2968984 make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
  1172
}
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1173
2471
86f7ea794e83 add a few public methods for the Config code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2465
diff changeset
  1174
TypeId 
86f7ea794e83 add a few public methods for the Config code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2465
diff changeset
  1175
Object::GetRealTypeId (void) const
86f7ea794e83 add a few public methods for the Config code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2465
diff changeset
  1176
{
86f7ea794e83 add a few public methods for the Config code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2465
diff changeset
  1177
  return m_tid;
86f7ea794e83 add a few public methods for the Config code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2465
diff changeset
  1178
}
86f7ea794e83 add a few public methods for the Config code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2465
diff changeset
  1179
2463
c77e43117673 actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2460
diff changeset
  1180
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1181
Ptr<Object>
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1182
Object::DoGetObject (TypeId tid) const
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1183
{
1534
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1184
  NS_ASSERT (CheckLoose ());
709
b5c7825babf3 make QueryInterface const
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 708
diff changeset
  1185
  const Object *currentObject = this;
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1186
  do {
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1187
    NS_ASSERT (currentObject != 0);
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1188
    TypeId cur = currentObject->m_tid;
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1189
    while (cur != tid && cur != Object::GetTypeId ())
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1190
      {
2235
fb93067a3c2e rewrite interface id metadata
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2234
diff changeset
  1191
        cur = cur.GetParent ();
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1192
      }
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1193
    if (cur == tid)
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1194
      {
709
b5c7825babf3 make QueryInterface const
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 708
diff changeset
  1195
        return const_cast<Object *> (currentObject);
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1196
      }
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1197
    currentObject = currentObject->m_next;
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1198
  } while (currentObject != this);
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1199
  return 0;
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1200
}
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1201
void 
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1202
Object::Dispose (void)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1203
{
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1204
  Object *current = this;
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1205
  do {
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1206
    NS_ASSERT (current != 0);
713
c3c745a80610 add a m_disposed field and check it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 712
diff changeset
  1207
    NS_ASSERT (!current->m_disposed);
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1208
    current->DoDispose ();
713
c3c745a80610 add a m_disposed field and check it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 712
diff changeset
  1209
    current->m_disposed = true;
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1210
    current = current->m_next;
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1211
  } while (current != this);
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1212
}
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1213
void
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1214
Object::NotifyConstructionCompleted (void)
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1215
{}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1216
void 
2258
666099a753e0 AddInterface -> AggregateObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
  1217
Object::AggregateObject (Ptr<Object> o)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1218
{
718
b32ae2809deb add dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 713
diff changeset
  1219
  NS_ASSERT (!m_disposed);
b32ae2809deb add dox
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 713
diff changeset
  1220
  NS_ASSERT (!o->m_disposed);
1534
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1221
  NS_ASSERT (CheckLoose ());
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1222
  NS_ASSERT (o->CheckLoose ());
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1223
  Object *other = PeekPointer (o);
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1224
  Object *next = m_next;
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1225
  m_next = other->m_next;
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1226
  other->m_next = next;
1534
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1227
  NS_ASSERT (CheckLoose ());
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1228
  NS_ASSERT (o->CheckLoose ());
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1229
}
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1230
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1231
void 
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1232
Object::SetTypeId (TypeId tid)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1233
{
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1234
  NS_ASSERT (Check ());
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1235
  m_tid = tid;
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1236
}
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1237
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1238
void
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1239
Object::DoDispose (void)
713
c3c745a80610 add a m_disposed field and check it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 712
diff changeset
  1240
{
c3c745a80610 add a m_disposed field and check it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 712
diff changeset
  1241
  NS_ASSERT (!m_disposed);
c3c745a80610 add a m_disposed field and check it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 712
diff changeset
  1242
}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1243
1336
de5a133ece8a add Object::TraceConnect, TraceDisconnect, and GetTraceResolver methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 732
diff changeset
  1244
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1245
bool 
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1246
Object::Check (void) const
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1247
{
701
aa179c876b22 optimization suggested by gustavo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 699
diff changeset
  1248
  return (m_count > 0);
aa179c876b22 optimization suggested by gustavo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 699
diff changeset
  1249
}
aa179c876b22 optimization suggested by gustavo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 699
diff changeset
  1250
1534
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1251
/* In some cases, when an event is scheduled against a subclass of
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1252
 * Object, and if no one owns a reference directly to this object, the
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1253
 * object is alive, has a refcount of zero and the method ran when the
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1254
 * event expires runs against the raw pointer which means that we are
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1255
 * manipulating an object with a refcount of zero.  So, instead we
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1256
 * check the aggregate reference count.
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1257
 */
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1258
bool 
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1259
Object::CheckLoose (void) const
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1260
{
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1261
  uint32_t refcount = 0;
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1262
  const Object *current = this;
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1263
  do
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1264
    {
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1265
      refcount += current->m_count;
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1266
      current = current->m_next;
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1267
    }
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1268
  while (current != this);
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1269
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1270
  return (refcount > 0);
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1271
}
6b7a4e88c422 Make Object::QueryInterface and AddInterface check for the aggregate refcount instead of the object refcount, reason explained in a comment near Object::CheckLoose. Add the same check also to TraceConnect/Disconnect and GetTraceResolver.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
  1272
701
aa179c876b22 optimization suggested by gustavo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 699
diff changeset
  1273
void
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1274
Object::MaybeDelete (void) const
701
aa179c876b22 optimization suggested by gustavo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 699
diff changeset
  1275
{
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1276
  // First, check if any of the attached
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1277
  // Object has a non-zero count.
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1278
  const Object *current = this;
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1279
  do {
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1280
    NS_ASSERT (current != 0);
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1281
    if (current->m_count != 0)
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1282
      {
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1283
        return;
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1284
      }
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1285
    current = current->m_next;
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1286
  } while (current != this);
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1287
2529
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1288
  // Ensure we are disposed.
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1289
  Object *tmp = const_cast<Object *> (this);
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1290
  const Object *end = this;
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1291
  do {
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1292
    NS_ASSERT (current != 0);
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1293
    Object *next = tmp->m_next;
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1294
    if (!tmp->m_disposed)
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1295
      {
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1296
        tmp->DoDispose ();
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1297
      }
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1298
    tmp = next;
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1299
  } while (tmp != end);
d5f8bee5fcbd ensure that Dispose is invoked at one point.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2523
diff changeset
  1300
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1301
  // all attached objects have a zero count so, 
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1302
  // we can delete all attached objects.
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1303
  current = this;
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1304
  do {
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1305
    NS_ASSERT (current != 0);
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1306
    Object *next = current->m_next;
702
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1307
    delete current;
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1308
    current = next;
829df6703988 yet another optimization to cut even more on memory allocations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 701
diff changeset
  1309
  } while (current != end);
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1310
}
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1311
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1312
} // namespace ns3
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1313
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1314
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1315
#ifdef RUN_SELF_TESTS
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1316
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1317
#include "test.h"
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1318
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1319
namespace {
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1320
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1321
class BaseA : public ns3::Object
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1322
{
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1323
public:
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
  1324
  static ns3::TypeId GetTypeId (void) {
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1325
    static ns3::TypeId tid = ns3::TypeId ("BaseA")
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
  1326
      .SetParent (Object::GetTypeId ())
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
  1327
      .AddConstructor<BaseA> ();
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1328
    return tid;
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
  1329
  }
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1330
  BaseA ()
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1781
diff changeset
  1331
  {}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1332
  virtual void Dispose (void) {}
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1333
};
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1334
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1335
class DerivedA : public BaseA
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1336
{
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1337
public:
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
  1338
  static ns3::TypeId GetTypeId (void) {
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1339
    static ns3::TypeId tid = ns3::TypeId ("DerivedA")
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
  1340
      .SetParent (BaseA::GetTypeId ())
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1341
      .AddConstructor<DerivedA> ();
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1342
    return tid;
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
  1343
  }
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1344
  DerivedA ()
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1781
diff changeset
  1345
  {}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1346
  virtual void Dispose (void) {
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1347
    BaseA::Dispose ();
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1348
  }
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1349
};
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1350
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1351
class BaseB : public ns3::Object
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1352
{
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1353
public:
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
  1354
  static ns3::TypeId GetTypeId (void) {
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1355
    static ns3::TypeId tid = ns3::TypeId ("BaseB")
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
  1356
      .SetParent (Object::GetTypeId ())
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
  1357
      .AddConstructor<BaseB> ();
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1358
    return tid;
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
  1359
  }
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1360
  BaseB ()
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1781
diff changeset
  1361
  {}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1362
  virtual void Dispose (void) {}
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1363
};
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1364
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1365
class DerivedB : public BaseB
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1366
{
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1367
public:
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
  1368
  static ns3::TypeId GetTypeId (void) {
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1369
    static ns3::TypeId tid = ns3::TypeId ("DerivedB")
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
  1370
      .SetParent (BaseB::GetTypeId ())
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1371
      .AddConstructor<DerivedB> ();
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
  1372
    return tid;
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
  1373
  }
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1374
  DerivedB ()
2243
9573a034177a check constructor with reference arguments
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2241
diff changeset
  1375
  {}
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1376
  virtual void Dispose (void) {
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1377
    BaseB::Dispose ();
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1378
  }
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1379
};
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1380
2247
56b3591fa3b0 use NS_OBJECT_ENSURE_REGISTERED and fix off-by-one in IidManager::GetRegistered
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2243
diff changeset
  1381
NS_OBJECT_ENSURE_REGISTERED (BaseA);
56b3591fa3b0 use NS_OBJECT_ENSURE_REGISTERED and fix off-by-one in IidManager::GetRegistered
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2243
diff changeset
  1382
NS_OBJECT_ENSURE_REGISTERED (DerivedA);
56b3591fa3b0 use NS_OBJECT_ENSURE_REGISTERED and fix off-by-one in IidManager::GetRegistered
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2243
diff changeset
  1383
NS_OBJECT_ENSURE_REGISTERED (BaseB);
56b3591fa3b0 use NS_OBJECT_ENSURE_REGISTERED and fix off-by-one in IidManager::GetRegistered
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2243
diff changeset
  1384
NS_OBJECT_ENSURE_REGISTERED (DerivedB);
56b3591fa3b0 use NS_OBJECT_ENSURE_REGISTERED and fix off-by-one in IidManager::GetRegistered
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2243
diff changeset
  1385
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1386
} // namespace anonymous
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1387
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1388
namespace ns3 {
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1389
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1390
class ObjectTest : public Test
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1391
{
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1392
public:
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1393
  ObjectTest ();
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1394
  virtual bool RunTests (void);
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1395
};
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1396
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1397
ObjectTest::ObjectTest ()
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1398
  : Test ("Object")
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1399
{}
1351
0a6aaa6acbd3 test object-based tracing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1349
diff changeset
  1400
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1401
bool 
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1402
ObjectTest::RunTests (void)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1403
{
1349
11562f6b73aa rewrite Object tests with test.h macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1346
diff changeset
  1404
  bool result = true;
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1405
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1781
diff changeset
  1406
  Ptr<BaseA> baseA = CreateObject<BaseA> ();
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1407
  NS_TEST_ASSERT_EQUAL (baseA->GetObject<BaseA> (), baseA);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1408
  NS_TEST_ASSERT_EQUAL (baseA->GetObject<BaseA> (DerivedA::GetTypeId ()), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1409
  NS_TEST_ASSERT_EQUAL (baseA->GetObject<DerivedA> (), 0);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1410
  baseA = CreateObject<DerivedA> ();
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1411
  NS_TEST_ASSERT_EQUAL (baseA->GetObject<BaseA> (), baseA);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1412
  NS_TEST_ASSERT_EQUAL (baseA->GetObject<BaseA> (DerivedA::GetTypeId ()), baseA);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1413
  NS_TEST_ASSERT_UNEQUAL (baseA->GetObject<DerivedA> (), 0);
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1414
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1781
diff changeset
  1415
  baseA = CreateObject<BaseA> ();
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1781
diff changeset
  1416
  Ptr<BaseB> baseB = CreateObject<BaseB> ();
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1417
  Ptr<BaseB> baseBCopy = baseB;
2258
666099a753e0 AddInterface -> AggregateObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
  1418
  baseA->AggregateObject (baseB);
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1419
  NS_TEST_ASSERT_UNEQUAL (baseA->GetObject<BaseA> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1420
  NS_TEST_ASSERT_EQUAL (baseA->GetObject<DerivedA> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1421
  NS_TEST_ASSERT_UNEQUAL (baseA->GetObject<BaseB> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1422
  NS_TEST_ASSERT_EQUAL (baseA->GetObject<DerivedB> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1423
  NS_TEST_ASSERT_UNEQUAL (baseB->GetObject<BaseB> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1424
  NS_TEST_ASSERT_EQUAL (baseB->GetObject<DerivedB> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1425
  NS_TEST_ASSERT_UNEQUAL (baseB->GetObject<BaseA> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1426
  NS_TEST_ASSERT_EQUAL (baseB->GetObject<DerivedA> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1427
  NS_TEST_ASSERT_UNEQUAL (baseBCopy->GetObject<BaseA> (), 0);
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1428
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1429
  baseA = CreateObject<DerivedA> ();
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1430
  baseB = CreateObject<DerivedB> ();
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1431
  baseBCopy = baseB;
2258
666099a753e0 AddInterface -> AggregateObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
  1432
  baseA->AggregateObject (baseB);
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1433
  NS_TEST_ASSERT_UNEQUAL (baseA->GetObject<DerivedB> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1434
  NS_TEST_ASSERT_UNEQUAL (baseA->GetObject<BaseB> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1435
  NS_TEST_ASSERT_UNEQUAL (baseB->GetObject<DerivedA> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1436
  NS_TEST_ASSERT_UNEQUAL (baseB->GetObject<BaseA> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1437
  NS_TEST_ASSERT_UNEQUAL (baseBCopy->GetObject<DerivedA> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1438
  NS_TEST_ASSERT_UNEQUAL (baseBCopy->GetObject<BaseA> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1439
  NS_TEST_ASSERT_UNEQUAL (baseB->GetObject<DerivedB> (), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1440
  NS_TEST_ASSERT_UNEQUAL (baseB->GetObject<BaseB> (), 0)
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1441
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1781
diff changeset
  1442
  baseA = CreateObject<BaseA> ();
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1781
diff changeset
  1443
  baseB = CreateObject<BaseB> ();
2258
666099a753e0 AddInterface -> AggregateObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
  1444
  baseA->AggregateObject (baseB);
701
aa179c876b22 optimization suggested by gustavo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 699
diff changeset
  1445
  baseA = 0;
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1446
  baseA = baseB->GetObject<BaseA> ();
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1447
1351
0a6aaa6acbd3 test object-based tracing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1349
diff changeset
  1448
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2247
diff changeset
  1449
  // Test the object creation code of TypeId
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
  1450
  Ptr<Object> a = BaseA::GetTypeId ().CreateObject ();
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1451
  NS_TEST_ASSERT_EQUAL (a->GetObject<BaseA> (), a);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1452
  NS_TEST_ASSERT_EQUAL (a->GetObject<BaseA> (DerivedA::GetTypeId ()), 0);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1453
  NS_TEST_ASSERT_EQUAL (a->GetObject<DerivedA> (), 0);
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1454
  a = DerivedA::GetTypeId ().CreateObject ();
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1455
  NS_TEST_ASSERT_EQUAL (a->GetObject<BaseA> (), a);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1456
  NS_TEST_ASSERT_EQUAL (a->GetObject<BaseA> (DerivedA::GetTypeId ()), a);
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1457
  NS_TEST_ASSERT_UNEQUAL (a->GetObject<DerivedA> (), 0);
2237
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
  1458
7745a8c76396 add 'factory' support to InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2235
diff changeset
  1459
1349
11562f6b73aa rewrite Object tests with test.h macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1346
diff changeset
  1460
  return result;
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1461
}
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1462
706
8b0bf4623c9d rename InterfaceObject to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 703
diff changeset
  1463
static ObjectTest g_interfaceObjectTests;
699
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1464
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1465
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1466
} // namespace ns3
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1467
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1468
#endif /* RUN_SELF_TESTS */
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1469
956a76f5fd56 a replacement for the Interface base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1470