stromx  0.8.0
VariantHandle.h
1 /*
2  * Copyright 2015 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_VARIANTHANDLE_H
18 #define STROMX_RUNTIME_VARIANTHANDLE_H
19 
20 #include "stromx/runtime/VariantInterface.h"
21 #include "stromx/runtime/Exception.h"
22 
23 #ifdef __GNUG__
24  #include <tr1/memory>
25 #else
26  #include <memory>
27 #endif
28 
29 namespace stromx
30 {
31  namespace runtime
32  {
34  class STROMX_RUNTIME_API VariantHandle : public VariantInterface
35  {
36  friend class VariantInterface;
37 
38  public:
46  : m_variant(variant)
47  {
48  if (variant == 0)
49  {
50  throw WrongArgument("Variant must not be 0.");
51  }
52  }
53 
54  virtual unsigned int id() const;
55  virtual const std::string & package() const;
56  virtual const std::string title() const;
57  virtual bool isVariant(const VariantInterface& variant) const;
58  virtual CompositeType compositeType() const;
59  virtual const VariantHandle lhs() const;
60  virtual const VariantHandle rhs() const;
61 
63  bool isValid() const { return m_variant.get() != 0; }
64 
65  private:
66  VariantHandle() {}
67 
68  std::tr1::shared_ptr<VariantInterface> m_variant;
69  };
70  }
71 }
72 
73 #endif // STROMX_RUNTIME_VARIANTHANDLE_H
Definition: VariantHandle.h:34
bool isValid() const
Definition: VariantHandle.h:63
Abstract description of a data variant.
Definition: VariantInterface.h:40
VariantHandle(VariantInterface *const variant)
Definition: VariantHandle.h:45
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
A wrong argument was passed to a function.
Definition: Exception.h:53