satellite-log.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions Ltd.
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: Frans Laakso <frans.laakso@magister.fi>
19  */
20 #ifndef SATELLITE_LOG_H
21 #define SATELLITE_LOG_H
22 
23 #include <ns3/satellite-output-fstream-string-container.h>
24 
25 #include <map>
26 
27 namespace ns3
28 {
29 
54 class SatLog : public Object
55 {
56  public:
60  typedef enum
61  {
63  LOG_INFO = 1,
65  LOG_ERROR = 3,
66  LOG_CUSTOM = 4
68 
72  typedef std::pair<LogType_t, std::string> key_t;
73 
77  typedef std::map<key_t, Ptr<SatOutputFileStreamStringContainer>> container_t;
78 
82  SatLog();
83 
87  ~SatLog();
88 
93  static TypeId GetTypeId(void);
94 
99  TypeId GetInstanceTypeId(void) const;
100 
104  void DoDispose();
105 
112  void AddToLog(LogType_t logType, std::string fileTag, std::string message);
113 
117  void Reset();
118 
119  private:
125  std::string GetFileTag(LogType_t logType);
126 
133  Ptr<SatOutputFileStreamStringContainer> CreateLog(LogType_t logType, std::string fileTag);
134 
141  Ptr<SatOutputFileStreamStringContainer> FindLog(LogType_t logType, std::string fileTag);
142 
146  void WriteToFile();
147 
152 };
153 
154 } // namespace ns3
155 
156 #endif /* SATELLITE_LOG_H */
Class for simulator output logging such as warnings and error messages.
Definition: satellite-log.h:55
SatLog()
Constructor.
void DoDispose()
Do needed dispose actions.
std::map< key_t, Ptr< SatOutputFileStreamStringContainer > > container_t
typedef for map of containers
Definition: satellite-log.h:77
void WriteToFile()
Write the contents of a container matching to the key into a file.
Ptr< SatOutputFileStreamStringContainer > CreateLog(LogType_t logType, std::string fileTag)
Function for creating a log.
std::pair< LogType_t, std::string > key_t
typedef for container key
Definition: satellite-log.h:72
std::string GetFileTag(LogType_t logType)
Function for getting the file tag for predefined log types.
void Reset()
Function for resetting the variables.
~SatLog()
Destructor.
Ptr< SatOutputFileStreamStringContainer > FindLog(LogType_t logType, std::string fileTag)
Function for finding a log based on the key.
void AddToLog(LogType_t logType, std::string fileTag, std::string message)
Function for adding a line to a specific log.
container_t m_container
Map for containers.
static TypeId GetTypeId(void)
NS-3 type id function.
TypeId GetInstanceTypeId(void) const
NS-3 instance type id function.
LogType_t
Enum for log types.
Definition: satellite-log.h:61
@ LOG_ERROR
LOG_ERROR.
Definition: satellite-log.h:65
@ LOG_WARNING
LOG_WARNING.
Definition: satellite-log.h:64
@ LOG_CUSTOM
LOG_CUSTOM.
Definition: satellite-log.h:66
@ LOG_GENERIC
LOG_GENERIC.
Definition: satellite-log.h:62
@ LOG_INFO
LOG_INFO.
Definition: satellite-log.h:63
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.