This file is indexed.

/usr/include/ns3.26/ns3/attribute-helper.h is in libns3-dev 3.26+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2008 INRIA
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
 */
#ifndef ATTRIBUTE_HELPER_H
#define ATTRIBUTE_HELPER_H

#include "attribute.h"
#include "attribute-accessor-helper.h"
#include <sstream>
#include "abort.h"

/**
 * \file
 * \ingroup attributehelper
 * Declaration of Attribute helper macros.
 */

namespace ns3 {

/**
 * \ingroup attribute
 * \defgroup attributehelper Attribute Helper
 *
 * All these macros can be used to generate automatically the code
 * for subclasses of AttributeValue, AttributeAccessor, and, AttributeChecker,
 * which can be used to give attribute powers to a normal class. i.e.,
 * the user class can then effectively be made an attribute.
 *
 * There are two kinds of helper macros:
 *   -# The simple macros.
 *     - ATTRIBUTE_HELPER_HEADER(type)
 *     - ATTRIBUTE_HELPER_CPP(type)
 *   -# The more complex macros.
 *
 * The simple macros are implemented in terms of the complex
 * macros and should generally be preferred over the complex macros.
 *
 * \note
 * Because these macros generate class and function definitions, it's
 * difficult to document the results directly.  Instead, we use a
 * set of functions in print-introspected-doxygen.cc to generate
 * most of the APi documentation.  When using these macros,
 * please add the required function calls to print-introspected-doxygen.cc
 * so your new API is documented.
 */

/**
 * \ingroup attributehelper
 * \defgroup attributeimpl Attribute Implementation
 *
 * These are the internal implementation functions for the Attribute
 * system.
 *
 * Module code shouldn't need to call these directly.  Instead,
 * see \ref attributehelper.
 *
 * There are three versions of DoMakeAccessorHelperOne:
 *  - With a member variable: DoMakeAccessorHelperOne(U T::*)
 *  - With a class get functor: DoMakeAccessorHelperOne(U(T::*)(void) const)
 *  - With a class set method:  DoMakeAccessorHelperOne(void(T::*)(U))
 *
 * There are two pairs of DoMakeAccessorHelperTwo (four total):
 *  - Taking two arguments, a set method and get functor, in either order,
 *  - With set methods returning \c void or \c bool.
 */

/**
 * \ingroup attributeimpl
 *
 * A simple string-based attribute checker
 *
 * \tparam T    \explicit The specific AttributeValue type used to represent
 *              the Attribute.
 * \tparam BASE \explicit The AttributeChecker type corresponding to \p T.
 * \param [in] name  The name of the AttributeValue type, essentially the
 *              string form of \p T.
 * \param [in] underlying Underlying type name.
 * \return Ptr to AttributeChecker.
 */
template <typename T, typename BASE>
Ptr<AttributeChecker>
MakeSimpleAttributeChecker (std::string name, std::string underlying)
{
  /* String-based AttributeChecker implementation. */
  struct SimpleAttributeChecker : public BASE
  {
    virtual bool Check (const AttributeValue &value) const {
      return dynamic_cast<const T *> (&value) != 0;
    }
    virtual std::string GetValueTypeName (void) const {
      return m_type;
    }
    virtual bool HasUnderlyingTypeInformation (void) const {
      return true;
    }
    virtual std::string GetUnderlyingTypeInformation (void) const {
      return m_underlying;
    }
    virtual Ptr<AttributeValue> Create (void) const {
      return ns3::Create<T> ();
    }
    virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const {
      const T *src = dynamic_cast<const T *> (&source);
      T *dst = dynamic_cast<T *> (&destination);
      if (src == 0 || dst == 0)
        {
          return false;
        }
      *dst = *src;
      return true;
    }
    std::string m_type;        // The name of the AttributeValue type.
    std::string m_underlying;  // The underlying attribute type name.
  } *checker = new SimpleAttributeChecker ();
  checker->m_type = name;
  checker->m_underlying = underlying;
  return Ptr<AttributeChecker> (checker, false);
}

}

/**
 * \ingroup attributehelper
 *
 * Define the attribute accessor functions \c MakeTypeAccessor
 * for class \p type.
 *
 * \param [in] type The name of the class
 *
 * This macro defines and generates the code for the implementation 
 * of the \c MakeTypeAccessor template functions. This macro is typically
 * invoked in a class header to allow users of this class to view and
 * use the template functions defined here. This macro is implemented
 * through the helper templates functions ns3::MakeAccessorHelper<>.
 */
