A Discrete-Event Network Simulator
API
config.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  */
19 #ifndef CONFIG_H
20 #define CONFIG_H
21 
22 #include "ptr.h"
23 
24 #include <string>
25 #include <vector>
26 
33 namespace ns3
34 {
35 
36 class AttributeValue;
37 class Object;
38 class CallbackBase;
39 
50 namespace Config
51 {
52 
58 void Reset();
59 
70 void Set(std::string path, const AttributeValue& value);
81 bool SetFailSafe(std::string path, const AttributeValue& value);
91 void SetDefault(std::string name, const AttributeValue& value);
101 bool SetDefaultFailSafe(std::string name, const AttributeValue& value);
109 void SetGlobal(std::string name, const AttributeValue& value);
118 bool SetGlobalFailSafe(std::string name, const AttributeValue& value);
130 void ConnectWithoutContext(std::string path, const CallbackBase& cb);
142 bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase& cb);
150 void DisconnectWithoutContext(std::string path, const CallbackBase& cb);
164 void Connect(std::string path, const CallbackBase& cb);
176 bool ConnectFailSafe(std::string path, const CallbackBase& cb);
184 void Disconnect(std::string path, const CallbackBase& cb);
185 
195 {
196  public:
198  typedef std::vector<Ptr<Object>>::const_iterator Iterator;
199  MatchContainer();
207  MatchContainer(const std::vector<Ptr<Object>>& objects,
208  const std::vector<std::string>& contexts,
209  std::string path);
210 
216 
218  {
219  return Begin();
220  }
221 
228 
230  {
231  return End();
232  }
233 
239  std::size_t GetN() const;
240 
241  std::size_t size() const
242  {
243  return GetN();
244  }
245 
251  Ptr<Object> Get(std::size_t i) const;
259  std::string GetMatchedPath(uint32_t i) const;
263  std::string GetPath() const;
264 
275  void Set(std::string name, const AttributeValue& value);
285  bool SetFailSafe(std::string name, const AttributeValue& value);
296  void Connect(std::string name, const CallbackBase& cb);
306  bool ConnectFailSafe(std::string name, const CallbackBase& cb);
317  void ConnectWithoutContext(std::string name, const CallbackBase& cb);
327  bool ConnectWithoutContextFailSafe(std::string name, const CallbackBase& cb);
336  void Disconnect(std::string name, const CallbackBase& cb);
345  void DisconnectWithoutContext(std::string name, const CallbackBase& cb);
346 
347  private:
349  std::vector<Ptr<Object>> m_objects;
351  std::vector<std::string> m_contexts;
353  std::string m_path;
354 };
355 
362 MatchContainer LookupMatches(std::string path);
363 
379 
384 std::size_t GetRootNamespaceObjectN();
385 
392 
393 } // namespace Config
394 
395 } // namespace ns3
396 
397 #endif /* CONFIG_H */
Hold a value for an Attribute.
Definition: attribute.h:70
Base class for Callback class.
Definition: callback.h:360
hold a set of objects which match a specific search string.
Definition: config.h:195
std::vector< Ptr< Object > >::const_iterator Iterator
Const iterator over the objects in this container.
Definition: config.h:198
bool SetFailSafe(std::string name, const AttributeValue &value)
Definition: config.cc:115
void Connect(std::string name, const CallbackBase &cb)
Definition: config.cc:128
void DisconnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: config.cc:187
void Set(std::string name, const AttributeValue &value)
Definition: config.cc:103
Ptr< Object > Get(std::size_t i) const
Definition: config.cc:82
void Disconnect(std::string name, const CallbackBase &cb)
Definition: config.cc:174
std::string GetMatchedPath(uint32_t i) const
Definition: config.cc:89
MatchContainer::Iterator End() const
Definition: config.cc:68
MatchContainer::Iterator begin() const
Definition: config.h:217
bool ConnectFailSafe(std::string name, const CallbackBase &cb)
Definition: config.cc:137
std::string GetPath() const
Definition: config.cc:96
bool ConnectWithoutContextFailSafe(std::string name, const CallbackBase &cb)
Definition: config.cc:161
std::size_t size() const
Definition: config.h:241
std::string m_path
The path used to perform the object matching.
Definition: config.h:353
void ConnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: config.cc:152
std::size_t GetN() const
Definition: config.cc:75
MatchContainer::Iterator end() const
Definition: config.h:229
std::vector< Ptr< Object > > m_objects
The list of objects in this container.
Definition: config.h:349
MatchContainer::Iterator Begin() const
Definition: config.cc:61
std::vector< std::string > m_contexts
The context for each object.
Definition: config.h:351
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:855
void SetGlobal(std::string name, const AttributeValue &value)
Definition: config.cc:936
bool SetFailSafe(std::string path, const AttributeValue &value)
Definition: config.cc:883
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:890
void Disconnect(std::string path, const CallbackBase &cb)
Definition: config.cc:991
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:974
MatchContainer LookupMatches(std::string path)
Definition: config.cc:998
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:967
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:950
bool ConnectFailSafe(std::string path, const CallbackBase &cb)
Definition: config.cc:984
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:1012
Ptr< Object > GetRootNamespaceObject(uint32_t i)
Definition: config.cc:1026
bool SetGlobalFailSafe(std::string name, const AttributeValue &value)
Definition: config.cc:943
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:876
void RegisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:1005
std::size_t GetRootNamespaceObjectN()
Definition: config.cc:1019
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
Definition: config.cc:900
bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase &cb)
Definition: config.cc:960
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ptr smart pointer declaration and implementation.