author Mathieu Lacage <>
Tue, 28 Aug 2007 09:37:10 +0200
changeset 1371 bebf690257c9
parent 1370 d5339e1c95df
child 1374 77468496f7e0
permissions -rw-r--r--
replace TraceResolver::PrintAvailable with TraceResolver::CollectSources

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 * Copyright (c) 2007 INRIA
 * All rights reserved.
 * 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
 * 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
 * Author: Mathieu Lacage <>

#include <string>
#include <list>
#include "trace-context.h"

namespace ns3 {

class CallbackBase;

 * \brief the base class which is used to recursively perform trace
 *        namespace resolution.
 * \ingroup tracing
 * Subclasses must implement the two pure virtal methods defined in 
 * this base class:
 *  - ns3::TraceResolver::Connect
 *  - ns3::TraceResolver::Disconnect.
class TraceResolver

  TraceResolver ();
  virtual ~TraceResolver ();
  void Ref (void);
  void Unref (void);

   * \param path the namespace path to resolver
   * \param cb the callback to connect to the matching namespace
   * \param context the context in which to store the trace context
   * First, extract the leading path element from the input path, and 
   * match this leading patch element against any terminal trace source
   * contained in this trace resolver.
   * Second, recursively resolve the rest of the path using other 
   * objects if there are any.
   * If there is any TraceContextElement associated to one of the matching
   * elements, it should be added to the input TraceContext.
  virtual void Connect (std::string path, CallbackBase const &cb, const TraceContext &context) = 0;
   * \param path the namespace path to resolver
   * \param cb the callback to disconnect in the matching namespace
   * This method should behave as Connect.
  virtual void Disconnect (std::string path, CallbackBase const &cb) = 0;

  class SourceCollection
    void Print (std::ostream &os) const;
    void AddUnique (std::string path, const TraceContext &context,
                    std::string help);
    void SetFlag (void);
    void ClearFlag (void);
    bool IsFlagSet (void);
    struct Source
      std::string path;
      TraceContext context;
      std::string help;
    typedef std::vector<struct Source> SourceVector;
    SourceVector m_sources;
    bool m_flag;
  virtual void CollectSources (std::string path, const TraceContext &context, 
                               SourceCollection *collection) = 0;
   * \param path a namespace path
   * \returns the initial element of the path.
   * If the input path is "/foo/...", the return
   * value is "foo".
  std::string GetElement (std::string path);
   * \param path a namespace path
   * \returns the subpath.
   * If the input path is "/foo/bar/...", the return
   * value is "/bar/...".
  std::string GetSubpath (std::string path);
  uint32_t m_count;

}//namespace ns3

#endif /* TRACE_RESOLVER_H */