#define ATTRIBUTE_ACCESSOR_DEFINE(type)                                 \
  template <typename T1>                                                \
  Ptr<const AttributeAccessor> Make ## type ## Accessor (T1 a1)         \
  {                                                                     \
    return MakeAccessorHelper<type ## Value> (a1);                      \
  }                                                                     \
  template <typename T1, typename T2>                                   \
  Ptr<const AttributeAccessor> Make ## type ## Accessor (T1 a1, T2 a2)  \
  {                                                                     \
    return MakeAccessorHelper<type ## Value> (a1, a2);                  \
  }

/**
 * \ingroup attributehelper
 *
 * Declare the attribute value class \p \<name>Value
 * for underlying class \p type.
 *
 * \param [in] type The underlying type name
 * \param [in] name The token to use in defining the accessor name.
 *
 * This macro declares the class \c TypeValue associated with class \c type.
 * This macro is typically invoked in the class header file.
 *
 * This can be used directly for things like plain old data,
 * such as \c std::string, to create the attribute value class
 * StringValue.
 */
#define ATTRIBUTE_VALUE_DEFINE_WITH_NAME(type,name)                     \
  class name ## Value : public AttributeValue                           \
  {                                                                     \
  public:                                                               \
    name ## Value ();                                                   \
    name ## Value (const type &value);                                  \
    void Set (const type &value);                                       \
    type Get (void) const;                                              \
    template <typename T>                                               \
      bool GetAccessor (T &value) const {                               \
      value = T (m_value);                                              \
      return true;                                                      \
    }                                                                   \
    virtual Ptr<AttributeValue> Copy (void) const;                      \
    virtual std::string                                                 \
      SerializeToString (Ptr<const AttributeChecker> checker) const;    \
    virtual bool                                                        \
      DeserializeFromString (std::string value,                         \
                             Ptr<const AttributeChecker> checker);      \
  private:                                                              \
    type m_value;                                                       \
  };


/**
 * \ingroup attributehelper
 *
 * Declare the attribute value class \p \<Name>Value
 * for the class \p Name
 *
 * \param [in] Name The name of the class.
 *
 * This macro declares the class \c NameValue associated to class \c Name.
 * This macro is typically invoked in the class header file.
 */
#define ATTRIBUTE_VALUE_DEFINE(Name)                                    \
  ATTRIBUTE_VALUE_DEFINE_WITH_NAME (Name,Name)


/**
 * \ingroup attributehelper
 *
 * Define the conversion operators class \p type and
 * Attribute instances.
 *
 * \param [in] type The name of the class
 *
 * This macro defines the conversion operators for class \c type to and
 * from instances of type Attribute.
 * Typically invoked in the class header file.
 *
 * \internal
 * This appears to be unused.
 */
#define ATTRIBUTE_CONVERTER_DEFINE(type)

/**
 * \ingroup attributehelper
 *
 * Declare the AttributeChecker class \p \<type>Checker
 * and the \c MakeTypeChecker function for class \p type.
 *
 * \param [in] type The name of the class
 *
 * This macro declares the \p \<type>Checker class and the associated
 * \c MakeTypeChecker function.
 *
 * (Note that the \p \<type>Checker class needs no implementation
 * since it just inherits all its implementation from AttributeChecker.)
 *
 * Typically invoked in the class header file.
 */
#define ATTRIBUTE_CHECKER_DEFINE(type)                                  \
  class type ## Checker : public AttributeChecker {};                   \
  Ptr<const AttributeChecker> Make ## type ## Checker (void)


/**
 * \ingroup attributehelper
 *
 * Define the class methods belonging to
 * the attribute value class \p \<name>Value 
 * of the underlying class \p type.
 *
 * \param [in] type The underlying type name
 * \param [in] name The token to use in defining the accessor name.
 *
 * This macro implements the \p \<type>Value class methods
 * (including the \p \<type>Value::SerializeToString
 * and \p \<type>Value::DeserializeFromString methods).
 *
 * Typically invoked in the source file.
 */
