Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

sequence.cpp

Go to the documentation of this file.
00001 // PTF - Psychological Test Framework 00002 // http://ptf.sourceforge.net 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU Library General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 #include <ptf/core/sequence.hpp> 00019 #include <ptf/core/ptfcore.hpp> 00020 #include <string> 00021 #include <stdexcept> 00022 00023 // bring things we use into scope 00024 using std::string; 00025 00029 Sequence::Sequence() { 00030 // nothing to do here 00031 } 00032 00037 Sequence::Sequence(const char* fname) { 00038 loadFromFile(fname); 00039 } 00040 00044 Sequence::~Sequence() { 00045 // nothing to do here 00046 } 00047 00052 void Sequence::loadFromFile(const char* fname) { 00053 ifstream fin(fname); 00054 if (fin.good()) { 00055 idList.clear(); 00056 while (!fin.eof()) { 00057 string token; 00058 fin >> token; 00059 if (token!="") idList.push_back(atoi(token.c_str())); 00060 } 00061 } 00062 else { 00063 PtfCore::getSingleton().getMessageLog() 00064 << "ERROR: Can't load sequence file (" << fname << ").\n"; 00065 throw std::runtime_error("Can't load sequence file."); 00066 } 00067 fin.close(); 00068 } 00069 00075 void Sequence::setTaskId(int i, int value) { 00076 idList[i] = value; 00077 } 00078 00084 int Sequence::getTaskId(int i) { 00085 return idList[i]; 00086 } 00087 00093 int& Sequence::operator[](int i) { 00094 return idList[i]; 00095 } 00096 00101 int Sequence::size() { 00102 return (int)idList.size(); 00103 }

Generated on Fri Dec 17 14:54:23 2004 for Psychological Test Framework by doxygen 1.3.8