author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Fri, 04 May 2007 15:04:07 +0200 | |
changeset 524 | 082ffdd8fbd7 |
parent 517 | src/node/application-list.h@702e96b8960f |
child 525 | 4a6c58f0e327 |
permissions | -rw-r--r-- |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
// -*- Mode:NS3 -*- |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
// |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
// Copyright (c) 2006 Georgia Tech Research Corporation |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
// All rights reserved. |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
// |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
// This program is free software; you can redistribute it and/or modify |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
// it under the terms of the GNU General Public License version 2 as |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
// published by the Free Software Foundation; |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
// |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
// This program is distributed in the hope that it will be useful, |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
// GNU General Public License for more details. |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
// |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
// You should have received a copy of the GNU General Public License |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
// along with this program; if not, write to the Free Software |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
// |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
19 |
// Author: George F. Riley<riley@ece.gatech.edu> |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
20 |
// |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
21 |
// Manages the list of applications associated with a node. |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
// George F. Riley, Georgia Tech, Spring 2007 |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
23 |
|
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
#ifndef __APPLICATION_LIST_H__ |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
25 |
#define __APPLICATION_LIST_H__ |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
|
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
#include "application.h" |
516
3d330150ab6d
make ApplicationList an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
498
diff
changeset
|
28 |
#include "ns3/ns-unknown.h" |
497
34d6f349478f
implement Dispose properly throughout the network stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
494
diff
changeset
|
29 |
#include <vector> |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
|
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
namespace ns3 { |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
32 |
|
516
3d330150ab6d
make ApplicationList an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
498
diff
changeset
|
33 |
class ApplicationList : public NsUnknown |
498
5d5fe14d5751
make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
497
diff
changeset
|
34 |
{ |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
public: |
516
3d330150ab6d
make ApplicationList an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
498
diff
changeset
|
36 |
static const uint32_t iid; |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
ApplicationList(Node*); |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
// Copy constructor not needed, default one is correct |
497
34d6f349478f
implement Dispose properly throughout the network stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
494
diff
changeset
|
39 |
virtual ~ApplicationList(); |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
// Inherited from Capabilty |
493
68542941fc8a
use ref/unref for Node in more cases
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
382
diff
changeset
|
41 |
virtual ApplicationList* Copy(Node*) const; |
68542941fc8a
use ref/unref for Node in more cases
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
382
diff
changeset
|
42 |
virtual void SetNode(Node *); // Sets the node for all apps |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
43 |
virtual void Add(Application*); // Add an already new'ed app |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
// Manage the list |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
45 |
template <typename T> T* AddCopy(const T& t) // Add a new application |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
{ |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
T* a = t.Copy(); |
497
34d6f349478f
implement Dispose properly throughout the network stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
494
diff
changeset
|
48 |
m_apps.push_back(a); |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
return a; |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
} |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
51 |
void Remove(Application*); // Application has finished |
497
34d6f349478f
implement Dispose properly throughout the network stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
494
diff
changeset
|
52 |
uint32_t Count() const; // Number of applications |
34d6f349478f
implement Dispose properly throughout the network stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
494
diff
changeset
|
53 |
Application* Get(uint32_t i) const; // Get app by index |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
|
517
702e96b8960f
finish Dispose -> DoDispose rework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
516
diff
changeset
|
55 |
protected: |
702e96b8960f
finish Dispose -> DoDispose rework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
516
diff
changeset
|
56 |
virtual void DoDispose (void); |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
private: |
497
34d6f349478f
implement Dispose properly throughout the network stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
494
diff
changeset
|
58 |
std::vector<Application*> m_apps; |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
}; |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
|
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
61 |
}//namespace ns3 |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
62 |
#endif |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
63 |