src/common/ascii-writer.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu Nov 12 13:01:01 2009 +0100 (2009-11-12)
changeset 5505 c0ac392289c3
parent 4711 3c9b7588ea4c
permissions -rw-r--r--
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     3  * Copyright (c) 2009 INRIA
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License version 2 as
     7  * published by the Free Software Foundation;
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    17  *
    18  * Author: Guillaume Seguin <guilla...@segu.in>
    19  */
    20 
    21 #ifndef ASCII_WRITER_H
    22 #define ASCII_WRITER_H
    23 
    24 #include <stdint.h>
    25 #include <ostream>
    26 #include "ns3/simple-ref-count.h"
    27 #include "ns3/ptr.h"
    28 
    29 namespace ns3 {
    30 
    31 class Packet;
    32 
    33 /**
    34  * \ingroup common
    35  *
    36  * \brief Ascii output
    37  */
    38 class AsciiWriter : public SimpleRefCount<AsciiWriter>
    39 {
    40 public:
    41   static Ptr<AsciiWriter> Get (std::ostream &os);
    42 
    43   enum Type {
    44     ENQUEUE,
    45     DEQUEUE,
    46     DROP,
    47     TX,
    48     RX
    49   };
    50 
    51   ~AsciiWriter (void);
    52 
    53   /**
    54    * Writes a message in the output file, checking if the files will
    55    * need to be reordered.
    56    */
    57   void WritePacket (enum Type type, std::string message, Ptr<const Packet> p);
    58 
    59 private:
    60   AsciiWriter (std::ostream *os);
    61 
    62   std::ostream *m_writer;
    63 };
    64 
    65 } // namespace ns3
    66 
    67 #endif /* ASCII_WRITER_H */