View | Details | Raw Unified | Return to bug 2149
Collapse All | Expand All

(-)a/src/core/model/type-id.cc (-2 / +158 lines)
 Lines 102-119   public: Link Here 
102
                     Ptr<const AttributeValue> initialValue,
102
                     Ptr<const AttributeValue> initialValue,
103
                     Ptr<const AttributeAccessor> spec,
103
                     Ptr<const AttributeAccessor> spec,
104
                     Ptr<const AttributeChecker> checker);
104
                     Ptr<const AttributeChecker> checker);
105
  void AddDeprecatedAttribute (uint16_t uid, const std::string &oldName,
106
                               const std::string &oldClass, const std::string &msg);
105
  void SetAttributeInitialValue(uint16_t uid,
107
  void SetAttributeInitialValue(uint16_t uid,
106
                                uint32_t i,
108
                                uint32_t i,
107
                                Ptr<const AttributeValue> initialValue);
109
                                Ptr<const AttributeValue> initialValue);
108
  uint32_t GetAttributeN (uint16_t uid) const;
110
  uint32_t GetAttributeN (uint16_t uid) const;
111
  uint32_t GetDeprecatedAttributeN (uint16_t uid) const;
109
  struct TypeId::AttributeInformation GetAttribute(uint16_t uid, uint32_t i) const;
112
  struct TypeId::AttributeInformation GetAttribute(uint16_t uid, uint32_t i) const;
113
  struct TypeId::DeprecatedAttributeInformation GetDeprecatedAttribute (uint16_t uid,
114
                                                                        uint32_t i) const;
110
  void AddTraceSource (uint16_t uid,
115
  void AddTraceSource (uint16_t uid,
111
                       std::string name, 
116
                       std::string name, 
112
                       std::string help,
117
                       std::string help,
113
                       Ptr<const TraceSourceAccessor> accessor,
118
                       Ptr<const TraceSourceAccessor> accessor,
114
                       std::string callback);
119
                       std::string callback);
120
  void AddDeprecatedTraceSource(uint16_t uid, const std::string &oldName,
121
                                const std::string &oldClass, const std::string &msg);
115
  uint32_t GetTraceSourceN (uint16_t uid) const;
122
  uint32_t GetTraceSourceN (uint16_t uid) const;
123
  uint32_t GetDeprecatedTraceSourceN (uint16_t uid) const;
116
  struct TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, uint32_t i) const;
124
  struct TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, uint32_t i) const;
125
  struct TypeId::DeprecatedTraceSourceInformation GetDeprecatedTraceSource (uint16_t uid,
126
                                                                            uint32_t i) const;
117
  bool MustHideFromDocumentation (uint16_t uid) const;
127
  bool MustHideFromDocumentation (uint16_t uid) const;
118
128
119
private:
129
private:
 Lines 131-137   private: Link Here 
131
    Callback<ObjectBase *> constructor;
141
    Callback<ObjectBase *> constructor;
132
    bool mustHideFromDocumentation;
142
    bool mustHideFromDocumentation;
133
    std::vector<struct TypeId::AttributeInformation> attributes;
143
    std::vector<struct TypeId::AttributeInformation> attributes;
144
    std::vector<struct TypeId::DeprecatedAttributeInformation> deprecatedAttributes;
134
    std::vector<struct TypeId::TraceSourceInformation> traceSources;
145
    std::vector<struct TypeId::TraceSourceInformation> traceSources;
146
    std::vector<struct TypeId::DeprecatedTraceSourceInformation> deprecatedTraceSources;
135
  };
147
  };
136
  typedef std::vector<struct IidInformation>::const_iterator Iterator;
148
  typedef std::vector<struct IidInformation>::const_iterator Iterator;
137
149
 Lines 436-441   IidManager::AddAttribute (uint16_t uid, Link Here 
436
  info.checker = checker;
448
  info.checker = checker;
437
  information->attributes.push_back (info);
449
  information->attributes.push_back (info);
438
}
450
}
451
452
void
453
IidManager::AddDeprecatedAttribute(uint16_t uid, const std::string &oldName,
454
                                   const std::string &oldClass, const std::string &msg)
