Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

BaseTrace Class Reference

#include <basetrace.h>

Inheritance diagram for BaseTrace:

Inheritance graph
[legend]
Collaboration diagram for BaseTrace:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BaseTrace ()
 ~BaseTrace ()
virtual int command (int argc, const char *const *argv)
virtual void dump ()
virtual void namdump ()
char * buffer ()
char * nbuffer ()
Tcl_Channel channel ()
void channel (Tcl_Channel ch)
Tcl_Channel namchannel ()
void namchannel (Tcl_Channel namch)
void flush (Tcl_Channel channel)
bool tagged ()
void tagged (bool tag)

Static Public Member Functions

double round (double x, double precision=PRECISION)

Protected Attributes

Tcl_Channel channel_
Tcl_Channel namChan_
char * wrk_
char * nwrk_
bool tagged_

Constructor & Destructor Documentation

BaseTrace::BaseTrace  ) 
 

Definition at line 57 of file basetrace.cc.

References nwrk_, and wrk_.

00058   : channel_(0), namChan_(0), tagged_(0) 
00059 {
00060   wrk_ = new char[1026];
00061   nwrk_ = new char[256];
00062 }

BaseTrace::~BaseTrace  ) 
 

Definition at line 64 of file basetrace.cc.

References nwrk_, and wrk_.

00065 {
00066   delete wrk_;
00067   delete nwrk_;
00068 }


Member Function Documentation

char* BaseTrace::buffer  )  [inline]
 

Definition at line 50 of file basetrace.h.

References wrk_.

Referenced by Trace::annotate(), Trace::callback(), Trace::format(), SatTrace::format(), CMUTrace::format(), CMUTrace::format_aodv(), CMUTrace::format_arp(), CMUTrace::format_dsr(), CMUTrace::format_imep(), CMUTrace::format_ip(), CMUTrace::format_mac(), CMUTrace::format_rtp(), CMUTrace::format_tcp(), CMUTrace::format_tora(), SRForwarder::handlePktWithoutSR(), MobileNode::log_energy(), AODV::log_link_broke(), AODV::log_link_del(), AODV::log_link_kept(), toraAgent::log_link_layer_feedback(), toraAgent::log_link_layer_recycle(), toraAgent::log_lnk_del(), toraAgent::log_lnk_kept(), MobileNode::log_movement(), toraAgent::log_nb_del(), imepAgent::log_neighbor_list(), toraAgent::log_recv_clr(), toraAgent::log_recv_qry(), toraAgent::log_recv_upd(), toraAgent::log_route_loop(), toraAgent::log_route_table(), toraAgent::logNbDeletedLastDN(), toraAgent::logNextHopChange(), toraAgent::logToraDest(), toraAgent::logToraNeighbor(), DequeTrace::recv(), SRForwarder::recv(), toraAgent::recvUPD(), Trace::trace(), toraAgent::trace(), RouteCache::trace(), OmniMcastAgent::trace(), imepAgent::trace(), FloodingAgent::trace(), DumbAgent::trace(), DSRAgent::trace(), CMUPriQueue::trace(), DSDV_Agent::trace(), DiffusionAgent::trace(), and TcpAgent::trace_event().

00050 { return wrk_ ; }

void BaseTrace::channel Tcl_Channel  ch  )  [inline]
 

Definition at line 54 of file basetrace.h.

References channel_.

00054 {channel_ = ch; }

Tcl_Channel BaseTrace::channel void   )  [inline]
 

Definition at line 53 of file basetrace.h.

References channel_.

Referenced by Trace::command(), and DequeTrace::recv().

00053 { return channel_; }

int BaseTrace::command int  argc,
const char *const *  argv
[virtual]
 

Definition at line 117 of file basetrace.cc.

References channel_, namChan_, and tagged().

