vectorstore.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: vectorstore_8h-source.html,v 1.1 2007-09-08 19:02:37 rafi Exp $
00023 //
00024 // File:   vectorstore.h
00025 // Author: Rafael Ostertag
00026 //
00027 // Created on July 22, 2007, 7:57 PM
00028 //
00029 
00041 #ifndef _VECTORSTORE_H
00042 #define _VECTORSTORE_H
00043 
00044 #include <list>
00045 #include <map>
00046 #include <functional>
00047 
00048 #include <vstoreitem.h>
00049 #include <gvector.h>
00050 #include <gvectortypes.h>
00051 #include <filewriter.h>
00052 
00053 namespace GVectors {
00054     
00070     class VectorStore {
00071     private:
00082         std::map<gvid_t, vsi_ptr_t> lookup;
00091         std::list<vsi_ptr_t> vector_items;
00103         std::list<gvid_t> removed;
00104         
00114         bool useexceptions;
00115         
00116     protected:
00118         vsi_ptr_t get_item(gvid_t id) const;
00119         
00120     public:
00122         VectorStore(bool use_e=true);
00124         ~VectorStore();
00125 
00127         void use_exceptions(bool ue);
00130         vv_ptr_t id_get(gvid_t id);
00133         vv_ptr_t operator[](gvid_t id) { return id_get(id); }
00134         
00136         gvid_t add(const vv_ref_t v);
00138         gvid_t add(vv_ptr_t v, bool managed=true);
00139         
00142         void replace(gvid_t id, vv_ptr_t v, bool managed=true);
00145         void replace(gvid_t id, vv_ref_t v);
00146         
00148         gvid_t add_child(gvid_t id, const vv_ref_t v);
00150         gvid_t add_child(gvid_t id, vv_ptr_t v, bool managed=true);
00151         
00153         void remove(gvid_t id);
00155         void clear();
00157         vssize_t size() const;
00158 
00160         void set_origin(const Coordinates& co);
00162         void set_scale(double sc);
00164         void set_arrow_length(double arl);
00166         void set_rotation(const Rotation& r);
00168         void draw(Drawer &d);
00170         void save(FileWriter& fw) const;
00171                 
00174         void sum_up(gvid_t id, GVector& vec) const;
00177         void dimension(Coordinates& min, Coordinates& max) const;
00178     };
00179     
00180 }
00181 
00182 #endif  /* _VECTORSTORE_H */

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