455
{
456
  NS_LOG_FUNCTION (this << oldName << oldClass);
457
  struct IidInformation *information = LookupInformation (uid);
458
  struct TypeId::DeprecatedAttributeInformation info;
459
  info.oldName = oldName;
460
  info.oldClass = oldClass;
461
  info.msg = msg;
462
  information->deprecatedAttributes.push_back (info);
463
}
464
439
void 
465
void 
440
IidManager::SetAttributeInitialValue(uint16_t uid,
466
IidManager::SetAttributeInitialValue(uint16_t uid,
441
                                     uint32_t i,
467
                                     uint32_t i,
 Lines 447-454   IidManager::SetAttributeInitialValue(uint16_t uid, Link Here 
447
  information->attributes[i].initialValue = initialValue;
473
  information->attributes[i].initialValue = initialValue;
448
}
474
}
449
475
450
451
452
uint32_t 
476
uint32_t 
453
IidManager::GetAttributeN (uint16_t uid) const
477
IidManager::GetAttributeN (uint16_t uid) const
454
{
478
{
 Lines 456-461   IidManager::GetAttributeN (uint16_t uid) const Link Here 
456
  struct IidInformation *information = LookupInformation (uid);
480
  struct IidInformation *information = LookupInformation (uid);
457
  return information->attributes.size ();
481
  return information->attributes.size ();
458
}
482
}
483
484
uint32_t
485
IidManager::GetDeprecatedAttributeN (uint16_t uid) const
486
{
487
  NS_LOG_FUNCTION (this << uid);
488
  struct IidInformation *information = LookupInformation (uid);
489
  return information->deprecatedAttributes.size ();
490
}
491
459
struct TypeId::AttributeInformation 
492
struct TypeId::AttributeInformation 
460
IidManager::GetAttribute(uint16_t uid, uint32_t i) const
493
IidManager::GetAttribute(uint16_t uid, uint32_t i) const
461
{
494
{
 Lines 465-470   IidManager::GetAttribute(uint16_t uid, uint32_t i) const Link Here 
465
  return information->attributes[i];
498
  return information->attributes[i];
466
}
499
}
467
500
501
struct TypeId::DeprecatedAttributeInformation
502
IidManager::GetDeprecatedAttribute (uint16_t uid, uint32_t i) const
503
{
504
  NS_LOG_FUNCTION (this << uid << i);
505
  struct IidInformation *information = LookupInformation (uid);
506
  NS_ASSERT (i < information->deprecatedAttributes.size ());
507
  return information->deprecatedAttributes[i];
508
}
509
468
bool
510
bool
469
IidManager::HasTraceSource (uint16_t uid,
511
IidManager::HasTraceSource (uint16_t uid,
470
                            std::string name)
512
                            std::string name)
 Lines 514-519   IidManager::AddTraceSource (uint16_t uid, Link Here 
514
  source.callback = callback;
556
  source.callback = callback;
515
  information->traceSources.push_back (source);
557
  information->traceSources.push_back (source);
516
}
558
}
559
560
void
561
IidManager::AddDeprecatedTraceSource (uint16_t uid, const std::string &oldName,
562
                                      const std::string &oldClass, const std::string &msg)
563
{
564
  NS_LOG_FUNCTION (this << uid << oldName << oldClass);
565
  struct IidInformation *information = LookupInformation (uid);
566
  struct TypeId::DeprecatedTraceSourceInformation source;
567
  source.oldName = oldName;
568
  source.oldClass = oldClass;
569
  source.msg = msg;
570
  information->deprecatedTraceSources.push_back (source);
571
}
572
517
uint32_t 
573
uint32_t 
518
IidManager::GetTraceSourceN (uint16_t uid) const
574
IidManager::GetTraceSourceN (uint16_t uid) const
519
{
575
{
 Lines 521-526   IidManager::GetTraceSourceN (uint16_t uid) const Link Here 
521
  struct IidInformation *information = LookupInformation (uid);
577
  struct IidInformation *information = LookupInformation (uid);
522
  return information->traceSources.size ();
578
  return information->traceSources.size ();
523
}
579
}
580
581
uint32_t
582
IidManager::GetDeprecatedTraceSourceN (uint16_t uid) const
583
{
584
  NS_LOG_FUNCTION (this << uid);
585
  struct IidInformation *information = LookupInformation (uid);
586
  return information->deprecatedTraceSources.size ();
587
}
588
524
struct TypeId::TraceSourceInformation 
589
struct TypeId::TraceSourceInformation 
525
IidManager::GetTraceSource(uint16_t uid, uint32_t i) const
590
IidManager::GetTraceSource(uint16_t uid, uint32_t i) const
526
{
591
{
 Lines 529-534   IidManager::GetTraceSource(uint16_t uid, uint32_t i) const Link Here 
529
  NS_ASSERT (i < information->traceSources.size ());
594
  NS_ASSERT (i < information->traceSources.size ());
530
  return information->traceSources[i];
595
  return information->traceSources[i];
531
}
596
}
597
598
struct TypeId::DeprecatedTraceSourceInformation
599
IidManager::GetDeprecatedTraceSource(uint16_t uid, uint32_t i) const
600
{
601
  NS_LOG_FUNCTION (this << uid << i);
602
  struct IidInformation *information = LookupInformation (uid);
603
  NS_ASSERT (i < information->deprecatedTraceSources.size ());
604
  return information->deprecatedTraceSources[i];
605
}
606
532
bool 
607
bool 
533
IidManager::MustHideFromDocumentation (uint16_t uid) const
608
IidManager::MustHideFromDocumentation (uint16_t uid) const
534
{
609
{
 Lines 631-636   TypeId::LookupAttributeByName (std::string name, struct TypeId::AttributeInforma Link Here 
631
        }
706
        }
632
      nextTid = tid.GetParent ();
707
      nextTid = tid.GetParent ();
633
    } while (nextTid != tid);