00118 {
00119         Tcl& tcl = Tcl::instance();
00120         if (argc == 2) {
00121                 if (strcmp(argv[1], "detach") == 0) {
00122                         channel_ = 0;
00123                         namChan_ = 0;
00124                         return (TCL_OK);
00125                 }
00126                 if (strcmp(argv[1], "flush") == 0) {
00127                         if (channel_ != 0) 
00128                                 Tcl_Flush(channel_);
00129                         if (namChan_ != 0)
00130                                 Tcl_Flush(namChan_);
00131                         return (TCL_OK);
00132                 }
00133                 if (strcmp(argv[1], "tagged") == 0) {
00134                         tcl.resultf("%d", tagged());
00135                         return (TCL_OK);
00136                 }
00137         } else if (argc == 3) {
00138                 if (strcmp(argv[1], "attach") == 0) {
00139                         int mode;
00140                         const char* id = argv[2];
00141                         channel_ = Tcl_GetChannel(tcl.interp(), (char*)id,
00142                                                   &mode);
00143                         if (channel_ == 0) {
00144                                 tcl.resultf("trace: can't attach %s for writing", id);
00145                                 return (TCL_ERROR);
00146                         }
00147                         return (TCL_OK);
00148                 }
00149                 if (strcmp(argv[1], "namattach") == 0) {
00150                         int mode;
00151                         const char* id = argv[2];
00152                         namChan_ = Tcl_GetChannel(tcl.interp(), (char*)id,
00153                                                   &mode);
00154                         if (namChan_ == 0) {
00155                                 tcl.resultf("trace: can't attach %s for writing", id);
00156                                 return (TCL_ERROR);
00157                         }
00158                         return (TCL_OK);
00159                 }
00160                 if (strcmp(argv[1], "tagged") == 0) {
00161                         int tag;
00162                         if (Tcl_GetBoolean(tcl.interp(),
00163                                            (char*)argv[2], &tag) == TCL_OK) {
00164                                 tagged(tag);
00165                                 return (TCL_OK);
00166                         } else return (TCL_ERROR);
00167                 }
00168         }
00169         return (TclObject::command(argc, argv));
00170 }

Here is the call graph for this function:

void BaseTrace::dump  )  [virtual]
 

Definition at line 70 of file basetrace.cc.

References channel_, and wrk_.

Referenced by Trace::annotate(), SRForwarder::handlePktWithoutSR(), MobileNode::log_energy(), AODV::log_link_broke(), AODV::log_link_del(), AODV::log_link_kept(), toraAgent::log_link_layer_feedback(), toraAgent::log_link_layer_recycle(), toraAgent::log_lnk_del(), toraAgent::log_lnk_kept(), MobileNode::log_movement(), toraAgent::log_nb_del(), imepAgent::log_neighbor_list(), toraAgent::log_recv_clr(), toraAgent::log_recv_qry(), toraAgent::log_recv_upd(), toraAgent::log_route_loop(), toraAgent::log_route_table(), toraAgent::logNbDeletedLastDN(), toraAgent::logNextHopChange(), toraAgent::logToraDest(), toraAgent::logToraNeighbor(), DequeTrace::recv(), Trace::recv(), TraceIpMac::recv(), TraceIp::recv(), SRForwarder::recv(), SatDequeTrace::recv(), CMUTrace::recv(), Trace::recvOnly(), toraAgent::recvUPD(), Trace::trace(), toraAgent::trace(), RouteCache::trace(), OmniMcastAgent::trace(), imepAgent::trace(), FloodingAgent::trace(), DumbAgent::trace(), DSRAgent::trace(), CMUPriQueue::trace(), DSDV_Agent::trace(), DiffusionAgent::trace(), EventTrace::trace(), and SatTrace::traceonly().

00071 {
00072         int n = strlen(wrk_);
00073         if ((n > 0) && (channel_ != 0)) {
00074                 /*
00075                  * tack on a newline (temporarily) instead
00076                  * of doing two writes
00077                  */
00078                 wrk_[n] = '\n';
00079                 wrk_[n + 1] = 0;
00080                 (void)Tcl_Write(channel_, wrk_, n + 1);
00081                 //Tcl_Flush(channel_);
00082                 wrk_[n] = 0;
00083         }
00084 
00085         //  if (callback_) {
00086 //              Tcl& tcl = Tcl::instance();
00087 //              tcl.evalf("%s handle { %s }", name(), wrk_);
00088 //      }
00089 }

void BaseTrace::flush Tcl_Channel  channel  )  [inline]
 

Definition at line 59 of file basetrace.h.

Referenced by Trace::command().

