stromx  0.8.0
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/InputConnector.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<InputConnector> & 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 
128  void removeInput(Operator* const op, const unsigned int inputId);
129 
130  private:
131  explicit Thread(const impl::Network* const network);
132 
133  void start();
134  void stop();
135  void join();
136  void pause();
137  void resume();
138 
139  void setDelay(const unsigned int delay);
140 
141  void setObserver(const impl::ThreadImplObserver* const observer);
142 
152  void setInterruptedFlag(const bool value) { m_interruptedFlag = value; }
153  bool interruptedFlag() const { return m_interruptedFlag; }
154 
155  impl::ThreadImpl* m_thread;
156  std::string m_name;
157  const impl::Network* m_network;
158  std::vector<InputConnector> m_inputSequence;
159  Color m_color;
160  bool m_interruptedFlag;
161  };
162  }
163 }
164 
165 #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