708
    } while (nextTid != tid);
709
710
  nextTid = *this;
711
  do {
712
      tid = nextTid;
713
      for (uint32_t i = 0; i < tid.GetDeprecatedAttributeN (); ++i)
714
        {
715
          struct TypeId::DeprecatedAttributeInformation tmp = tid.GetDeprecatedAttribute (i);
716
          if (tmp.oldName == name)
717
            {
718
              NS_LOG_UNCOND ("ATTENTION: Deprecated attribute " << name <<
719
                             " in class " << tmp.oldClass << "." << tmp.msg);
720
              return false;
721
            }
722
        }
723
      nextTid = tid.GetParent ();
724
    } while (nextTid != tid);
725
634
  return false;
726
  return false;
635
}
727
}
636
728
 Lines 750-755   TypeId::AddAttribute (std::string name, Link Here 
750
  return *this;
842
  return *this;
751
}
843
}
752
844
845
TypeId
846
TypeId::DeprecateAttribute (const std::string &oldName, const std::string &oldClass,
847
                            const std::string &msg)
848
{
849
  Singleton<IidManager>::Get ()->AddDeprecatedAttribute (m_tid, oldName, oldClass, msg);
850
  return *this;
851
}
852
853
TypeId
854
TypeId::DeprecateTraceSource (const std::string &oldName, const std::string &oldClass,
855
                              const std::string &msg)
856
{
857
  Singleton<IidManager>::Get ()->AddDeprecatedTraceSource (m_tid, oldName, oldClass, msg);
858
  return *this;
859
}
860
753
bool 
861
bool 
754
TypeId::SetAttributeInitialValue(uint32_t i, 
862
TypeId::SetAttributeInitialValue(uint32_t i, 
755
                                 Ptr<const AttributeValue> initialValue)
863
                                 Ptr<const AttributeValue> initialValue)
 Lines 783-794   TypeId::GetAttributeN (void) const Link Here 
783
  uint32_t n = Singleton<IidManager>::Get ()->GetAttributeN (m_tid);
891
  uint32_t n = Singleton<IidManager>::Get ()->GetAttributeN (m_tid);
784
  return n;
892
  return n;
