VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sequentialExecutionContainer.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2014 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
8 
9 #pragma once
10 
12 #include <vector>
13 
17 template <class Texec>
19 {
20 public:
21 
22  typedef typename std::vector<Texec *> SecContainerType;
23  typedef typename SecContainerType::iterator SecIteratorType;
24 
25 public:
26 
29  : myExecVec()
30  {
31  }
32 
36 
39  virtual void add(Texec *item) { myExecVec.push_back(item); }
40 
43  virtual void remove(Texec *item) { myExecVec.erase(std::remove(myExecVec.begin(), myExecVec.end(), item), myExecVec.end()); }
44 
46  virtual void clear() { myExecVec.clear(); }
47 
51  virtual void deleteAndClear();
52 
55  virtual bool empty() const { return myExecVec.empty(); }
56 
60  virtual bool contains(Texec *item) { return std::find(begin(), end(), item) != end(); }
61 
64  virtual SecIteratorType begin() { return myExecVec.begin(); }
66  virtual SecIteratorType end() { return myExecVec.end(); }
67 
70  virtual void executeMethod(void (Texec::*theMethodPtr)());
71 
72 protected:
73 
76 
77 };
78 
79 template<class Texec>
81 {
84  for (SecIteratorType item = begin(); item != end(); ++item)
85  {
86  delete (*item);
87  }
88  clear();
89 }
90 
91 template<class Texec>
92 inline void DtSequentialExecutionContainer<Texec>::executeMethod(void (Texec::*theMethodPtr)())
93 {
94  if (empty())
95  {
96  return;
97  }
98 
101  for (SecIteratorType item = begin(); item != end(); ++item)
102  {
103  ((**item).*theMethodPtr)();
104  }
105 }

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)