1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2008 INRIA
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;
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.
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
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
34 * \brief Configuration of simulation parameters and tracing
40 * \param path a path to match attributes.
41 * \param value the value to set in all matching attributes.
43 * This function will attempt to find attributes which
44 * match the input path and will then set their value to the input
47 void Set (std::string path, const AttributeValue &value);
49 * \param name the full name of the attribute
50 * \param value the value to set.
52 * This method overrides the initial value of the
53 * matching attribute. This method cannot fail: it will
54 * crash if the input attribute name or value is invalid.
56 void SetDefault (std::string name, const AttributeValue &value);
58 * \param name the full name of the attribute
59 * \param value the value to set.
60 * \returns true if the value was set successfully, false otherwise.
62 * This method overrides the initial value of the
65 bool SetDefaultFailSafe (std::string name, const AttributeValue &value);
67 * \param name the name of the requested GlobalValue.
68 * \param value the value to set
70 * This method is equivalent to GlobalValue::Bind
72 void SetGlobal (std::string name, const AttributeValue &value);
74 * \param name the name of the requested GlobalValue.
75 * \param value the value to set
77 * This method is equivalent to GlobalValue::BindFailSafe
79 bool SetGlobalFailSafe (std::string name, const AttributeValue &value);
81 * \param path a path to match trace sources.
82 * \param cb the callback to connect to the matching trace sources.
84 * This function will attempt to find all trace sources which
85 * match the input path and will then connect the input callback
88 void ConnectWithoutContext (std::string path, const CallbackBase &cb);
90 * \param path a path to match trace sources.
91 * \param cb the callback to disconnect to the matching trace sources.
93 * This function undoes the work of Config::Connect.
95 void DisconnectWithoutContext (std::string path, const CallbackBase &cb);
97 * \param path a path to match trace sources.
98 * \param cb the callback to connect to the matching trace sources.
100 * This function will attempt to find all trace sources which
101 * match the input path and will then connect the input callback
102 * to them in such a way that the callback will receive an extra
103 * context string upon trace event notification.
105 void Connect (std::string path, const CallbackBase &cb);
107 * \param path a path to match trace sources.
108 * \param cb the callback to connect to the matching trace sources.
110 * This function undoes the work of Config::ConnectWithContext.
112 void Disconnect (std::string path, const CallbackBase &cb);
115 * \brief hold a set of objects which match a specific search string.
117 * This class also allows you to perform a set of configuration operations
118 * on the set of matching objects stored in the container. Specifically,
119 * it is possible to perform bulk Connects and Sets.
124 typedef std::vector<Ptr<Object> >::const_iterator Iterator;
126 // constructor used only by implementation.
127 MatchContainer (const std::vector<Ptr<Object> > &objects,
128 const std::vector<std::string> &contexts,
132 * \returns an iterator which points to the first item in the container
134 MatchContainer::Iterator Begin (void) const;
136 * \returns an iterator which points to the last item in the container
138 MatchContainer::Iterator End (void) const;
140 * \returns the number of items in the container
142 uint32_t GetN (void) const;
144 * \param i index of item to lookup ([0,n[)
145 * \returns the item requested.
147 Ptr<Object> Get (uint32_t i) const;
149 * \param i index of item to lookup ([0,n[)
150 * \returns the fully-qualified matching path associated
151 * to the requested item.
153 * The matching patch uniquely identifies the requested object.
155 std::string GetMatchedPath (uint32_t i) const;
157 * \returns the path used to perform the object matching.
159 std::string GetPath (void) const;
162 * \param name name of attribute to set
163 * \param value value to set to the attribute
165 * Set the specified attribute value to all the objects stored in this
167 * \sa ns3::Config::Set
169 void Set (std::string name, const AttributeValue &value);
171 * \param name the name of the trace source to connect to
172 * \param cb the sink to connect to the trace source
174 * Connect the specified sink to all the objects stored in this
176 * \sa ns3::Config::Connect
178 void Connect (std::string name, const CallbackBase &cb);
180 * \param name the name of the trace source to connect to
181 * \param cb the sink to connect to the trace source
183 * Connect the specified sink to all the objects stored in this
185 * \sa ns3::Config::ConnectWithoutContext
187 void ConnectWithoutContext (std::string name, const CallbackBase &cb);
189 * \param name the name of the trace source to disconnect from
190 * \param cb the sink to disconnect from the trace source
192 * Disconnect the specified sink from all the objects stored in this
194 * \sa ns3::Config::Disconnect
196 void Disconnect (std::string name, const CallbackBase &cb);
198 * \param name the name of the trace source to disconnect from
199 * \param cb the sink to disconnect from the trace source
201 * Disconnect the specified sink from all the objects stored in this
203 * \sa ns3::Config::DisconnectWithoutContext
205 void DisconnectWithoutContext (std::string name, const CallbackBase &cb);
207 std::vector<Ptr<Object> > m_objects;
208 std::vector<std::string> m_contexts;
213 * \param path the path to perform a match against
214 * \returns a container which contains all the objects which match the input
217 MatchContainer LookupMatches (std::string path);
220 * \param obj a new root object
222 * Each root object is used during path matching as
223 * the root of the path by Config::Connect, and Config::Set.
225 void RegisterRootNamespaceObject (Ptr<Object> obj);
227 * \param obj a new root object
229 * This function undoes the work of Config::RegisterRootNamespaceObject.
231 void UnregisterRootNamespaceObject (Ptr<Object> obj);
234 * \returns the number of registered root namespace objects.
236 uint32_t GetRootNamespaceObjectN (void);
239 * \param i the index of the requested object.
240 * \returns the requested root namespace object
242 Ptr<Object> GetRootNamespaceObject (uint32_t i);
244 } // namespace Config
248 #endif /* CONFIG_H */