785
}
893
}
894
895
uint32_t
896
TypeId::GetDeprecatedAttributeN (void) const
897
{
898
  NS_LOG_FUNCTION (this);
899
  uint32_t n = Singleton<IidManager>::Get ()->GetDeprecatedAttributeN (m_tid);
900
  return n;
901
}
786
struct TypeId::AttributeInformation 
902
struct TypeId::AttributeInformation 
787
TypeId::GetAttribute(uint32_t i) const
903
TypeId::GetAttribute(uint32_t i) const
788
{
904
{
789
  NS_LOG_FUNCTION (this << i);
905
  NS_LOG_FUNCTION (this << i);
790
  return Singleton<IidManager>::Get ()->GetAttribute(m_tid, i);
906
  return Singleton<IidManager>::Get ()->GetAttribute(m_tid, i);
791
}
907
}
908
909
struct TypeId::DeprecatedAttributeInformation
910
TypeId::GetDeprecatedAttribute (uint32_t i) const
911
{
912
  NS_LOG_FUNCTION (this << i);
913
  return Singleton<IidManager>::Get ()->GetDeprecatedAttribute (m_tid, i);
914
}
915
792
std::string 
916
std::string 
793
TypeId::GetAttributeFullName (uint32_t i) const
917
TypeId::GetAttributeFullName (uint32_t i) const
794
{
918
{
 Lines 803-808   TypeId::GetTraceSourceN (void) const Link Here 
803
  NS_LOG_FUNCTION (this);
927
  NS_LOG_FUNCTION (this);
804
  return Singleton<IidManager>::Get ()->GetTraceSourceN (m_tid);
928
  return Singleton<IidManager>::Get ()->GetTraceSourceN (m_tid);
805
}
929
}
930
931
uint32_t
932
TypeId::GetDeprecatedTraceSourceN (void) const
933
{
934
  NS_LOG_FUNCTION (this);
935
  return Singleton<IidManager>::Get ()->GetDeprecatedTraceSourceN (m_tid);
936
}
937
806
struct TypeId::TraceSourceInformation 
938
struct TypeId::TraceSourceInformation 
807
TypeId::GetTraceSource(uint32_t i) const
939
TypeId::GetTraceSource(uint32_t i) const
808
{
940
{
 Lines 810-815   TypeId::GetTraceSource(uint32_t i) const Link Here 
810
  return Singleton<IidManager>::Get ()->GetTraceSource(m_tid, i);
942
  return Singleton<IidManager>::Get ()->GetTraceSource(m_tid, i);
811
}
943
}
812
944
945
struct TypeId::DeprecatedTraceSourceInformation
946
TypeId::GetDeprecatedTraceSource (uint32_t i) const
947
{
948
  NS_LOG_FUNCTION (this << i);
949
  return Singleton<IidManager>::Get ()->GetDeprecatedTraceSource (m_tid, i);
950
}
951
813
TypeId 
952
TypeId 
814
TypeId::AddTraceSource (std::string name,
953
TypeId::AddTraceSource (std::string name,
815
                        std::string help,
954
                        std::string help,
 Lines 856-861   TypeId::LookupTraceSourceByName (std::string name) const Link Here 
856
        }
995
        }
857
      nextTid = tid.GetParent ();
996
      nextTid = tid.GetParent ();
858
    } while (nextTid != tid);
997
    } while (nextTid != tid);
998
999
  nextTid = *this;
1000
  do {
1001
      tid = nextTid;
1002
      for (uint32_t i = 0; i < tid.GetDeprecatedTraceSourceN (); ++i)
1003
        {
1004
          struct TypeId::DeprecatedTraceSourceInformation tmp = tid.GetDeprecatedTraceSource (i);
1005
          if (tmp.oldName == name)
1006
            {
1007
              NS_LOG_UNCOND ("ATTENTION: Deprecated attribute " << name <<
1008
                             " in class " << tmp.oldClass << "." << tmp.msg);
1009
              return 0;
1010
            }
1011
        }
1012
      nextTid = tid.GetParent ();
1013
    } while (nextTid != tid);
1014
859
  return 0;
1015
  return 0;
860
}
1016
}
861
1017
(-)a/src/core/model/type-id.h (-1 / +66 lines)
 Lines 81-86   public: Link Here 
81
    std::string callback;
81
    std::string callback;
82
    Ptr<const TraceSourceAccessor> accessor;
82
    Ptr<const TraceSourceAccessor> accessor;
83
  };
83
  };
84
  struct DeprecatedAttributeInformation {
85
    std::string oldName;
86
    std::string oldClass;
87
    std::string msg;
88
  };
89
  struct DeprecatedTraceSourceInformation {
90
    std::string oldName;
91
    std::string oldClass;
92
    std::string msg;
93
  };
84
94
85
  /**
95
  /**
86
   * Type of hash values
96
   * Type of hash values
 Lines 190-201   public: Link Here 
190
   * \returns the number of attributes associated to this TypeId
200
   * \returns the number of attributes associated to this TypeId
191
   */
201
   */
192
  uint32_t GetAttributeN (void) const;
202
  uint32_t GetAttributeN (void) const;
203
204
  /**
205
   * \return the number of deprecated attributes associated to this TypeId
206
   */
207
  uint32_t GetDeprecatedAttributeN (void) const;
