SHOGUN  6.1.3
WrappedObjectArray.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 
37 #include <shogun/lib/config.h>
38 
39 #ifdef USE_META_INTEGRATION_TESTS
40 
41 #ifndef WRAPPED_OBJECT_ARRAY_H__
42 #define WRAPPED_OBJECT_ARRAY_H__
43 
48 
49 
50 namespace shogun
51 {
52 
57 class CWrappedObjectArray : public CDynamicObjectArray
58 {
59 public:
60  CWrappedObjectArray(): CDynamicObjectArray() { }
61 
68  template<class T> bool append_wrapped(T data, const char* data_name="")
69  {
70  return this->append_element(new CWrappedBasic<T>(data, data_name));
71  }
72 
79  template<class T> bool append_wrapped(SGVector<T> data, const char* data_name="")
80  {
81  return this->append_element(new CWrappedSGVector<T>(data,
82  data_name));
83  }
84 
91  template<class T> bool append_wrapped(SGMatrix<T> data, const char* data_name="")
92  {
93  return this->append_element(new CWrappedSGMatrix<T>(data,
94  data_name));
95  }
96 
98  virtual const char* get_name() const { return "WrappedObjectArray"; }
99 
100 #define APPEND_WRAPPED_TEMPLATE(META_TYPE, SG_TYPE) \
101  \
106  bool append_wrapped_##META_TYPE(SG_TYPE data, const char* data_name="") \
107 { \
108  return this->append_wrapped(data, data_name); \
109 }
110 
111  APPEND_WRAPPED_TEMPLATE(real, float64_t)
112  APPEND_WRAPPED_TEMPLATE(float, float32_t)
113  APPEND_WRAPPED_TEMPLATE(int, int32_t)
114  APPEND_WRAPPED_TEMPLATE(real_vector, SGVector<float64_t>)
115  APPEND_WRAPPED_TEMPLATE(float_vector, SGVector<float32_t>)
116  APPEND_WRAPPED_TEMPLATE(real_matrix, SGMatrix<float64_t>)
117  APPEND_WRAPPED_TEMPLATE(float_matrix, SGMatrix<float32_t>)
118 
126  bool append_wrapped_real_vector(float64_t data, const char* data_name="")
127  {
128  SGVector<float64_t> wrap(1);
129  wrap[0] = data;
130  return this->append_wrapped(wrap, data_name);
131  }
132 };
133 }
134 #endif // WRAPPED_OBJECT_ARRAY_H__
135 #endif // USE_META_INTEGRATION_TESTS
T wrap(const T &value)
Definition: some.h:151
double float64_t
Definition: common.h:60
float float32_t
Definition: common.h:59
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18

SHOGUN Machine Learning Toolbox - Documentation