A Discrete-Event Network Simulator
API
config.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef CONFIG_H
21 #define CONFIG_H
22 
23 #include "ptr.h"
24 #include <string>
25 #include <vector>
26 
33 namespace ns3 {
34 
35 class AttributeValue;
36 class Object;
37 class CallbackBase;
38 
49 namespace Config {
50 
56 void Reset (void);
57 
68 void Set (std::string path, const AttributeValue &value);
79 bool SetFailSafe (std::string path, const AttributeValue &value);
89 void SetDefault (std::string name, const AttributeValue &value);
99 bool SetDefaultFailSafe (std::string name, const AttributeValue &value);
107 void SetGlobal (std::string name, const AttributeValue &value);
116 bool SetGlobalFailSafe (std::string name, const AttributeValue &value);
128 void ConnectWithoutContext (std::string path, const CallbackBase &cb);
140 bool ConnectWithoutContextFailSafe (std::string path, const CallbackBase &cb);
148 void DisconnectWithoutContext (std::string path, const CallbackBase &cb);
162 void Connect (std::string path, const CallbackBase &cb);
174 bool ConnectFailSafe (std::string path, const CallbackBase &cb);
182 void Disconnect (std::string path, const CallbackBase &cb);
183 
193 {
194 public:
196  typedef std::vector<Ptr<Object> >::const_iterator Iterator;
197  MatchContainer ();
205  MatchContainer (const std::vector<Ptr<Object> > &objects,
206  const std::vector<std::string> &contexts,
207  std::string path);
208 
213  MatchContainer::Iterator Begin (void) const;
214  MatchContainer::Iterator begin (void) const { return Begin (); }
220  MatchContainer::Iterator End (void) const;
221  MatchContainer::Iterator end (void) const { return End (); }
227  std::size_t GetN (void) const;
228  std::size_t size (void) const { return GetN (); }
234  Ptr<Object> Get (std::size_t i) const;
242  std::string GetMatchedPath (uint32_t i) const;
246  std::string GetPath (void) const;
247 
258  void Set (std::string name, const AttributeValue &value);
268  bool SetFailSafe (std::string name, const AttributeValue &value);
279  void Connect (std::string name, const CallbackBase &cb);
289  bool ConnectFailSafe (std::string name, const CallbackBase &cb);
300  void ConnectWithoutContext (std::string name, const CallbackBase &cb);
310  bool ConnectWithoutContextFailSafe (std::string name, const CallbackBase &cb);
319  void Disconnect (std::string name, const CallbackBase &cb);
328  void DisconnectWithoutContext (std::string name, const CallbackBase &cb);
329 
330 private:
332  std::vector<Ptr<Object> > m_objects;
334  std::vector<std::string> m_contexts;
336  std::string m_path;
337 };
338 
345 MatchContainer LookupMatches (std::string path);
346 
362 
367 std::size_t GetRootNamespaceObjectN (void);
368 
375 
376 } // namespace Config
377 
378 } // namespace ns3
379 
380 #endif /* CONFIG_H */
Hold a value for an Attribute.
Definition: attribute.h:69
Base class for Callback class.
Definition: callback.h:1196
hold a set of objects which match a specific search string.
Definition: config.h:193
std::vector< Ptr< Object > >::const_iterator Iterator
Const iterator over the objects in this container.
Definition: config.h:196
MatchContainer::Iterator end(void) const
Definition: config.h:221
MatchContainer::Iterator begin(void) const
Definition: config.h:214
bool SetFailSafe(std::string name, const AttributeValue &value)
Definition: config.cc:105
std::size_t size(void) const
Definition: config.h:228
void Connect(std::string name, const CallbackBase &cb)
Definition: config.cc:117
void DisconnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: config.cc:171
void Set(std::string name, const AttributeValue &value)
Definition: config.cc:94
Ptr< Object > Get(std::size_t i) const
Definition: config.cc:75
void Disconnect(std::string name, const CallbackBase &cb)
Definition: config.cc:159
std::string GetPath(void) const
Definition: config.cc:87
MatchContainer::Iterator End(void) const
Definition: config.cc:63
std::string GetMatchedPath(uint32_t i) const
Definition: config.cc:81
bool ConnectFailSafe(std::string name, const CallbackBase &cb)
Definition: config.cc:125
std::size_t GetN(void) const
Definition: config.cc:69
bool ConnectWithoutContextFailSafe(std::string name, const CallbackBase &cb)
Definition: config.cc:147
std::string m_path
The path used to perform the object matching.
Definition: config.h:336
void ConnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: config.cc:139
std::vector< Ptr< Object > > m_objects
The list of objects in this container.
Definition: config.h:332
MatchContainer::Iterator Begin(void) const
Definition: config.cc:57
std::vector< std::string > m_contexts
The context for each object.
Definition: config.h:334
void SetGlobal(std::string name, const AttributeValue &value)
Definition: config.cc:891
bool SetFailSafe(std::string path, const AttributeValue &value)
Definition: config.cc:844
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:820
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
void Disconnect(std::string path, const CallbackBase &cb)
Definition: config.cc:935
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
MatchContainer LookupMatches(std::string path)
Definition: config.cc:940
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:914
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:901
bool ConnectFailSafe(std::string path, const CallbackBase &cb)
Definition: config.cc:929
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:952
Ptr< Object > GetRootNamespaceObject(uint32_t i)
Definition: config.cc:964
bool SetGlobalFailSafe(std::string name, const AttributeValue &value)
Definition: config.cc:896
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:839
void RegisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:946
std::size_t GetRootNamespaceObjectN(void)
Definition: config.cc:958
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
Definition: config.cc:857
bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase &cb)
Definition: config.cc:909
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ptr smart pointer declaration and implementation.