filereader.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // This file is part of libgvectors.
00004 // libgvectors is a C++ library intended for visualizing mathematical vectors.
00005 // Copyright (C) 2007  Rafael Ostertag
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
00020 // USA.
00021 //
00022 // $Id: filereader_8h-source.html,v 1.1 2007-09-08 19:02:31 rafi Exp $
00023 //
00024 // File:   filereader.h
00025 // Author: Rafael Ostertag
00026 //
00027 // Created on August 18, 2007, 12:37 AM
00028 //
00029 
00040 #ifndef _FILEREADER_H
00041 #define _FILEREADER_H
00042 
00043 #include <map>
00044 
00045 #include <gvectortypes.h>
00046 #include <vectorstore.h>
00047 #include <visualvector.h>
00048 
00049 namespace GVectors {
00060     template<class Fct> class FileReader {
00061     private:
00067         std::map<vslevel_t, gvid_t> levelmap;
00074         VectorStore& vectorstore;
00087         Fct callback;
00088     protected:
00102         virtual void put(vslevel_t level, const vv_ref_t visualvector) {
00103             if (level==TOP_LEVEL_NUM) {
00104                 levelmap[level] = vectorstore.add(visualvector);
00105             } else {
00106                 levelmap[level] = vectorstore.add_child(levelmap[level-1], visualvector);
00107             }
00108             
00109             callback(level, levelmap[level], vectorstore[levelmap[level]]);
00110         }
00111         
00112     public:
00122         FileReader(VectorStore& vs, Fct cb) : vectorstore(vs), callback(cb) {
00123             // Empty
00124         }
00132         FileReader(const FileReader& fr) : vectorstore(fr.vectorstore),
00133                 callback(fr.callback) {
00134             // Empty
00135         }
00141         virtual ~FileReader() {
00142             // Empty
00143         }
00149         virtual void read() = 0;
00150     };
00151 }
00152 
00153 
00154 #endif  /* _FILEREADER_H */
00155 

Generated on Sat Sep 8 19:37:29 2007 for libgvectors by  doxygen 1.4.7