00059 { Tcl_Flush(channel); }

void BaseTrace::namchannel Tcl_Channel  namch  )  [inline]
 

Definition at line 57 of file basetrace.h.

References namChan_.

00057 {namChan_ = namch; }

Tcl_Channel BaseTrace::namchannel  )  [inline]
 

Definition at line 56 of file basetrace.h.

References namChan_.

Referenced by Trace::command(), Trace::format(), SatTrace::format(), CMUTrace::format(), DequeTrace::recv(), and SatDequeTrace::recv().

00056 { return namChan_; }

void BaseTrace::namdump  )  [virtual]
 

Definition at line 91 of file basetrace.cc.

References namChan_, and nwrk_.

Referenced by Trace::annotate(), CMUTrace::nam_format(), DequeTrace::recv(), Trace::recv(), SatDequeTrace::recv(), Trace::recvOnly(), EventTrace::trace(), and Trace::write_nam_trace().

00092 {
00093         int n = 0;
00094 
00095         /* Otherwise nwrk_ isn't initialized */
00096         if (namChan_ != 0)
00097                 n = strlen(nwrk_);
00098         if ((n > 0) && (namChan_ != 0)) {
00099                 /*
00100                  * tack on a newline (temporarily) instead
00101                  * of doing two writes
00102                  */
00103                 nwrk_[n] = '\n';
00104                 nwrk_[n + 1] = 0;
00105                 (void)Tcl_Write(namChan_, nwrk_, n + 1);
00106                 //Tcl_Flush(channel_);
00107                 nwrk_[n] = 0;
00108         }
00109 }

char* BaseTrace::nbuffer  )  [inline]
 

Definition at line 51 of file basetrace.h.

References nwrk_.

Referenced by Trace::annotate(), Trace::format(), SatTrace::format(), CMUTrace::nam_format(), DequeTrace::recv(), SatDequeTrace::recv(), TcpAgent::trace_event(), and Trace::write_nam_trace().

00051 {return nwrk_; }

double BaseTrace::round double  x,
double  precision = PRECISION
[inline, static]
 

Definition at line 72 of file basetrace.h.

Referenced by Trace::annotate(), HttpApp::command(), SatGeometry::distance(), Trace::format(), SatTrace::format(), HttpApp::log(), SatGeometry::propdelay(), Trace::trace(), and TcpAgent::trace_event().

00072                                                                    {
00073                 return (double)floor(x*precision + 0.5)/precision;
00074         }

void BaseTrace::tagged bool  tag  )  [inline]
 

Definition at line 77 of file basetrace.h.

References tagged_.

00077 { tagged_ = tag; }

bool BaseTrace::tagged  )  [inline]
 

Definition at line 76 of file basetrace.h.

References tagged_.

Referenced by Trace::annotate(), Trace::command(), command(), Trace::format(), SatTrace::format(), CMUTrace::format_aodv(), CMUTrace::format_arp(), CMUTrace::format_dsr(), CMUTrace::format_imep(), CMUTrace::format_ip(), CMUTrace::format_mac(), CMUTrace::format_rtp(), CMUTrace::format_tcp(), CMUTrace::format_tora(), CMUPriQueue::log_stats(), DequeTrace::recv(), and Trace::trace().

00076 { return tagged_; }


Member Data Documentation

Tcl_Channel BaseTrace::channel_ [protected]
 

Definition at line 80 of file basetrace.h.

Referenced by channel(), command(), and dump().

Tcl_Channel BaseTrace::namChan_ [protected]
 

Definition at line 81 of file basetrace.h.

Referenced by command(), namchannel(), and namdump().

char* BaseTrace::nwrk_ [protected]
 

Definition at line 83 of file basetrace.h.

Referenced by BaseTrace(), namdump(), nbuffer(), and ~BaseTrace().

bool BaseTrace::tagged_ [protected]
 

Definition at line 84 of file basetrace.h.

Referenced by tagged().

char* BaseTrace::wrk_ [protected]
 

Definition at line 82 of file basetrace.h.

Referenced by BaseTrace(), buffer(), dump(), and ~BaseTrace().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 12:33:38 2004 for NS2.26SourcesOriginal by doxygen 1.3.3