stromx  0.8.0
RecycleAccess.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_RECYCLEACCESS_H
18 #define STROMX_RUNTIME_RECYCLEACCESS_H
19 
20 #ifdef __GNUG__
21  #include <tr1/memory>
22 #else
23  #include <memory>
24 #endif
25 
26 #include "stromx/runtime/DataContainer.h"
27 #include "stromx/runtime/Exception.h"
28 
29 namespace stromx
30 {
31  namespace runtime
32  {
33  namespace impl
34  {
35  class RecycleAccessImpl;
36  }
37 
38  class Data;
39  class DataContainer;
40 
49  class STROMX_RUNTIME_API RecycleAccess
50  {
51  public:
57  explicit RecycleAccess(const DataContainer & data);
58 
61 
67  void add(const DataContainer & data);
68 
73  bool empty() const;
74 
81  Data* operator()() const { return get(); }
82 
89  Data* get() const;
90 
100  Data* operator()(const unsigned int timeout) const { return get(timeout); }
101 
111  Data* get(const unsigned int timeout) const;
112 
114  void release() { m_impl.reset(); }
115 
116  private:
117  std::tr1::shared_ptr<impl::RecycleAccessImpl> m_impl;
118  };
119  }
120 }
121 
122 #endif // STROMX_RUNTIME_RECYCLEACCESS_H
Recycle access to a data container.
Definition: RecycleAccess.h:49
Abstract data object.
Definition: Data.h:53
Container which manages the life-cycle of data objects.
Definition: DataContainer.h:43
Data * operator()(const unsigned int timeout) const
Definition: RecycleAccess.h:100
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
RecycleAccess()
Definition: RecycleAccess.h:60
Data * operator()() const
Definition: RecycleAccess.h:81
void release()
Definition: RecycleAccess.h:114