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 class CFeatures;
00019 
00027 class CCombinedFeatures : public CFeatures
00028 {
00029     public:
00031         CCombinedFeatures();
00033         CCombinedFeatures(const CCombinedFeatures& orig);
00034 
00039         virtual CFeatures* duplicate() const;
00040 
00042         virtual ~CCombinedFeatures();
00043 
00048         inline virtual EFeatureType get_feature_type()
00049         {
00050             return F_UNKNOWN;
00051         }
00052 
00057         inline virtual EFeatureClass get_feature_class()
00058         {
00059             return C_COMBINED;
00060         }
00061 
00066         inline virtual int32_t get_num_vectors()
00067         {
00068             return num_vec;
00069         }
00070 
00075         virtual int32_t get_size()
00076         {
00077             CFeatures* f=feature_list->get_current_element();
00078             if (f)
00079             {
00080                 int32_t s=f->get_size();
00081                 SG_UNREF(f)
00082                 return s;
00083             }
00084             else 
00085                 return 0;
00086         }
00087 
00089         void list_feature_objs();
00090 
00096         bool check_feature_obj_compatibility(CCombinedFeatures* comb_feat);
00097 
00102         inline CFeatures* get_first_feature_obj()
00103         {
00104             return feature_list->get_first_element();
00105         }
00106 
00112         inline CFeatures* get_first_feature_obj(CListElement<CFeatures*>*&current)
00113         {
00114             return feature_list->get_first_element(current);
00115         }
00116 
00121         inline CFeatures* get_next_feature_obj()
00122         {
00123             return feature_list->get_next_element();
00124         }
00125 
00131         inline CFeatures* get_next_feature_obj(CListElement<CFeatures*>*&current)
00132         {
00133             return feature_list->get_next_element(current);
00134         }
00135 
00140         inline CFeatures* get_last_feature_obj()
00141         {
00142             return feature_list->get_last_element();
00143         }
00144 
00150         inline bool insert_feature_obj(CFeatures* obj)
00151         {
00152             ASSERT(obj);
00153             int32_t n=obj->get_num_vectors();
00154 
00155             if (num_vec>0 && n!=num_vec)
00156                 SG_ERROR("Number of feature vectors does not match (expected %d, obj has %d)\n", num_vec, n);
00157 
00158             num_vec=n;
00159             return feature_list->insert_element(obj);
00160         }
00161 
00167         inline bool append_feature_obj(CFeatures* obj)
00168         {
00169             ASSERT(obj);
00170             int32_t n=obj->get_num_vectors();
00171 
00172             if (num_vec>0 && n!=num_vec)
00173                 SG_ERROR("Number of feature vectors does not match (expected %d, obj has %d)\n", num_vec, n);
00174 
00175             num_vec=n;
00176             return feature_list->append_element(obj);
00177         }
00178 
00183         inline bool delete_feature_obj()
00184         {
00185             CFeatures* f=feature_list->delete_element();
00186             if (f)
00187             {
00188                 SG_UNREF(f);
00189                 return true;
00190             }
00191             else
00192                 return false;
00193         }
00194 
00199         inline int32_t get_num_feature_obj()
00200         {
00201             return feature_list->get_num_elements();
00202         }
00203 
00205         inline virtual const char* get_name() const { return "CombinedFeatures"; }
00206 
00207     protected:
00209         CList<CFeatures*>* feature_list;
00210 
00214         int32_t num_vec;
00215 };
00216 #endif

SHOGUN Machine Learning Toolbox - Documentation