src/core/names.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 4298 cc2db3e6bcae
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
craigdo@4139
     1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
craigdo@4139
     2
/*
craigdo@4139
     3
 * Copyright (c) 2009 University of Washington
craigdo@4139
     4
 *
craigdo@4139
     5
 * This program is free software; you can redistribute it and/or modify
craigdo@4139
     6
 * it under the terms of the GNU General Public License version 2 as
craigdo@4139
     7
 * published by the Free Software Foundation;
craigdo@4139
     8
 *
craigdo@4139
     9
 * This program is distributed in the hope that it will be useful,
craigdo@4139
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
craigdo@4139
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
craigdo@4139
    12
 * GNU General Public License for more details.
craigdo@4139
    13
 *
craigdo@4139
    14
 * You should have received a copy of the GNU General Public License
craigdo@4139
    15
 * along with this program; if not, write to the Free Software
craigdo@4139
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
craigdo@4139
    17
 */
craigdo@4139
    18
craigdo@4139
    19
#ifndef OBJECT_NAMES_H
craigdo@4139
    20
#define OBJECT_NAMES_H
craigdo@4139
    21
craigdo@4139
    22
#include "ns3/ptr.h"
craigdo@4139
    23
#include "ns3/object.h"
craigdo@4139
    24
craigdo@4139
    25