#define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type,name)                  \
  name ## Value::name ## Value ()                                       \
    : m_value () {}                                                     \
  name ## Value::name ## Value (const type &value)                      \
    : m_value (value) {}                                                \
  void name ## Value::Set (const type &v) {                             \
    m_value = v;                                                        \
  }                                                                     \
  type name ## Value::Get (void) const {                                \
    return m_value;                                                     \
  }                                                                     \
  Ptr<AttributeValue>                                                   \
  name ## Value::Copy (void) const {                                    \
    return ns3::Create<name ## Value> (*this);                          \
  }                                                                     \
  std::string name ## Value::SerializeToString                          \
    (Ptr<const AttributeChecker> checker) const {                       \
      std::ostringstream oss;                                           \
      oss << m_value;                                                   \
      return oss.str ();                                                \
  }                                                                     \
  bool name ## Value::DeserializeFromString                             \
    (std::string value, Ptr<const AttributeChecker> checker) {          \
      std::istringstream iss;                                           \
      iss.str (value);                                                  \
      iss >> m_value;                                                   \
      NS_ABORT_MSG_UNLESS (iss.eof (), "Attribute value " << "\"" << value << "\"" << " is not properly formatted");                                        \
      return !iss.bad () && !iss.fail ();                               \
  }

/**
 * \ingroup attributehelper
 *
 * Define the class methods belonging to
 * attribute value class \p \<type>Value for class \p type.
 *
 * \param [in] type The name of the class.
 *
 * This macro implements the \p \<type>Value class methods
 * (including the \p \<type>Value::SerializeToString
 * and \p \<type>Value::DeserializeFromString methods).
 *
 * Typically invoked in the source file.
 */
#define ATTRIBUTE_VALUE_IMPLEMENT(type)                                 \
  ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (type,type)


/**
 * \ingroup attributehelper
 *
 * Define the \c MakeTypeChecker function for class \p type.
 *
 * \param [in] type The name of the class
 *
 * This macro implements the \c MakeTypeChecker function.
 *
 * Typically invoked in the source file..
 */
#define ATTRIBUTE_CHECKER_IMPLEMENT(type)                               \
  Ptr<const AttributeChecker> Make ## type ## Checker (void) {          \
    return MakeSimpleAttributeChecker<type ## Value,type ## Checker>    \
      (# type "Value", # type);                                         \
  }                                                                     \

/**
 * \ingroup attributehelper
 *
 * Define the \c MakeTypeChecker function for class \p type.
 *
 * \param [in] type The name of the class.
 * \param [in] name The string name of the underlying type.
 *
 * This macro implements the \c MakeTypeChecker function
 * for class \p type.
 *
 * Typically invoked in the source file..
 */
#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type,name)                \
  Ptr<const AttributeChecker> Make ## type ## Checker (void) {          \
    return MakeSimpleAttributeChecker<type ## Value,type ## Checker>    \
      (# type "Value", name);                                           \
  }                                                                     \

/**
 * \ingroup attributehelper
 *
 * Declare the attribute value, accessor and checkers for class \p type
 *
 * \param [in] type The name of the class
 *
 * This macro declares:
 *
 *   - The attribute value class \p \<type>Value,
 *
 *   - The attribute accessor functions \c MakeTypeAccessor,
 *
 *   - The AttributeChecker class \p \<type>Checker
 *     and the \c MakeTypeChecker function,
 *
 * for class \p type.
 *
 * This macro should be invoked outside of the class
 * declaration in its public header.
 */
#define ATTRIBUTE_HELPER_HEADER(type)                                   \
  ATTRIBUTE_VALUE_DEFINE (type);                                        \
  ATTRIBUTE_ACCESSOR_DEFINE (type);                                     \
  ATTRIBUTE_CHECKER_DEFINE (type);

/**
 * \ingroup attributehelper
 *
 * Define the attribute value, accessor and checkers for class \p type
 *
 * \param [in] type The name of the class
 *
 * This macro implements
 *
 *   - The \p \<type>Value class methods,
 *
 *   - The \c MakeTypeChecker function,
 *
 * for class \p type.
 *
 * This macro should be invoked from the class implementation file.
 */
#define ATTRIBUTE_HELPER_CPP(type)                                      \
  ATTRIBUTE_CHECKER_IMPLEMENT (type);                                   \
  ATTRIBUTE_VALUE_IMPLEMENT (type);


#endif /* ATTRIBUTE_HELPER_H */