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 * Written (W) 2011-2012 Heiko Strathmann 00010 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00011 */ 00012 00013 #ifndef _CFEATURES__H__ 00014 #define _CFEATURES__H__ 00015 00016 #include <shogun/lib/common.h> 00017 #include <shogun/io/File.h> 00018 #include <shogun/base/SGObject.h> 00019 #include <shogun/preprocessor/Preprocessor.h> 00020 #include <shogun/features/FeatureTypes.h> 00021 #include <shogun/features/SubsetStack.h> 00022 #include <shogun/lib/List.h> 00023 00024 namespace shogun 00025 { 00026 class CFile; 00027 class CPreprocessor; 00028 class CKernel; 00029 } 00030 00031 namespace shogun 00032 { 00033 00060 class CFeatures : public CSGObject 00061 { 00062 public: 00067 CFeatures(int32_t size=0); 00068 00070 CFeatures(const CFeatures& orig); 00071 00076 CFeatures(CFile* loader); 00077 00084 virtual CFeatures* duplicate() const=0; 00085 00086 virtual ~CFeatures(); 00087 00094 virtual EFeatureType get_feature_type() const=0; 00095 00102 virtual EFeatureClass get_feature_class() const=0; 00103 00109 virtual int32_t add_preprocessor(CPreprocessor* p); 00110 00116 virtual CPreprocessor* del_preprocessor(int32_t num); 00117 00122 CPreprocessor* get_preprocessor(int32_t num) const; 00123 00128 void set_preprocessed(int32_t num); 00129 00134 bool is_preprocessed(int32_t num) const; 00135 00140 int32_t get_num_preprocessed() const; 00141 00146 int32_t get_num_preprocessors() const; 00147 00149 void clean_preprocessors(); 00150 00155 int32_t get_cache_size() const; 00156 00163 virtual int32_t get_num_vectors() const=0; 00164 00173 virtual bool reshape(int32_t num_features, int32_t num_vectors); 00174 00181 virtual int32_t get_size() const=0; 00182 00184 void list_feature_obj() const; 00185 00190 virtual void load(CFile* loader); 00191 00196 virtual void save(CFile* writer); 00197 00203 bool check_feature_compatibility(CFeatures* f) const; 00204 00210 bool has_property(EFeatureProperty p) const; 00211 00216 void set_property(EFeatureProperty p); 00217 00222 void unset_property(EFeatureProperty p); 00223 00234 virtual CFeatures* create_merged_copy(CFeatures* other) 00235 { 00236 SG_ERROR("%s::create_merged_copy() is not yet implemented!\n"); 00237 return NULL; 00238 } 00239 00245 virtual void add_subset(SGVector<index_t> subset); 00246 00249 virtual void remove_subset(); 00250 00253 virtual void remove_all_subsets(); 00254 00259 virtual CSubsetStack* get_subset_stack(); 00260 00262 virtual void subset_changed_post() {} 00263 00273 virtual CFeatures* copy_subset(SGVector<index_t> indices); 00274 00275 private: 00276 void init(); 00277 00278 private: 00280 uint64_t properties; 00281 00283 int32_t cache_size; 00284 00286 CPreprocessor** preproc; 00287 00289 int32_t num_preproc; 00290 00292 bool* preprocessed; 00293 00294 protected: 00296 CSubsetStack* m_subset_stack; 00297 }; 00298 } 00299 #endif