namespace ns3 {
craigdo@4139
    26
craigdo@4139
    27
/**
craigdo@4139
    28
 * \brief A directory of name and Ptr<Object> associations that allows us to
craigdo@4139
    29
 * give any ns3 Object a name.
craigdo@4139
    30
 */
craigdo@4139
    31
class Names
craigdo@4139
    32
{
craigdo@4139
    33
public:
craigdo@4139
    34
craigdo@4139
    35
  /**
craigdo@4153
    36
   * \brief Add the association between the string "name" and the Ptr<Object> obj.
craigdo@4153
    37
   *
craigdo@4153
    38
   * The name may begin either with "/Names" to explicitly call out the fact 
craigdo@4153
    39
   * that the name provided is installed under the root of the name space, 
craigdo@4158
    40
   * or it may begin with the name of the first object in the path.  For example, 
craigdo@4158
    41
   * Names::Add ("/Names/client", obj) and Names::Add ("client", obj) accomplish 
craigdo@4158
    42
   * exactly the same thing.  A name at a given level in the name space path must
craigdo@4158
    43
   * be unique.  In the case of the example above, it would be illegal to try and
craigdo@4158
    44
   * associate a different object with the same name: "client" at the same level 
craigdo@4158
    45
   * ("/Names") in the path.
craigdo@4153
    46
   *
craigdo@4158
    47
   * As well as specifying a name at the root of the "/Names" namespace, the 
tomh@4481
    48
   * name parameter can contain a path that fully qualifies the name to 
craigdo@4158
    49
   * be added.  For example, if you previously have named an object "client"
craigdo@4158
    50
   * in the root namespace as above, you could name an object "under" that
craigdo@4158
    51
   * name by making a call like Names::Add ("/Names/client/eth0", obj).  This 
craigdo@4158
    52
   * will define the name "eth0" and make it reachable using the path specified.
craigdo@4158
    53
   * Note that Names::Add ("client/eth0", obj) would accomplish exactly the same 
craigdo@4158
    54
   * thing.
craigdo@4139
    55
   *
craigdo@4160
    56
   * Duplicate names are not allowed at the same level in a path, however you may
craigdo@4160
    57
   * associate similar names with different paths.  For example, if you define
craigdo@4160
    58
   * "/Names/Client", you may not define another "/Names/Client" just as you may
craigdo@4160
    59
   * not have two files with the same name in a classical filesystem.  However,
craigdo@4160
    60
   * you may have "/Names/Client/eth0" and "/Names/Server/eth0" defined at the 
craigdo@4160
    61
   * same time just as you might have different files of the same name under 
craigdo@4160
    62
   * different directories.
craigdo@4160
    63
   *
craigdo@4158
    64
   * \param name The name of the object you want to associate; which may be 
craigdo@4158
    65
   *             prepended with a path to that object.
tomh@4481
    66
   * \param object A smart pointer to the object itself.
craigdo@4139
    67
   */
tomh@4481
    68
  static void Add (std::string name, Ptr<Object> object);
craigdo@4139
    69
craigdo@4139
    70
  /**
craigdo@4160
    71
   * \brief An intermediate form of Names::Add allowing you to provide a path to
craigdo@4160
    72
   * the parent object (under which you want this name to be defined) in the form
craigdo@4160
    73
   * of a name path string.
craigdo@4160
    74
   *
craigdo@4160
    75
   * In some cases, it is desirable to break up the path used to describe an item
craigdo@4160
    76
   * in the names namespace into a path and a name.  This is analogous to a
craigdo@4160
    77
   * file system operation in which you provide a directory name and a file name.
craigdo@4160
    78
   *
craigdo@4160
    79
   * For example, consider a situation where you have previously named an object
craigdo@4160
    80
   * "/Names/server".  If you further want to create an association for between a 
craigdo@4160
    81
   * Ptr<Object> object that you want to live "under" the server in the name space
craigdo@4160
    82
   * -- perhaps "eth0" -- you could do this in two ways, depending on which was 
craigdo@4160
    83
   * more convenient: Names::Add ("/Names/server/eth0", object) or, using the split
craigdo@4160
    84
   * path and name approach, Names::Add ("/Names/server", "eth0", object).
craigdo@4160
    85
   *
craigdo@4160
    86
   * Duplicate names are not allowed at the same level in a path, however you may
craigdo@4160
    87
   * associate similar names with different paths.  For example, if you define
craigdo@4160
    88
   * "/Names/Client", you may not define another "/Names/Client" just as you may
craigdo@4160
    89
   * not have two files with the same name in a classical filesystem.  However,
craigdo@4160
    90
   * you may have "/Names/Client/eth0" and "/Names/Server/eth0" defined at the 
craigdo@4160
    91
   * same time just as you might have different files of the same name under 
craigdo@4160
    92
   * different directories.
craigdo@4160
    93
   *
craigdo@4160
    94
   * \param path A path name describing a previously named object under which 
craigdo@4160
    95
   *             you want this new name to be defined.
craigdo@4160
    96
   * \param name The name of the object you want to associate.
tomh@4481
    97
   * \param object A smart pointer to the object itself.
craigdo@4160
    98
   *
craigdo@4160
    99
   * \see Names::Add (Ptr<Object> context, std::string name, Ptr<Object> object);
craigdo@4160
   100
   */
craigdo@4298
   101
  static void Add (std::string path, std::string name, Ptr<Object> object);
craigdo@4160
   102
craigdo@4160
   103
  /**
craigdo@4160
   104
   * \brief A low-level form of Names::Add allowing you to specify the path to
craigdo@4160
   105
   * the parent object (under which you want this name to be defined) in the form
craigdo@4160
   106
   * of a previously named object.
craigdo@4160
   107
   *
craigdo@4160
   108
   * In some use cases, it is desirable to break up the path in the names name
craigdo@4160
   109
   * space into a path and a name.  This is analogous to a file system operation 
craigdo@4160
   110
   * in which you provide a directory name and a file name.  Recall that the path
craigdo@4160
   111
   * string actually refers to a previously named object, "under" which you want
craigdo@4160
   112
   * to accomplish some naming action.
craigdo@4160
   113
   * 
craigdo@4160
   114
   * However, the path is sometimes not avialable, and you only have the object 
craigdo@4160
   115
   * that is represented by the path in the names name space.  To support this 
craigdo@4160
   116
   * use-case in a reasonably high-performance way, the path string is can be 
craigdo@4160
   117
   * replaced by the object pointer to which that path would refer.  In the spirit
craigdo@4160
   118
   * of the Config code where this use-case is most prominent, we refer to this
craigdo@4160
   119
   * object as the "context" for the names operation.
craigdo@4160
   120
   *
craigdo@4160
   121
   * You can think of the context roughly as the inode number of a directory file
craigdo@4160
   122
   * in Unix.  The inode number can be used to look up the directory file which 
craigdo@4160
   123
   * contains the list of file names defined at that directory level.  Similarly
craigdo@4160
   124
   * the context is used to look up an internal name service entry which contains
craigdo@4160
   125
   * the names defined for that context.
craigdo@4160
   126
   *
craigdo@4160
   127
   * For example, consider a situation where you have previously named an object
craigdo@4160
   128
   * "/Names/server".  If you further want to create an association for between a 
craigdo@4160
   129
   * Ptr<Object> object that you want to live "under" the server in the name space
craigdo@4160
   130
   * -- perhaps "eth0" -- you could do this by providing a complete path to the 
craigdo@4160
   131
   * new name: Names::Add ("/Names/server/eth0", object).  If, however, somewhere
craigdo@4160
   132
   * in your code you only had a pointer to the server, say Ptr<Node> node, and 
craigdo@4160
   133
   * not a handy path string,  you could also accomplish this by 
craigdo@4160
   134
   * Names::Add (node, "eth0", object).
craigdo@4160
   135
   *
craigdo@4160
   136
   * Duplicate names are not allowed at the same level in a path.  In the case
craigdo@4160
   137
   * of this method, the context object gives the same information as a path
craigdo@4160
   138
   * string.  You may associate similar names with different paths.  For example,
craigdo@4160
   139
   *  if you define"/Names/Client", you may not define another "/Names/Client" 
craigdo@4160
   140
   * just as you may not have two files with the same name in a classical filesystem.
craigdo@4160
   141
   * However, you may have "/Names/Client/eth0" and "/Names/Server/eth0" defined at 
craigdo@4160
   142
   * the same time just as you might have different files of the same name under 
craigdo@4160
   143
   * different directories.
craigdo@4160
   144
   *
craigdo@4160
   145
   * \param context A smart pointer to an object that is used in place of the path
craigdo@4160
   146
   *                under which you want this new name to be defined.
craigdo@4160
   147
   * \param name The name of the object you want to associate.
tomh@4481
   148
   * \param object A smart pointer to the object itself.
craigdo@4160
   149
   */
craigdo@4298
   150
  static void Add (Ptr<Object> context, std::string name, Ptr<Object> object);
craigdo@4160
   151
craigdo@4160
   152
  /**
craigdo@4153
   153
   * \brief Rename a previously associated name.
craigdo@4153
   154
   *
craigdo@4153
   155
   * The name may begin either with "/Names" to explicitly call out the fact 
craigdo@4153
   156
   * that the name provided is installed under the root of the name space, 
craigdo@4158
   157
   * or it may begin with the name of the first object in the path.  For example, 
craigdo@4158
   158
   * Names::Rename ("/Names/client", "server") and Names::Rename ("client", "server") 
craigdo@4158
   159
   * accomplish exactly the same thing.  Names at a given level in the name space
craigdo@4158
   160
   * path must be unique. In the case of the example above, it would be illegal 
craigdo@4158
   161
   * to try and rename a different object to the same name: "server" at the same 
craigdo@4158
   162
   * level ("/Names") in the path.
craigdo@4153
   163
   *
craigdo@4158
   164
   * As well as specifying a name at the root of the "/Names" namespace, the 
tomh@4481
   165
   * name parameter can contain a path that fully qualifies the name to 
craigdo@4158
   166
   * be changed.  For example, if you previously have (re)named an object 
craigdo@4158
   167
   * "server" in the root namespace as above, you could then rename an object 
craigdo@4158
   168
   * "under" that name by making a call like Names::Rename ("/Names/server/csma", "eth0").
craigdo@4158
   169
   * This will rename the object previously associated with "/Names/server/csma" 
craigdo@4158
   170
   * to "eth0" and make leave it reachable using the path "/Names/server/eth0".
craigdo@4158
   171
   * Note that Names::Rename ("server/csma", "eth0") would accomplish exactly the 
craigdo@4158
   172
   * same thing.
craigdo@4153
   173
   *
craigdo@4159
   174
   * \param oldpath The current path name to the object you want to change.
craigdo@4153
   175
   * \param newname The new name of the object you want to change.
craigdo@4153
   176
   *
craigdo@4158
   177
   * \see Names::Add (std::string name, Ptr<Object> obj)
craigdo@4153
   178
   */
craigdo@4298
   179
  static void Rename (std::string oldpath, std::string newname);
craigdo@4153
   180
craigdo@4153
   181
  /**
craigdo@4158
   182
   * \brief An intermediate form of Names::Rename allowing you to provide a path to
craigdo@4158
   183
   * the parent object (under which you want this name to be changed) in the form
craigdo@4158
   184
   * of a name path string.
craigdo@4153
   185
   *
craigdo@4158
   186
   * In some cases, it is desirable to break up the path used to describe an item
craigdo@4158
   187
   * in the names namespace into a path and a name.  This is analogous to a
craigdo@4158
   188
   * file system operation in which you provide a directory name and a file name.
craigdo@4153
   189
   *
craigdo@4158
   190
   * For example, consider a situation where you have previously named an object
craigdo@4158
   191
   * "/Names/server/csma".  If you want to change the name "csma" to "eth0", you
craigdo@4158
   192
   * could do this in two ways, depending on which was more convenient: 
craigdo@4158
   193
   * Names::Rename ("/Names/server/csma", "eth0") or, using the split
craigdo@4158
   194
   * path and name approach, Names::Rename ("/Names/server", "csma", "eth0").
craigdo@4158
   195
   *
craigdo@4158
   196
   * \param path A path name describing a previously named object under which 
craigdo@4158
   197
   *             you want this name change to occur (cf. directory).
craigdo@4158
   198
   * \param oldname The currently defined name of the object.
craigdo@4158
   199
   * \param newname The new name you want the object to have.
craigdo@4153
   200
   */
craigdo@4298
   201
  static void Rename (std::string path, std::string oldname, std::string newname);
craigdo@4153
   202
craigdo@4153
   203
  /**
craigdo@4158
   204
   * \brief A low-level form of Names::Rename allowing you to specify the path to
craigdo@4158
   205
   * the parent object (under which you want this name to be changed) in the form
craigdo@4158
   206
   * of a previously named object.
craigdo@4139
   207
   *
craigdo@4158
   208
   * In some use cases, it is desirable to break up the path in the names name
craigdo@4158
   209
   * space into a path and a name.  This is analogous to a file system operation 
craigdo@4158
   210
   * in which you provide a directory name and a file name.  Recall that the path
craigdo@4158
   211
   * string actually refers to a previously named object, "under" which you want
craigdo@4158
   212
   * to accomplish some naming action.
craigdo@4158
   213
   * 
craigdo@4158
   214
   * However, the path is sometimes not avialable, and you only have the object 
craigdo@4158
   215
   * that is represented by the path in the names name space.  To support this 
craigdo@4158
   216
   * use-case in a reasonably high-performance way, the path string is can be 
craigdo@4158
   217
   * replaced by the object pointer to which that path would refer.  In the spirit
craigdo@4158
   218
   * of the Config code where this use-case is most prominent, we refer to this
craigdo@4158
   219
   * object as the "context" for the names operation.
craigdo@4146
   220
   *
craigdo@4160
   221
   * You can think of the context roughly as the inode number of a directory file
craigdo@4160
   222
   * in Unix.  The inode number can be used to look up the directory file which 
craigdo@4160
   223
   * contains the list of file names defined at that directory level.  Similarly
craigdo@4160
   224
   * the context is used to look up an internal name service entry which contains
craigdo@4160
   225
   * the names defined for that context.
craigdo@4160
   226
   *
craigdo@4158
   227
   * For example, consider a situation where you have previously named an object
craigdo@4158
   228
   * "/Names/server/csma".  If you later decide to rename the csma object to say
craigdo@4158
   229
   * "eth0" -- you could do this by providing a complete path as in
craigdo@4158
   230
   * Names::Rename ("/Names/server/csma", "eth0").  If, however, somewhere
craigdo@4158
   231
   * in your code you only had a pointer to the server, and not a handy path 
craigdo@4158
   232
   * string, say Ptr<Node> node, you could also accomplish this by 
craigdo@4158
   233
   * Names::Rename (node, "csma", "eth0").
craigdo@4158
   234
   *
craigdo@4158
   235
   * \param context A smart pointer to an object that is used in place of the path
craigdo@4158
   236
   *                under which you want this new name to be defined.
craigdo@4153
   237
   * \param oldname The current shortname of the object you want to change.
craigdo@4153
   238
   * \param newname The new shortname of the object you want to change.
craigdo@4139
   239
   */
craigdo@4298
   240
  static void Rename (Ptr<Object> context, std::string oldname, std::string newname);
craigdo@4139
   241
craigdo@4139
   242
  /**
craigdo@4139
   243
   * Given a pointer to an object, look to see if that object has a name
craigdo@4158
   244
   * associated with it and, if so, return the name of the object otherwise
craigdo@4158
   245
   * return an empty string.
craigdo@4139
   246
   *
craigdo@4158
   247
   * An object can be referred to in two ways.  Either you can talk about it
craigdo@4158
   248
   * using its fully qualified path name, for example, "/Names/client/eth0"
craigdo@4158
   249
   * or you can refer to it by its name, in this case "eth0".
craigdo@4139
   250
   *
craigdo@4158
   251
   * This method returns the name of the object, e.g., "eth0".
craigdo@4139
   252
   *
craigdo@4139
   253
   * \param object A spart pointer to an object for which you want to find
craigdo@4158
   254
   *               its name.
craigdo@4146
   255
   *
craigdo@4158
   256
   * \returns a string containing the name of the object if found, otherwise
craigdo@4158
   257
   *          the empty string.
craigdo@4139
   258
   */
craigdo@4158
   259
  static std::string FindName (Ptr<Object> object);
craigdo@4139
   260
craigdo@4139
   261
  /**
craigdo@4139
   262
   * Given a pointer to an object, look to see if that object has a name
craigdo@4158
   263
   * associated with it and return the fully qualified name path of the 
craigdo@4158
   264
   * object otherwise return an empty string.
craigdo@4139
   265
   *
craigdo@4158
   266
   * An object can be referred to in two ways.  Either you can talk about it
craigdo@4158
   267
   * using its fully qualified path name, for example, "/Names/client/eth0"
craigdo@4158
   268
   * or you can refer to it by its name, in this case "eth0".
craigdo@4139
   269
   *
craigdo@4158
   270
   * This method returns the name path of the object, e.g., "Names/client/eth0".
craigdo@4139
   271
   *
craigdo@4139
   272
   * \param object A spart pointer to an object for which you want to find
craigdo@4139
   273
   *               its fullname.
craigdo@4146
   274
   *
craigdo@4158
   275
   * \returns a string containing the name path of the object, otherwise
craigdo@4158
   276
   *          the empty string.
craigdo@4139
   277
   */
craigdo@4158
   278
  static std::string FindPath (Ptr<Object> object);
craigdo@4139
   279
craigdo@4139
   280
  /**
craigdo@4158
   281
   * Given a name path string, look to see if there's an object in the system
craigdo@4158
   282
   * with that associated to it.  If there is, do a GetObject on the resulting
craigdo@4158
   283
   * object to convert it to the requested typename and return it.
craigdo@4139
   284
   * 
craigdo@4158
   285
   * An object can be referred to in two ways.  Either you can talk about it
craigdo@4158
   286
   * using its fully qualified path name, for example, "/Names/client/eth0"
craigdo@4158
   287
   * or you can refer to it by its name, in this case "eth0".
craigdo@4139
   288
   *
craigdo@4158
   289
   * This method requires that the name path of the object be provided, e.g., 
craigdo@4158
   290
   * "Names/client/eth0".
craigdo@4158
   291
   *
craigdo@4158
   292
   * \param path A string containing a name space path used to locate the object.
craigdo@4146
   293
   *
craigdo@4146
   294
   * \returns a smart pointer to the named object converted to the requested
craigdo@4146
   295
   *          type.
craigdo@4139
   296
   */
craigdo@4139
   297
  template <typename T>
craigdo@4158
   298
  static Ptr<T> Find (std::string path);
craigdo@4139
   299
craigdo@4139
   300
  /**
craigdo@4158
   301
   * Given a path to an object and an object name, look through the names defined
craigdo@4158
   302
   * under the path to see if there's an object there with the given name.
craigdo@4139
   303
   *
craigdo@4158
   304
   * In some cases, it is desirable to break up the path used to describe an item
craigdo@4158
   305
   * in the names namespace into a path and a name.  This is analogous to a
craigdo@4158
   306
   * file system operation in which you provide a directory name and a file name.
craigdo@4139
   307
   *
craigdo@4158
   308
   * For example, consider a situation where you have previously named an object
craigdo@4158
   309
   * "/Names/server/eth0".  If you want to discover the object which you associated
craigdo@4158
   310
   * with this path, you could do this in two ways, depending on which was more 
craigdo@4158
   311
   * convenient: Names::Find ("/Names/server/eth0") or, using the split path and 
craigdo@4158
   312
   * name approach, Names::Find ("/Names/server", "eth0").
craigdo@4146
   313
   *
craigdo@4158
   314
   * \param path A path name describing a previously named object under which 
craigdo@4158
   315
   *             you want to look for the specified name.
craigdo@4158
   316
   * \param name A string containing a name to search for.
craigdo@4146
   317
   *
craigdo@4146
   318
   * \returns a smart pointer to the named object converted to the requested
craigdo@4146
   319
   *          type.
craigdo@4139
   320
   */
craigdo@4139
   321
  template <typename T>
craigdo@4158
   322
  static Ptr<T> Find (std::string path, std::string name);
craigdo@4158
   323
craigdo@4158
   324
  /**
craigdo@4158
   325
   * Given a path to an object and an object name, look through the names defined
craigdo@4158
   326
   * under the path to see if there's an object there with the given name.
craigdo@4158
   327
   *
craigdo@4158
   328
   * In some cases, it is desirable to break up the path used to describe an item
craigdo@4158
   329
   * in the names namespace into a path and a name.  This is analogous to a
craigdo@4158
   330
   * file system operation in which you provide a directory name and a file name.
craigdo@4158
   331
   *
craigdo@4158
   332
   * For example, consider a situation where you have previously named an object
craigdo@4158
   333
   * "/Names/server/eth0".  If you want to discover the object which you associated
craigdo@4158
   334
   * with this path, you could do this in two ways, depending on which was more 
craigdo@4158
   335
   * convenient: Names::Find ("/Names/server/eth0") or, using the split path and 
craigdo@4158
   336
   * name approach, Names::Find ("/Names/server", "eth0").
craigdo@4158
   337
   *
craigdo@4158
   338
   * However, the path is sometimes not avialable, and you only have the object 
craigdo@4158
   339
   * that is represented by the path in the names name space.  To support this 
craigdo@4158
   340
   * use-case in a reasonably high-performance way, the path string is can be 
craigdo@4158
   341
   * replaced by the object pointer to which that path would refer.  In the spirit
craigdo@4158
   342
   * of the Config code where this use-case is most prominent, we refer to this
craigdo@4158
   343
   * object as the "context" for the names operation.
craigdo@4158
   344
   *
craigdo@4160
   345
   * You can think of the context roughly as the inode number of a directory file
craigdo@4160
   346
   * in Unix.  The inode number can be used to look up the directory file which 
craigdo@4160
   347
   * contains the list of file names defined at that directory level.  Similarly
craigdo@4160
   348
   * the context is used to look up an internal name service entry which contains
craigdo@4160
   349
   * the names defined for that context.
craigdo@4160
   350
   *
craigdo@4158
   351
   * \param context A smart pointer to an object that is used in place of the path
craigdo@4158
   352
   *                under which you want this new name to be defined.
craigdo@4158
   353
   * \param name A string containing a name to search for.
craigdo@4158
   354
   *
craigdo@4158
   355
   * \returns a smart pointer to the named object converted to the requested
craigdo@4158
   356
   *          type.
craigdo@4158
   357
   */
craigdo@4158
   358
  template <typename T>
craigdo@4158
   359
  static Ptr<T> Find (Ptr<Object> context, std::string name);
craigdo@4139
   360
craigdo@4145
   361
  /**
craigdo@4145
   362
   * Clean up all of the data structures of the implementation and delete the
craigdo@4145
   363
   * underlying singleton.  Used to get valgrind-clean runs if the simulator
craigdo@4145
   364
   * is not run.  Normally singleton cleanup is scheduled on Simulator::Destroy.
craigdo@4145
   365
   */
craigdo@4145
   366
  static void Delete (void);
craigdo@4145
   367
craigdo@4139
   368
private:
craigdo@4139
   369
  /**
craigdo@4139
   370
   * \internal
craigdo@4139
   371
   *
craigdo@4158
   372
   * \brief Non-templated internal version of Names::Find
craigdo@4139
   373
   *
craigdo@4158
   374
   * \param name A string containing the path of the object to look for.
craigdo@4146
   375
   *
craigdo@4146
   376
   * \returns a smart pointer to the named object.
craigdo@4139
   377
   */
craigdo@4158
   378
  static Ptr<Object> FindInternal (std::string path);
craigdo@4139
   379
craigdo@4139
   380
  /**
craigdo@4139
   381
   * \internal
craigdo@4139
   382
   *
craigdo@4158
   383
   * \brief Non-templated internal version of Names::Find
craigdo@4158
   384
   *
craigdo@4158
   385
   * \param context A string containing the path to search for the object in.
craigdo@4158
   386
   * \param name A string containing the name of the object to look for.
craigdo@4158
   387
   *
craigdo@4158
   388
   * \returns a smart pointer to the named object.
craigdo@4158
   389
   */
craigdo@4158
   390
  static Ptr<Object> FindInternal (std::string path, std::string name);
craigdo@4158
   391
craigdo@4158
   392
  /**
craigdo@4158
   393
   * \internal
craigdo@4158
   394
   *
craigdo@4158
   395
   * \brief Non-templated internal version of Names::Find
craigdo@4139
   396
   *
craigdo@4139
   397
   * \param context A spart pointer to an object under which you want to look 
craigdo@4139
   398
   *                for the provided name.
craigdo@4158
   399
   * \param name A string containing the name to look for.
craigdo@4146
   400
   *
craigdo@4146
   401
   * \returns a smart pointer to the named object.
craigdo@4139
   402
   */
craigdo@4158
   403
  static Ptr<Object> FindInternal (Ptr<Object> context, std::string name);
craigdo@4139
   404
};
craigdo@4139
   405
craigdo@4139
   406
/**
craigdo@4139
   407
 * \brief Template definition of corresponding template declaration found in class Names.
craigdo@4139
   408
 */
craigdo@4139
   409
template <typename T>
craigdo@4139
   410
Ptr<T> 
craigdo@4139
   411
Names::Find (std::string name)
craigdo@4139
   412
{
craigdo@4158
   413
  Ptr<Object> obj = FindInternal (name);
craigdo@4139
   414
  if (obj)
craigdo@4139
   415
    {
craigdo@4139
   416
      return obj->GetObject<T> ();
craigdo@4139
   417
    }
craigdo@4139
   418
  else
craigdo@4139
   419
    {
craigdo@4139
   420
      return 0;
craigdo@4139
   421
    }
craigdo@4139
   422
}
craigdo@4139
   423
craigdo@4139
   424
/**
craigdo@4139
   425
 * \brief Template definition of corresponding template declaration found in class Names.
craigdo@4139
   426
 */
craigdo@4139
   427
template <typename T>
craigdo@4139
   428
Ptr<T> 
craigdo@4159
   429
Names::Find (std::string path, std::string name)
craigdo@4159
   430
{
craigdo@4159
   431
  Ptr<Object> obj = FindInternal (path, name);
craigdo@4159
   432
  if (obj)
craigdo@4159
   433
    {
craigdo@4159
   434
      return obj->GetObject<T> ();
craigdo@4159
   435
    }
craigdo@4159
   436
  else
craigdo@4159
   437
    {
craigdo@4159
   438
      return 0;
craigdo@4159
   439
    }
craigdo@4159
   440
}
craigdo@4159
   441
craigdo@4159
   442
/**
craigdo@4159
   443
 * \brief Template definition of corresponding template declaration found in class Names.
craigdo@4159
   444
 */
craigdo@4159
   445
template <typename T>
craigdo@4159
   446
Ptr<T> 
craigdo@4158
   447
Names::Find (Ptr<Object> context, std::string name)
craigdo@4139
   448
{
craigdo@4158
   449
  Ptr<Object> obj = FindInternal (context, name);
craigdo@4139
   450
  if (obj)
craigdo@4139
   451
    {
craigdo@4139
   452
      return obj->GetObject<T> ();
craigdo@4139
   453
    }
craigdo@4139
   454
  else
craigdo@4139
   455
    {
craigdo@4139
   456
      return 0;
craigdo@4139
   457
    }
craigdo@4139
   458
}
craigdo@4139
   459
craigdo@4139
   460
}//namespace ns3
craigdo@4139
   461
craigdo@4139
   462
#endif /* OBJECT_NAMES_H */