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 Fernando José Iglesias García 00008 * Copyright (C) 2012 Fernando José Iglesias García 00009 */ 00010 00011 #ifndef _STRUCTURED_LABELS__H__ 00012 #define _STRUCTURED_LABELS__H__ 00013 00014 #include <shogun/labels/Labels.h> 00015 #include <shogun/labels/LabelTypes.h> 00016 #include <shogun/lib/DynamicObjectArray.h> 00017 #include <shogun/lib/StructuredData.h> 00018 #include <shogun/lib/StructuredDataTypes.h> 00019 00020 namespace shogun { 00021 00023 class CStructuredLabels : public CLabels 00024 { 00025 00026 public: 00028 CStructuredLabels(); 00029 00038 CStructuredLabels(int32_t num_labels); 00039 00041 virtual ~CStructuredLabels(); 00042 00047 static CStructuredLabels* obtain_from_generic(CLabels* base_labels); 00048 00055 virtual void ensure_valid(const char* context = NULL); 00056 00065 void add_label(CStructuredData* label); 00066 00073 CDynamicObjectArray* get_labels() const; 00074 00081 CStructuredData* get_label(int32_t idx); 00082 00093 bool set_label(int32_t idx, CStructuredData* label); 00094 00099 virtual int32_t get_num_labels(); 00100 00102 virtual const char* get_name() const { return "StructuredLabels"; } 00103 00108 virtual ELabelType get_label_type() { return LT_STRUCTURED; } 00109 00114 inline EStructuredDataType get_structured_data_type() { return m_sdt; } 00115 00116 private: 00118 void init(); 00119 00121 void ensure_valid_sdt(CStructuredData* label); 00122 00123 protected: 00125 CDynamicObjectArray* m_labels; 00126 00128 EStructuredDataType m_sdt; 00129 00130 }; /* class CStructuredLabels */ 00131 00132 } /* namespace shogun */ 00133 00134 #endif /* _STRUCTUREDLABELS_H__ */