OverSim
PubSubSubspace.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
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 
25 #ifndef __PUBSUBSUBSPACE_H_
26 #define __PUBSUBSUBSPACE_H_
27 
28 #include "PubSubSubspaceId.h"
29 #include "NodeHandle.h"
30 #include "PubSubMessage_m.h"
31 #include <deque>
32 
34 {
35  protected:
38 
39  simtime_t lastTimestamp;
40  public:
47  ~PubSubSubspace( );
48 
49  const PubSubSubspaceId& getId() { return spaceId; }
52 
53  void setTimestamp() { lastTimestamp = simTime(); }
54  void setTimestamp( simtime_t stamp ) { lastTimestamp = stamp; }
55  simtime_t getLastTimestamp() { return lastTimestamp; }
56  simtime_t getTimeSinceLastTimestamp() { return simTime() - lastTimestamp; }
57  friend std::ostream& operator<< (std::ostream& o, const PubSubSubspace& subspace);
58 };
59 
61 {
62  public:
63  std::list<PubSubResponsibleNodeCall*> waitingNodes;
66 };
67 
69 {
70  public:
71  std::set<NodeHandle> children;
74  virtual bool addChild( NodeHandle node ) { return children.insert( node ).second; }
75  virtual bool removeChild( NodeHandle node ) { return children.erase( node ); }
76  virtual int getNumChildren() { return children.size(); }
77 
78  friend std::ostream& operator<< (std::ostream& o, const PubSubSubspaceIntermediate& subspace);
79 };
80 
82 {
83  public:
85  {
86  public:
88  std::set<NodeHandle> children;
89  unsigned int waitingChildren;
91  };
92  std::deque<IntermediateNode> intermediateNodes;
93  std::map<NodeHandle,bool> cachedChildren;
94 
95  std::deque<PubSubMoveMessage*> waitingMoveMessages;
96 
97  static unsigned int maxChildren;
98 
101  const NodeHandle& getBackupNode() { return backupNode; }
102 
105 
109 
111  void fixTotalChildrenCount();
112 
113  int getNumIntermediates() { return intermediateNodes.size(); }
114  IntermediateNode* getNextFreeIntermediate();
115 
116  virtual bool addChild( NodeHandle node );
117  virtual IntermediateNode* removeAnyChild( NodeHandle node );
118  protected:
121 
124 
125  friend std::ostream& operator<< (std::ostream& o, const PubSubSubspaceResponsible& subspace);
126 };
127 
128 #endif