COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coRunRec.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef _CO_RUN_REC_LIST_H_
9 #define _CO_RUN_REC_LIST_H_
10 
11 // 28.03.99
12 
13 #include "coDLList.h"
14 #include "coObjID.h"
15 #include <iostream>
16 
17 #ifndef INLINE
18 #define INLINE inline
19 #endif
20 
21 namespace covise
22 {
23 
24 // structure identifying a 'run' in the module network
25 // -> change coSendBuffer/coRecvBuffer when changing structure
26 struct coRunRec
27 {
28  int timeStep, blockNo, numBlocks; // include numBlocks to identify different block structure
29  int runID; // ID, sequentially counted up per execution
30  // on MPP internal: node number
31  coRunRec(const coObjInfo &info)
32  {
33  timeStep = info.timeStep;
34  blockNo = info.blockNo;
35  numBlocks = info.numBlocks;
36  runID = -1;
37  }
38  coRunRec(){};
39  bool operator!=(const coRunRec &r)
40  {
41  return (r.blockNo != blockNo || r.timeStep != timeStep || r.numBlocks != numBlocks);
42  }
43 };
44 
45 INLINE std::ostream &operator<<(std::ostream &str, const coRunRec &rec)
46 {
47  str << "RunRec: T=" << rec.timeStep
48  << " Block #" << rec.blockNo
49  << "/" << rec.numBlocks
50  << " RunID=" << rec.runID;
51  return str;
52 }
53 
54 // compare function
55 INLINE bool operator==(const coRunRec &step1, const coRunRec &step2)
56 {
57  return (step1.timeStep == step2.timeStep)
58  && (step1.blockNo == step2.blockNo)
59  && (step1.numBlocks == step2.numBlocks);
60 }
61 
66 #ifndef _WIN32
67 class UTILEXPORT coRunRecList : public coDLList<coRunRec>
68 #else
69 class coRunRecList : public coDLList<coRunRec>
70 #endif
71 {
72 
73 private:
75  coRunRecList(const coRunRecList &);
76 
78  coRunRecList &operator=(const coRunRecList &);
79 
80 public:
82 
85 
87  virtual ~coRunRecList(){};
88 
90  void add(const coRunRec &rec);
91 
93  Iter getID(int runID);
94 
96  Iter getElem(const coRunRec &rec);
97 };
98 
99 INLINE std::ostream &operator<<(std::ostream &str, coRunRecList &list)
100 {
101  coRunRecList::Iter rec(list);
102  while (rec)
103  {
104  str << *rec << std::endl;
105  rec++;
106  }
107  return str;
108 }
109 
110 // structure needed on MPP to combine RunRec's and Nodes
111 struct coMppRun
112 {
114  int node;
115 
116  coMppRun(const coObjInfo &info)
117  {
118  runRec.timeStep = info.timeStep;
119  runRec.blockNo = info.blockNo;
120  runRec.numBlocks = info.numBlocks;
121  runRec.runID = -1;
122  node = 0;
123  }
124 
125  coMppRun(const coRunRec &old)
126  {
127  runRec = old;
128  node = 0;
129  }
130 
131  coMppRun(){};
132 
133  bool notFit(const coObjInfo &info) const
134  {
135  return (runRec.timeStep != info.timeStep)
136  || (runRec.blockNo != info.blockNo)
137  || (runRec.numBlocks != info.numBlocks);
138  }
139 
140  bool notFit(const coRunRec &rec) const
141  {
142  return (runRec.timeStep != rec.timeStep)
143  || (runRec.blockNo != rec.blockNo)
144  || (runRec.numBlocks != rec.numBlocks);
145  }
146 
147  bool notFit(const coMppRun &old) const
148  {
149  return (runRec.timeStep != old.runRec.timeStep)
150  || (runRec.blockNo != old.runRec.blockNo)
151  || (runRec.numBlocks != old.runRec.numBlocks);
152  }
153 };
154 
157 {
158  Iter rec(*this);
159  while ((rec) && ((*rec).runID != runID))
160  rec++;
161  return rec;
162 }
163 
166 {
167  Iter rec(*this);
168  while ((rec) && !((*rec) == searchRec))
169  rec++;
170  return rec;
171 }
172 
174 INLINE void coRunRecList::add(const coRunRec &addRec)
175 {
176 
177  Iter rec(*this);
178  while ((rec) && !((*rec) == addRec))
179  {
180  // if we got it, we needn't appeand it twice
181  if ((*rec) == addRec)
182  return;
183  rec++;
184  }
185  append(addRec);
186 }
187 }
188 
189 #endif
int runID
Definition: coRunRec.h:29
bool notFit(const coObjInfo &info) const
Definition: coRunRec.h:133
coRunRec()
Definition: coRunRec.h:38
int timeStep
Definition: coObjID.h:304
Definition: coRunRec.h:26
int blockNo
Definition: coRunRec.h:28
virtual ~coRunRecList()
Destructor.
Definition: coRunRec.h:87
Iter getElem(const coRunRec &rec)
get element with certain Contents
Definition: coRunRec.h:165
coMppRun(const coObjInfo &info)
Definition: coRunRec.h:116
coDLList< coRunRec > & append(const coRunRec &)
add new item to end of list
Definition: coRunRec.h:111
coRunRec runRec
Definition: coRunRec.h:113
coRunRec(const coObjInfo &info)
Definition: coRunRec.h:31
coDLListIter< coRunRec > Iter
Definition: coRunRec.h:81
Iter getID(int runID)
get element with certain ID
Definition: coRunRec.h:156
Definition: coObjID.h:230
bool operator!=(const coRunRec &r)
Definition: coRunRec.h:39
int blockNo
Definition: coObjID.h:304
coMppRun(const coRunRec &old)
Definition: coRunRec.h:125
bool notFit(const coRunRec &rec) const
Definition: coRunRec.h:140
int node
Definition: coRunRec.h:114
Definition: coDLList.h:43
GLdouble GLdouble GLdouble r
Definition: khronos-glext.h:6457
void add(const coRunRec &rec)
add a record, replace existing equal ones
Definition: coRunRec.h:174
int timeStep
Definition: coRunRec.h:28
coMppRun()
Definition: coRunRec.h:131
INLINE bool operator==(const coObjID &a, const coObjID &b)
Definition: coObjID.h:166
bool notFit(const coMppRun &old) const
Definition: coRunRec.h:147
coRunRecList()
Default constructor: NOT IMPLEMENTED.
Definition: coRunRec.h:84
Definition: coRunRec.h:67
int numBlocks
Definition: coRunRec.h:28
#define INLINE
Definition: coDLList.h:49
Definition: coDLList.h:101
int numBlocks
Definition: coObjID.h:304
#define UTILEXPORT
Definition: coExport.h:182
QTextStream & operator<<(QTextStream &out, const coConfigEntryStringList list)
Definition: coConfigEntryString.cpp:166