src/common/trace-container.cc
changeset 53 ae406f4957d5
parent 52 72a52d59ee9f
child 54 f860e6f94787
equal deleted inserted replaced
52:72a52d59ee9f 53:ae406f4957d5
    34 	m_siList.erase (m_siList.begin (), m_siList.end ());
    34 	m_siList.erase (m_siList.begin (), m_siList.end ());
    35 	m_fList.erase (m_fList.begin (), m_fList.end ());
    35 	m_fList.erase (m_fList.begin (), m_fList.end ());
    36 }
    36 }
    37 
    37 
    38 void 
    38 void 
    39 TraceContainer::set_ui_variable_callback (char const *name, Callback<void,uint64_t, uint64_t> callback)
    39 TraceContainer::setUiVariableCallback (char const *name, Callback<void,uint64_t, uint64_t> callback)
    40 {
    40 {
    41 	for (UiListI i = m_uiList.begin (); i != m_uiList.end (); i++) {
    41 	for (UiListI i = m_uiList.begin (); i != m_uiList.end (); i++) {
    42 		if ((*i).second == name) {
    42 		if ((*i).second == name) {
    43 			(*i).first->set_callback (callback);
    43 			(*i).first->setCallback (callback);
    44 			return;
    44 			return;
    45 		}
    45 		}
    46 	}
    46 	}
    47 	assert (false);
    47 	assert (false);
    48 }
    48 }
    49 void 
    49 void 
    50 TraceContainer::set_si_variable_callback (char const *name, Callback<void,int64_t, int64_t> callback)
    50 TraceContainer::setSiVariableCallback (char const *name, Callback<void,int64_t, int64_t> callback)
    51 {
    51 {
    52 	for (SiListI i = m_siList.begin (); i != m_siList.end (); i++) {
    52 	for (SiListI i = m_siList.begin (); i != m_siList.end (); i++) {
    53 		if ((*i).second == name) {
    53 		if ((*i).second == name) {
    54 			(*i).first->set_callback (callback);
    54 			(*i).first->setCallback (callback);
    55 			return;
    55 			return;
    56 		}
    56 		}
    57 	}
    57 	}
    58 	assert (false);
    58 	assert (false);
    59 }
    59 }
    60 void 
    60 void 
    61 TraceContainer::set_f_variable_callback (char const *name, Callback<void,double, double> callback)
    61 TraceContainer::setFVariableCallback (char const *name, Callback<void,double, double> callback)
    62 {
    62 {
    63 	assert (false);
    63 	assert (false);
    64 }
    64 }
    65 void 
    65 void 
    66 TraceContainer::set_stream (char const *name, std::ostream *os)
    66 TraceContainer::setStream (char const *name, std::ostream *os)
    67 {
    67 {
    68 	for (StreamTracerListI i = m_traceStreamList.begin (); i != m_traceStreamList.end (); i++) {
    68 	for (StreamTracerListI i = m_traceStreamList.begin (); i != m_traceStreamList.end (); i++) {
    69 		if ((*i).second == name) {
    69 		if ((*i).second == name) {
    70 			(*i).first->set_stream (os);
    70 			(*i).first->setStream (os);
    71 			return;
    71 			return;
    72 		}
    72 		}
    73 	}
    73 	}
    74 	assert (false);
    74 	assert (false);
    75 }
    75 }
    76 
    76 
    77 void 
    77 void 
    78 TraceContainer::register_ui_variable (char const *name, UiVariableTracerBase *var)
    78 TraceContainer::registerUiVariable (char const *name, UiVariableTracerBase *var)
    79 {
    79 {
    80 	// ensure unicity
    80 	// ensure unicity
    81 	for (UiListI i = m_uiList.begin (); i != m_uiList.end (); i++) {
    81 	for (UiListI i = m_uiList.begin (); i != m_uiList.end (); i++) {
    82 		if (i->second == name) {
    82 		if (i->second == name) {
    83 			m_uiList.erase (i);
    83 			m_uiList.erase (i);
    85 		}
    85 		}
    86 	}
    86 	}
    87 	m_uiList.push_back (std::make_pair (var, name));
    87 	m_uiList.push_back (std::make_pair (var, name));
    88 }
    88 }
    89 void 
    89 void 
    90 TraceContainer::register_si_variable (char const *name, SiVariableTracerBase *var)
    90 TraceContainer::registerSiVariable (char const *name, SiVariableTracerBase *var)
    91 {
    91 {
    92 	// ensure unicity
    92 	// ensure unicity
    93 	for (SiListI i = m_siList.begin (); i != m_siList.end (); i++) {
    93 	for (SiListI i = m_siList.begin (); i != m_siList.end (); i++) {
    94 		if (i->second == name) {
    94 		if (i->second == name) {
    95 			m_siList.erase (i);
    95 			m_siList.erase (i);
    97 		}
    97 		}
    98 	}
    98 	}
    99 	m_siList.push_back (std::make_pair (var, name));
    99 	m_siList.push_back (std::make_pair (var, name));
   100 }
   100 }
   101 void 
   101 void 
   102 TraceContainer::register_f_variable (char const *name, FVariableTracerBase *var)
   102 TraceContainer::registerFVariable (char const *name, FVariableTracerBase *var)
   103 {
   103 {
   104 	assert (false);
   104 	assert (false);
   105 }
   105 }
   106 
   106 
   107 void 
   107 void 
   108 TraceContainer::register_stream (char const *name, StreamTracer *stream)
   108 TraceContainer::registerStream (char const *name, StreamTracer *stream)
   109 {
   109 {
   110 	// ensure unicity
   110 	// ensure unicity
   111 	for (StreamTracerListI i = m_traceStreamList.begin (); i != m_traceStreamList.end (); i++) {
   111 	for (StreamTracerListI i = m_traceStreamList.begin (); i != m_traceStreamList.end (); i++) {
   112 		if (i->second == name) {
   112 		if (i->second == name) {
   113 			m_traceStreamList.erase (i);
   113 			m_traceStreamList.erase (i);
   117 	m_traceStreamList.push_back (std::make_pair (stream,name));
   117 	m_traceStreamList.push_back (std::make_pair (stream,name));
   118 
   118 
   119 }
   119 }
   120 
   120 
   121 void 
   121 void 
   122 TraceContainer::register_callback (char const *name, CallbackTracerBase *tracer)
   122 TraceContainer::registerCallback (char const *name, CallbackTracerBase *tracer)
   123 {
   123 {
   124 	for (CallbackListI i = m_callbackList.begin (); i != m_callbackList.end (); i++) {
   124 	for (CallbackListI i = m_callbackList.begin (); i != m_callbackList.end (); i++) {
   125 		if (i->second == name) {
   125 		if (i->second == name) {
   126 			m_callbackList.erase (i);
   126 			m_callbackList.erase (i);
   127 			break;
   127 			break;
   135 
   135 
   136 }; // namespace ns3
   136 }; // namespace ns3
   137 
   137 
   138 #include <iostream>
   138 #include <iostream>
   139 void 
   139 void 
   140 ns3::TraceContainer::print_debug (void)
   140 ns3::TraceContainer::printDebug (void)
   141 {
   141 {
   142 	if (!m_uiList.empty ()) {
   142 	if (!m_uiList.empty ()) {
   143 		std::cout << "ui var: " << std::endl;
   143 		std::cout << "ui var: " << std::endl;
   144 		for (UiListI i = m_uiList.begin (); i != m_uiList.end (); i++) {
   144 		for (UiListI i = m_uiList.begin (); i != m_uiList.end (); i++) {
   145 			std::cout << "    \"" << (*i).second << "\""<<std::endl;
   145 			std::cout << "    \"" << (*i).second << "\""<<std::endl;