A Discrete-Event Network Simulator
API
data-collection-object.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Bucknell University
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  * Authors: Tiago G. Rodrigues (tgr002@bucknell.edu)
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/string.h"
23 #include "ns3/boolean.h"
24 
25 #include "data-collection-object.h"
26 
27 namespace ns3 {
28 
29 NS_LOG_COMPONENT_DEFINE ("DataCollectionObject");
30 
31 NS_OBJECT_ENSURE_REGISTERED (DataCollectionObject);
32 
33 TypeId
35 {
36  static TypeId tid = TypeId ("ns3::DataCollectionObject")
37  .SetParent<Object> ()
38  .SetGroupName ("Stats")
39  .AddConstructor<DataCollectionObject> ()
40  .AddAttribute ( "Name",
41  "Object's name",
43  .AddAttribute ( "Enabled",
44  "Object's enabled status",
46  ;
47  return tid;
48 }
49 
51 {
52 }
53 
55 {
56  NS_LOG_FUNCTION (this);
57 }
58 
59 bool
61 {
62  return m_enabled;
63 }
64 
65 std::string
67 {
68  return m_name;
69 }
70 
71 void
73 {
74  NS_LOG_FUNCTION (this << name);
75  for (size_t pos = name.find (" "); pos != std::string::npos; pos = name.find (" ", pos + 1, 1))
76  {
77  name[pos] = '_';
78  }
79 
80  m_name = name;
81 }
82 
83 void
85 {
86  NS_LOG_FUNCTION (this);
87  m_enabled = true;
88 }
89 
90 void
92 {
93  NS_LOG_FUNCTION (this);
94  m_enabled = false;
95 }
96 
97 } // namespace ns3
void Enable(void)
Set the status of an individual object.
Ptr< const AttributeChecker > MakeStringChecker(void)
Definition: string.cc:30
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Base class for data collection framework objects.
AttributeValue implementation for Boolean.
Definition: boolean.h:36
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Hold variables of type string.
Definition: string.h:41
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:84
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
virtual bool IsEnabled(void) const
Check the status of an individual object.
std::string m_name
Name of the object within the data collection framework.
static TypeId GetTypeId()
Get the type ID.
bool m_enabled
Object&#39;s activation state.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Disable(void)
Unset the status of an individual object.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
void SetName(std::string name)
Set the object&#39;s name. All spaces are replaced by underscores.
A base class which provides memory management and object aggregation.
Definition: object.h:87
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: string.h:42
std::string GetName(void) const
Get the object&#39;s name.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915