Back to index

texmacs  1.0.7.15
link.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : link.cpp
00004 * DESCRIPTION: Linking of trees
00005 * COPYRIGHT  : (C) 2006  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef LINK_H
00013 #define LINK_H
00014 #include "tree.hpp"
00015 #include "list.hpp"
00016 #include "hashmap.hpp"
00017 
00018 /******************************************************************************
00019 * The soft_link class
00020 ******************************************************************************/
00021 
00022 class soft_link;
00023 class soft_link_rep: public concrete_struct {
00024 public:
00025   tree t;
00026 
00027 public:
00028   inline soft_link_rep (tree t2): t (t2) {}
00029   inline ~soft_link_rep () {}
00030 
00031   friend class soft_link;
00032 };
00033 
00034 class soft_link {
00035 public:
00036 CONCRETE(soft_link);
00037 public:
00038   inline soft_link (tree t):
00039     rep (tm_new<soft_link_rep> (t)) {}
00040   inline friend bool operator == (soft_link ln1, soft_link ln2) {
00041     return ln1.rep == ln2.rep; }
00042   inline friend bool operator != (soft_link ln1, soft_link ln2) {
00043     return ln1.rep != ln2.rep; }
00044   inline friend tm_ostream& operator << (tm_ostream& out, soft_link ln) {
00045     return out << "soft_link (" << ln.rep << ")"; }
00046 };
00047 CONCRETE_CODE(soft_link);
00048 
00049 /******************************************************************************
00050 * Link repositories
00051 ******************************************************************************/
00052 
00053 class link_repository_rep: public abstract_struct {
00054 public:
00055   list<string> ids;
00056   list<observer> loci;
00057   list<soft_link> links;
00058   link_repository_rep ();
00059   ~link_repository_rep ();
00060   void insert_locus (string id, tree t);
00061   void insert_link (soft_link ln);
00062 };
00063 
00064 class link_repository {
00065 ABSTRACT_NULL(link_repository);
00066 public:
00067   inline link_repository (bool active) :
00068     rep (tm_new<link_repository_rep> ()) { (void) active; rep->ref_count++; }
00069 };
00070 ABSTRACT_NULL_CODE(link_repository);
00071 
00072 /******************************************************************************
00073 * Routines for navigation
00074 ******************************************************************************/
00075 
00076 list<string> get_ids (tree t);
00077 list<tree> get_trees (string id);
00078 list<tree> get_links (tree v);
00079 list<string> all_link_types ();
00080 
00081 void set_locus_rendering (string var, string val);
00082 string get_locus_rendering (string var);
00083 void declare_visited (string id);
00084 bool has_been_visited (string id);
00085 
00086 #endif // HARD_LINK_H