stromx  0.8.0
Id2DataPair.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_ID2DATAPAIR_H
18 #define STROMX_RUNTIME_ID2DATAPAIR_H
19 
20 #include "stromx/runtime/Config.h"
21 #include "stromx/runtime/DataContainer.h"
22 #include "stromx/runtime/Id2DataMapper.h"
23 
24 namespace stromx
25 {
26  namespace runtime
27  {
28  namespace impl
29  {
30  class Id2DataMap;
31  }
32 
34  class STROMX_RUNTIME_API Id2DataPair : public Id2DataMapper
35  {
36  public:
37  Id2DataPair(const unsigned int id, DataContainer data)
38  : m_id(id),
39  m_data(data)
40  {}
41 
42  explicit Id2DataPair(const unsigned int id)
43  : m_id(id),
44  m_data(DataContainer())
45  {}
46 
47  ~Id2DataPair() {}
48 
49  unsigned int id() const { return m_id; }
50  const DataContainer & data() const { return m_data; }
51 
52  virtual bool trySet(const impl::Id2DataMap& id2DataMap) const;
53  virtual bool tryGet(const impl::Id2DataMap& id2DataMap) const;
54  virtual void get(impl::Id2DataMap& id2DataMap) const;
55  virtual void set(impl::Id2DataMap& id2DataMap) const;
56 
57  private:
58  unsigned int m_id;
59  mutable DataContainer m_data;
60  };
61  }
62 }
63 
64 #endif // STROMX_RUNTIME_ID2DATAPAIR_H
Container which manages the life-cycle of data objects.
Definition: DataContainer.h:43
A direct map of one ID to one data object.
Definition: Id2DataPair.h:34
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
Abstract base class of ID-to-data mappers.
Definition: Id2DataMapper.h:30