author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Fri, 26 Oct 2007 14:14:20 +0200 | |
changeset 2036 | 0cb3c7151e89 |
parent 1696 | 0de65f4c8c43 |
permissions | -rw-r--r-- |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
45
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2006 INRIA |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#include "scheduler-factory.h" |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
21 |
#include "ns3/assert.h" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
22 |
#include "ns3/fatal-error.h" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
23 |
#include "ns3/default-value.h" |
45
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
|
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
namespace ns3 { |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
|
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
SchedulerFactory::~SchedulerFactory () |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
{} |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
Scheduler * |
122
6b8f1eda5c57
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
110
diff
changeset
|
31 |
SchedulerFactory::Create (void) const |
45
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
{ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
33 |
return DoCreate (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
34 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
35 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
36 |
Scheduler * |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
37 |
SchedulerFactory::CreateDefault (void) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
38 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
39 |
NS_ASSERT_MSG (!GetList ()->empty (), "No Scheduler factory registered"); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
40 |
std::string defaultValue = GetDefault ()->GetValue (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
41 |
for (List::const_iterator i = GetList ()->begin (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
42 |
i != GetList ()->end (); i++) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
43 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
44 |
if (i->second == defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
45 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
46 |
return i->first->Create (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
47 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
48 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
49 |
NS_ASSERT (false); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
50 |
// quiet compiler |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
51 |
return 0; |
45
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
} |
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
54 |
Scheduler * |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
55 |
SchedulerFactory::Create (const std::string &name) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
56 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
57 |
for (List::iterator i = GetList ()->begin (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
58 |
i != GetList ()->end (); i++) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
59 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
60 |
if (i->second == name) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
61 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
62 |
return i->first->Create (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
63 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
64 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
65 |
NS_ASSERT_MSG (false, "Tried to create non-existant scheduler: " << name); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
66 |
// quiet compiler. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
67 |
return 0; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
68 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
69 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
70 |
void |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
71 |
SchedulerFactory::AddDefault (const SchedulerFactory *factory, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
72 |
const std::string &name) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
73 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
74 |
GetDefault ()->AddDefaultValue (name); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
75 |
GetList ()->push_back (std::make_pair (factory, name)); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
76 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
77 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
78 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
79 |
void |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
80 |
SchedulerFactory::Add (const SchedulerFactory *factory, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
81 |
const std::string &name) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
82 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
83 |
GetDefault ()->AddPossibleValue (name); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
84 |
GetList ()->push_back (std::make_pair (factory, name)); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
85 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
86 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
87 |
StringEnumDefaultValue * |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
88 |
SchedulerFactory::GetDefault (void) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
89 |
{ |
692
3f03c8c4f381
uniformize the DefaultValues used by the Event Schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
439
diff
changeset
|
90 |
static StringEnumDefaultValue value ("Scheduler", "Event Scheduler algorithm"); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
91 |
return &value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
92 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
93 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
94 |
SchedulerFactory::List * |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
95 |
SchedulerFactory::GetList (void) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
96 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
97 |
static SchedulerFactory::List list; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
98 |
return &list; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
99 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
100 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
150
diff
changeset
|
101 |
|
45
f963078c6e95
enable user-provided schedulers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
102 |
}; // namespace ns3 |