stromx  0.7.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Thread.h
1 /*
2 * Copyright 2011 Matthias Fuchs
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17 #ifndef STROMX_RUNTIME_THREAD_H
18 #define STROMX_RUNTIME_THREAD_H
19 
20 #include <string>
21 #include <vector>
22 #include "stromx/runtime/Color.h"
23 #include "stromx/runtime/Config.h"
24 #include "stromx/runtime/Input.h"
25 
26 namespace stromx
27 {
28  namespace python
29  {
30  class ThreadUtilities;
31  }
32 
33  namespace runtime
34  {
35  class Operator;
36 
37  namespace impl
38  {
39  class Network;
40  class ThreadImpl;
41  class ThreadImplObserver;
42  }
43 
53  class STROMX_RUNTIME_API Thread
54  {
55  friend class Stream;
56  friend class ThreadTest;
57  friend class stromx::python::ThreadUtilities;
58 
59  public:
61  enum Status
62  {
70  PAUSED
71  };
72 
73  virtual ~Thread();
74 
76  Status status() const;
77 
79  const std::string & name() const;
80 
82  void setName(const std::string& name);
83 
85  const Color & color() const;
86 
91  void setColor(const Color & color);
92 
94  const std::vector<Input> & inputSequence() const;
95 
103  void addInput(Operator* const op, const unsigned int inputId);
104 
112  void insertInput(const unsigned int position, Operator* const op, const unsigned int inputId);
113 
120  void removeInput(const unsigned int position);
121 
129  void removeInput(Operator* const op, const unsigned int inputId);
130 
131  private:
132  explicit Thread(const impl::Network* const network);
133  unsigned int findInput(Operator* const op, const unsigned int inputId);
134 
135  void start();
136  void stop();
137  void join();
138  void pause();
139  void resume();
140 
141  void setDelay(const unsigned int delay);
142 
147  void removeOperator(const Operator* op);
148 
149  void setObserver(const impl::ThreadImplObserver* const observer);
150 
160  void setInterruptedFlag(const bool value) { m_interruptedFlag = value; }
161  bool interruptedFlag() const { return m_interruptedFlag; }
162 
163  impl::ThreadImpl* m_thread;
164  std::string m_name;
165  const impl::Network* m_network;
166  std::vector<Input> m_inputSequence;
167  Color m_color;
168  bool m_interruptedFlag;
169  };
170  }
171 }
172 
173 #endif // STROMX_RUNTIME_THREAD_H
RGB color.
Definition: Color.h:35
Definition: Thread.h:66
Status
Definition: Thread.h:61
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
The core data processing pipeline of stromx.
Definition: Stream.h:45
Abstract operator.
Definition: Operator.h:60
A thread which visits input nodes.
Definition: Thread.h:53
Definition: Thread.h:64