ToPS
|
00001 /* 00002 * Alphabet.hpp 00003 * 00004 * Copyright 2011 Andre Yoshiaki Kashiwabara <akashiwabara@usp.br> 00005 * Ígor Bonádio <ibonadio@ime.usp.br> 00006 * Vitor Onuchic <vitoronuchic@gmail.com> 00007 * Alan Mitchell Durham <aland@usp.br> 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 3 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00022 * MA 02110-1301, USA. 00023 */ 00024 00025 #ifndef ALPHABET_H 00026 #define ALPHABET_H 00027 00028 #include "crossplatform.hpp" 00029 00030 #include <boost/shared_ptr.hpp> 00031 #include <boost/pool/pool_alloc.hpp> 00032 00033 #include <vector> 00034 #include <map> 00035 #include <string> 00036 #include <sstream> 00037 #include <iostream> 00038 00039 00040 00041 00042 namespace tops { 00043 class DLLEXPORT Symbol; 00044 typedef boost::shared_ptr <Symbol> SymbolPtr; 00045 class DLLEXPORT ProbabilisticModelParameterValue; 00046 typedef boost::shared_ptr <ProbabilisticModelParameterValue> ProbabilisticModelParameterValuePtr; 00048 class DLLEXPORT Alphabet 00049 { 00050 public: 00052 00055 SymbolPtr createSymbol(const std::string & name); 00056 SymbolPtr createSymbol(char * name); 00057 00059 unsigned int size (); 00060 00062 SymbolPtr getSymbol(int k); 00063 00065 SymbolPtr getSymbol(const std::string & s); 00066 00068 00072 bool has (const std::string & s); 00073 00075 void initializeFromVector(const std::vector <std::string> & str); 00076 00078 std::string str() const; 00079 ProbabilisticModelParameterValuePtr getParameterValue(); 00080 private: 00081 std::vector<SymbolPtr, boost::pool_allocator<SymbolPtr> > _pool; 00082 std::map <std::string, SymbolPtr> _stringToSymbol; 00083 }; 00084 00085 typedef boost::shared_ptr<Alphabet> AlphabetPtr; 00086 } 00087 #endif