stromx  0.8.0
DataContainer.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_DATACONTAINER_H
18 #define STROMX_RUNTIME_DATACONTAINER_H
19 
20 #include "stromx/runtime/Config.h"
21 
22 #ifdef __GNUG__
23  #include <tr1/memory>
24 #else
25  #include <memory>
26 #endif
27 
28 namespace stromx
29 {
30  namespace runtime
31  {
32  class Data;
33 
34  namespace impl
35  {
36  class ReadAccessImpl;
37  class WriteAccessImpl;
38  class DataContainerImpl;
39  class RecycleAccessImpl;
40  }
41 
43  class STROMX_RUNTIME_API DataContainer
44  {
45  friend class impl::WriteAccessImpl;
46  friend class impl::ReadAccessImpl;
47  friend class impl::RecycleAccessImpl;
48 
49  friend STROMX_RUNTIME_API bool operator==(const DataContainer & lhs, const DataContainer & rhs);
50  friend STROMX_RUNTIME_API bool operator!=(const DataContainer & lhs, const DataContainer & rhs);
51  friend STROMX_RUNTIME_API std::ostream& operator<< (std::ostream& out, const DataContainer & container);
52 
53  public:
58 
64  explicit DataContainer(runtime::Data* data);
65 
73  explicit DataContainer(runtime::Data* data, const bool isReadOnly);
74 
76  bool empty() const { return m_impl.get() == 0; }
77 
79  void release() { m_impl.reset(); }
80 
84  bool isReadOnly() const;
85 
86  private:
87  std::tr1::shared_ptr<impl::DataContainerImpl> m_impl;
88  };
89 
91  STROMX_RUNTIME_API bool operator==(const DataContainer & lhs, const DataContainer & rhs);
92 
94  STROMX_RUNTIME_API bool operator!=(const DataContainer & lhs, const DataContainer & rhs);
95 
97  STROMX_RUNTIME_API std::ostream& operator<< (std::ostream& out, const DataContainer & container);
98  }
99 }
100 
101 #endif // STROMX_RUNTIME_DATACONTAINER_H
Abstract data object.
Definition: Data.h:53
Container which manages the life-cycle of data objects.
Definition: DataContainer.h:43
void release()
Definition: DataContainer.h:79
bool empty() const
Definition: DataContainer.h:76
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
bool operator!=(const runtime::DataContainer &lhs, const runtime::DataContainer &rhs)
Definition: DataContainer.cpp:46
DataContainer()
Definition: DataContainer.h:57