208
193
  /**
209
  /**
194
   * \param i index into attribute array
210
   * \param i index into attribute array
195
   * \returns the information associated to attribute whose 
211
   * \returns the information associated to attribute whose 
196
   *          index is i.
212
   *          index is i.
197
   */
213
   */
198
  struct TypeId::AttributeInformation GetAttribute(uint32_t i) const;
214
  struct TypeId::AttributeInformation GetAttribute(uint32_t i) const;
215
216
  /**
217
   * \param i index into deprecated attribute array
218
   * \returns the information associated to attribute whose
219
   *          index is i.
220
   */
221
  struct TypeId::DeprecatedAttributeInformation GetDeprecatedAttribute (uint32_t i) const;
222
199
  /**
223
  /**
200
   * \param i index into attribute array
224
   * \param i index into attribute array
201
   * \returns the full name associated to the attribute whose
225
   * \returns the full name associated to the attribute whose
 Lines 220-225   public: Link Here 
220
   * \returns the number of trace sources defined in this TypeId.
244
   * \returns the number of trace sources defined in this TypeId.
221
   */
245
   */
222
  uint32_t GetTraceSourceN (void) const;
246
  uint32_t GetTraceSourceN (void) const;
247
248
  /**
249
   * \returns the number of deprecated trace sources defined in this TypeId.
250
   */
251
  uint32_t GetDeprecatedTraceSourceN (void) const;
252
223
  /**
253
  /**
224
   * \param i index into trace source array.
254
   * \param i index into trace source array.
225
   * \returns detailed information about the requested trace source.
255
   * \returns detailed information about the requested trace source.
 Lines 227-232   public: Link Here 
227
  struct TypeId::TraceSourceInformation GetTraceSource(uint32_t i) const;
257
  struct TypeId::TraceSourceInformation GetTraceSource(uint32_t i) const;
228
258
229
  /**
259
  /**
260
   * \param i index into deprecated trace source array.
261
   * \returns detailed information about the requested deprecated trace source.
262
   */
263
  struct TypeId::DeprecatedTraceSourceInformation GetDeprecatedTraceSource (uint32_t i) const;
264
265
  /**
230
   * \param tid the TypeId of the base class.
266
   * \param tid the TypeId of the base class.
231
   * \return this TypeId instance.
267
   * \return this TypeId instance.
232
   *
268
   *
 Lines 296-301   public: Link Here 
296
                       Ptr<const AttributeChecker> checker);
332
                       Ptr<const AttributeChecker> checker);
297
333
298
  /**
334
  /**
335
   * \brief Deprecate an attribute by printing a message to the user
336
   *
337
   * If the user tries to attach to the attribute declared with this method,
338
   * a warning message is printed, indicating where he/she can found the new
339
   * attribute class and name.
340
   *
341
   * \param oldName old name of the attribute
342
   * \param oldClass old class of the attribute
343
   * \param msg optional message to be printed
344
   * \return this TypeId instance
345
   */
346
  TypeId DeprecateAttribute (const std::string &oldName, const std::string &oldClass,
347
                             const std::string &msg);
348
349
  /**
299
   * \param i the attribute to manipulate
350
   * \param i the attribute to manipulate
300
   * \param initialValue the new initial value to use for this attribute.
351
   * \param initialValue the new initial value to use for this attribute.
301
   * \returns true if the call was successfuly, false otherwise.
352
   * \returns true if the call was successfuly, false otherwise.
 Lines 352-357   public: Link Here 
352
                         Ptr<const TraceSourceAccessor> accessor,
403
                         Ptr<const TraceSourceAccessor> accessor,
353
                         std::string callback);
404
                         std::string callback);
354
405
406
  /**
407
   * \brief Deprecate a trace source by printing a message to the user
408
   *
409
   * If the user tries to attach to the trace source declared with this method,
410
   * a warning message is printed, indicating where he/she can found the new
411
   * attribute class and name.
412
   *
413
   * \param oldName old name of the trace source
414
   * \param oldClass old class of the trace source
415
   * \param msg optional message to print to the user
416
   * \return this TypeId instance
417
   */
418
  TypeId DeprecateTraceSource (const std::string &oldName, const std::string &oldClass,
419
                               const std::string &msg);
420
355
  TypeId HideFromDocumentation (void);
421
  TypeId HideFromDocumentation (void);
356
422
357
  /**
423
  /**
358
- 

Return to bug 2149