CombinedFeatures.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2009 Soeren Sonnenburg
00008  * Written (W) 1999-2008 Gunnar Raetsch
00009  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00010  */
00011 
00012 #ifndef _CCOMBINEDFEATURES__H__
00013 #define _CCOMBINEDFEATURES__H__
00014 
00015 #include "features/Features.h"
00016 #include "lib/List.h"
00017 
00018 namespace shogun
00019 {
00020 class CFeatures;
00021 template <class T> class CList;
00022 template <class T> class CListElement;
00023 
00031 class CCombinedFeatures : public CFeatures
00032 {
00033     public:
00035         CCombinedFeatures();
00037         CCombinedFeatures(const CCombinedFeatures& orig);
00038 
00043         virtual CFeatures* duplicate() const;
00044 
00046         virtual ~CCombinedFeatures();
00047 
00052         inline virtual EFeatureType get_feature_type()
00053         {
00054             return F_UNKNOWN;
00055         }
00056 
00061         inline virtual EFeatureClass get_feature_class()
00062         {
00063             return C_COMBINED;
00064         }
00065 
00070         inline virtual int32_t get_num_vectors()
00071         {
00072             return num_vec;
00073         }
00074 
00079         virtual int32_t get_size()
00080         {
00081             CFeatures* f=feature_list->get_current_element();
00082             if (f)
00083             {
00084                 int32_t s=f->get_size();
00085                 SG_UNREF(f)
00086                 return s;
00087             }
00088             else 
00089                 return 0;
00090         }
00091 
00093         void list_feature_objs();
00094 
00100         bool check_feature_obj_compatibility(CCombinedFeatures* comb_feat);
00101 
00106         inline CFeatures* get_first_feature_obj()
00107         {
00108             return feature_list->get_first_element();
00109         }
00110 
00116         inline CFeatures* get_first_feature_obj(CListElement<CFeatures*>*&current)
00117         {
00118             return feature_list->get_first_element(current);
00119         }
00120 
00125         inline CFeatures* get_next_feature_obj()
00126         {
00127             return feature_list->get_next_element();
00128         }
00129 
00135         inline CFeatures* get_next_feature_obj(CListElement<CFeatures*>*&current)
00136         {
00137             return feature_list->get_next_element(current);
00138         }
00139 
00144         inline CFeatures* get_last_feature_obj()
00145         {
00146             return feature_list->get_last_element();
00147         }
00148 
00154         inline bool insert_feature_obj(CFeatures* obj)
00155         {
00156             ASSERT(obj);
00157             int32_t n=obj->get_num_vectors();
00158 
00159             if (num_vec>0 && n!=num_vec)
00160                 SG_ERROR("Number of feature vectors does not match (expected %d, obj has %d)\n", num_vec, n);
00161 
00162             num_vec=n;
00163             return feature_list->insert_element(obj);
00164         }
00165 
00171         inline bool append_feature_obj(CFeatures* obj)
00172         {
00173             ASSERT(obj);
00174             int32_t n=obj->get_num_vectors();
00175 
00176             if (num_vec>0 && n!=num_vec)
00177                 SG_ERROR("Number of feature vectors does not match (expected %d, obj has %d)\n", num_vec, n);
00178 
00179             num_vec=n;
00180             return feature_list->append_element(obj);
00181         }
00182 
00187         inline bool delete_feature_obj()
00188         {
00189             CFeatures* f=feature_list->delete_element();
00190             if (f)
00191             {
00192                 SG_UNREF(f);
00193                 return true;
00194             }
00195             else
00196                 return false;
00197         }
00198 
00203         inline int32_t get_num_feature_obj()
00204         {
00205             return feature_list->get_num_elements();
00206         }
00207 
00209         inline virtual const char* get_name() const { return "CombinedFeatures"; }
00210 
00211     protected:
00213         CList<CFeatures*>* feature_list;
00214 
00218         int32_t num_vec;
00219 };
00220 }
00221 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation