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) 2012 Heiko Strathmann 00008 */ 00009 00010 #ifndef __SUBSETSTACK_H_ 00011 #define __SUBSETSTACK_H_ 00012 00013 #include <shogun/base/SGObject.h> 00014 #include <shogun/mathematics/Math.h> 00015 #include <shogun/lib/DynamicObjectArray.h> 00016 #include <shogun/features/Subset.h> 00017 00018 00019 namespace shogun 00020 { 00021 00035 class CSubsetStack: public CSGObject 00036 { 00037 public: 00040 CSubsetStack(); 00041 00044 CSubsetStack(const CSubsetStack& other); 00045 00047 virtual ~CSubsetStack(); 00048 00050 inline const char* get_name() const { return "SubsetStack"; } 00051 00055 virtual void add_subset(SGVector<index_t> subset); 00056 00058 virtual void remove_subset(); 00059 00061 virtual void remove_all_subsets(); 00062 00064 inline index_t get_size() { 00065 if (!has_subsets()) 00066 SG_WARNING("CSubsetStack::get_size(): No subset in stack!\n"); 00067 00068 return has_subsets() ? m_active_subset->get_size() : -1; 00069 } 00070 00072 virtual bool has_subsets() const 00073 { 00074 return m_active_subsets_stack->get_num_elements(); 00075 } 00076 00081 CSubset* get_last_subset() const { return m_active_subset; } 00082 00088 inline index_t subset_idx_conversion(index_t idx) const 00089 { 00090 return m_active_subset ? m_active_subset->m_subset_idx.vector[idx] : idx; 00091 } 00092 00093 private: 00095 void init(); 00096 00097 private: 00102 CDynamicObjectArray* m_active_subsets_stack; 00103 00105 CSubset* m_active_subset; 00106 }; 00107 00108 } 00109 #endif /* __SUBSETSTACK_H_ */