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