00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2008 Drexel University 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Joe Kopena (tjkopena@cs.drexel.edu) 00019 */ 00020 00021 #include "ns3/log.h" 00022 #include "ns3/simulator.h" 00023 00024 #include "data-calculator.h" 00025 00026 using namespace ns3; 00027 00028 NS_LOG_COMPONENT_DEFINE("DataCalculator"); 00029 00030 00031 //-------------------------------------------------------------- 00032 //---------------------------------------------- 00033 DataCalculator::DataCalculator() : 00034 m_enabled(true) 00035 { 00036 NS_LOG_FUNCTION_NOARGS(); 00037 } 00038 00039 DataCalculator::~DataCalculator() 00040 { 00041 NS_LOG_FUNCTION_NOARGS(); 00042 } 00043 00044 void 00045 DataCalculator::DoDispose(void) 00046 { 00047 NS_LOG_FUNCTION_NOARGS(); 00048 00049 Simulator::Cancel(m_startEvent); 00050 Simulator::Cancel(m_stopEvent); 00051 00052 Object::DoDispose(); 00053 // DataCalculator::DoDispose 00054 } 00055 00056 //---------------------------------------------- 00057 void 00058 DataCalculator::SetKey(const std::string key) 00059 { 00060 m_key = key; 00061 // end DataCalculator::SetKey 00062 } 00063 00064 std::string 00065 DataCalculator::GetKey() const 00066 { 00067 return m_key; 00068 // end DataCalculator::GetKey 00069 } 00070 00071 //---------------------------------------------- 00072 void 00073 DataCalculator::Enable() 00074 { 00075 m_enabled = true; 00076 // end DataCalculator::Enable 00077 } 00078 00079 void 00080 DataCalculator::Disable() 00081 { 00082 m_enabled = false; 00083 // end DataCalculator::Disable 00084 } 00085 00086 bool 00087 DataCalculator::GetEnabled() const 00088 { 00089 return m_enabled; 00090 // end DataCalculator::GetEnabled 00091 } 00092 00093 //---------------------------------------------- 00094 void 00095 DataCalculator::Start(const Time& startTime) 00096 { 00097 00098 m_startEvent = Simulator::Schedule(startTime, 00099 &DataCalculator::Enable, this); 00100 00101 // end DataCalculator::Start 00102 } 00103 00104 void 00105 DataCalculator::Stop(const Time& stopTime) 00106 { 00107 m_stopEvent = Simulator::Schedule(stopTime, 00108 &DataCalculator::Disable, this); 00109 // end DataCalculator::Stop 00110 }