attempt to document some of the internal details
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu May 08 12:40:44 2008 -0700 (21 months ago)
changeset 3059890b147e1ed6
parent 3058 31e4703e08da
child 3060 5a49ba9ad976
attempt to document some of the internal details
src/common/tag-list.h
     1.1 --- a/src/common/tag-list.h	Thu May 08 11:23:22 2008 -0700
     1.2 +++ b/src/common/tag-list.h	Thu May 08 12:40:44 2008 -0700
     1.3 @@ -28,6 +28,41 @@
     1.4  
     1.5  struct TagListData;
     1.6  
     1.7 +/**
     1.8 + * \brief keep track of the tags stored in a packet.
     1.9 + *
    1.10 + * This class is mostly private to the Packet implementation and users
    1.11 + * should never have to access it directly.
    1.12 + *
    1.13 + * \internal
    1.14 + * The implementation of this class is a bit tricky so, there are a couple
    1.15 + * of things to keep in mind here:
    1.16 + *
    1.17 + *   - it stores all tags in a single byte buffer: each tag is stored
    1.18 + *     as 4 32bit integers (TypeId, tag data size, start, end) followed 
    1.19 + *     by the tag data as generated by Tag::Serialize.
    1.20 + *
    1.21 + *   - the struct TagListData structure which contains the tag byte buffer
    1.22 + *     is shared and, thus, reference-counted. This data structure is unshared
    1.23 + *     as-needed to emulate COW semantics.
    1.24 + *
    1.25 + *   - each tag tags a unique set of bytes identified by the pair of offsets 
    1.26 + *     (start,end). These offsets are provided by Buffer::GetCurrentStartOffset
    1.27 + *     and Buffer::GetCurrentEndOffset which means that they are relative to 
    1.28 + *     the start of the 'virtual byte buffer' as explained in the documentation
    1.29 + *     for the ns3::Buffer class. Whenever the origin of the offset of the Buffer
    1.30 + *     instance associated to this TagList instance changes, the Buffer class
    1.31 + *     reports this to its container Packet class as a bool return value
    1.32 + *     in Buffer::AddAtStart and Buffer::AddAtEnd. In both cases, when this happens
    1.33 + *     the Packet class calls TagList::AddAtEnd and TagList::AddAtStart to update
    1.34 + *     the byte offsets of each tag in the TagList.
    1.35 + *
    1.36 + *   - whenever bytes are removed from the packet byte buffer, the TagList offsets 
    1.37 + *     are never updated because we rely on the fact that they will be updated in
    1.38 + *     either the next call to Packet::AddHeader or Packet::AddTrailer or when
    1.39 + *     the user iterates the tag list with Packet::GetTagIterator and 
    1.40 + *     TagIterator::Next.
    1.41 + */
    1.42  class TagList
    1.43  {
    1.44  public:
    1.45 @@ -68,16 +103,57 @@
    1.46    TagList &operator = (const TagList &o);
    1.47    ~TagList ();
    1.48  
    1.49 +  /**
    1.50 +   * \param tid the typeid of the tag added
    1.51 +   * \param bufferSize the size of the tag when its serialization will 
    1.52 +   *        be completed. Typically, the return value of Tag::GetSerializedSize
    1.53 +   * \param start offset which uniquely identifies the first byte tagged by this tag.
    1.54 +   * \param start offset which uniquely identifies the last byte tagged by this tag.
    1.55 +   * \returns a buffer which can be used to write the tag data.     
    1.56 +   *
    1.57 +   * 
    1.58 +   */
    1.59    TagBuffer Add (TypeId tid, uint32_t bufferSize, uint32_t start, uint32_t end);
    1.60  
    1.61 +  /**
    1.62 +   * \param o the other list of tags to aggregate.
    1.63 +   *
    1.64 +   * Aggregate the two lists of tags.
    1.65 +   */
    1.66    void Add (const TagList &o);
    1.67  
    1.68 +  /**
    1.69 +   * \param i points to the item to remove from this list.
    1.70 +   *
    1.71 +   * Not implemented.
    1.72 +   */
    1.73    void Remove (const Iterator &i);
    1.74    void RemoveAll (void);
    1.75  
    1.76 +  /**
    1.77 +   * \param offsetStart the offset which uniquely identifies the first data byte 
    1.78 +   *        present in the byte buffer associated to this TagList.
    1.79 +   * \param offsetEnd the offset which uniquely identifies the last data byte 
    1.80 +   *        present in the byte buffer associated to this TagList.
    1.81 +   * \returns an iterator
    1.82 +   *
    1.83 +   * The returned iterator will allow you to loop through the set of tags present
    1.84 +   * in this list: the boundaries of each tag as reported by their start and
    1.85 +   * end offsets will be included within the input offsetStart and offsetEnd.
    1.86 +   */
    1.87    TagList::Iterator Begin (uint32_t offsetStart, uint32_t offsetEnd) const;
    1.88  
    1.89 +  /**
    1.90 +   * Adjust the offsets stored internally by the adjustment delta and
    1.91 +   * make sure that all offsets are smaller than appendOffset which represents
    1.92 +   * the location where new bytes have been added to the byte buffer.
    1.93 +   */
    1.94    void AddAtEnd (int32_t adjustment, uint32_t appendOffset);
    1.95 +  /**
    1.96 +   * Adjust the offsets stored internally by the adjustment delta and
    1.97 +   * make sure that all offsets are bigger than prependOffset which represents
    1.98 +   * the location where new bytes have been added to the byte buffer.
    1.99 +   */
   1.100    void AddAtStart (int32_t adjustment, uint32_t prependOffset);
   1.101  
   1.102  private: