SHOGUN  6.1.3
WrappedBasic.h
Go to the documentation of this file.
1 /*
2  * -*- coding: utf-8 -*-
3  * vim: set fileencoding=utf-8
4  *
5  * Copyright (c) 2016, Shogun-Toolbox e.V. <shogun-team@shogun-toolbox.org>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * Authors: Heiko Strathmann
35  */
36 #ifdef USE_META_INTEGRATION_TESTS
37 #ifndef WRAPPED_BASIC_H__
38 #define WRAPPED_BASIC_H__
39 
40 #include <shogun/base/SGObject.h>
41 #include <shogun/lib/SGString.h>
42 
43 namespace
44 {
45  template <typename T>
46  T default_value()
47  {
48  return T();
49  }
50 
51  template <>
52  char default_value()
53  {
54  return '0';
55  }
56 }
57 
58 namespace shogun
59 {
60 
67 template<class T> class CWrappedBasic: public CSGObject
68 {
69 public:
71  CWrappedBasic() : CSGObject()
72  {
73  set_generic<T>();
74  register_params();
75  }
76 
81  CWrappedBasic(T value, const char* value_name="")
82  {
83  set_generic<T>();
84  register_params();
85  m_value = value;
86  m_value_name = value_name;
87  }
88 
90  virtual const char* get_name() const { return "WrappedBasic"; }
91 
92 private:
93  void register_params()
94  {
95  m_value_name = "Unnamed";
96  m_value = ::default_value<T>();
97 
98  SG_ADD(&m_value, "value", "Wrapped value", MS_NOT_AVAILABLE);
99  }
100 
101 protected:
103  T m_value;
104 
106  const char* m_value_name;
107 };
108 
109 template class CWrappedBasic<bool>;
110 template class CWrappedBasic<char>;
111 template class CWrappedBasic<int8_t>;
112 template class CWrappedBasic<uint8_t>;
113 template class CWrappedBasic<int16_t>;
114 template class CWrappedBasic<uint16_t>;
115 template class CWrappedBasic<int32_t>;
116 template class CWrappedBasic<uint32_t>;
117 template class CWrappedBasic<int64_t>;
118 template class CWrappedBasic<uint64_t>;
119 template class CWrappedBasic<float32_t>;
120 template class CWrappedBasic<float64_t>;
121 template class CWrappedBasic<floatmax_t>;
122 
123 };
124 #endif // WRAPPED_BASIC_H__
125 #endif // USE_META_INTEGRATION_TESTS
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
#define SG_ADD(...)
Definition: SGObject.h:93

SHOGUN Machine Learning Toolbox - Documentation