contrib/gel/gmvl/gmvl_database.h
Go to the documentation of this file.
00001 // This is gel/gmvl/gmvl_database.h
00002 #ifndef gmvl_database_h_
00003 #define gmvl_database_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author crossge@crd.ge.com
00010 // this provides a (not necessary fast or efficient) multi-access database.
00011 //   only dependency is on 'tag' nodes, although tag nodes are in all other
00012 //   sense identical to other nodes.
00013 
00014 #include <vcl_iosfwd.h>
00015 #include <vcl_vector.h>
00016 #include <vcl_string.h>
00017 
00018 #include <gmvl/gmvl_node_cache.h>
00019 #include <gmvl/gmvl_connection_cache.h>
00020 
00021 class gmvl_database
00022 {
00023  public:
00024 
00025   // methods on database nodes
00026   void add_node( const gmvl_node_sptr node);
00027   void remove_node( const gmvl_node_sptr node);
00028 
00029   // methods on connections
00030   void add_connection( const gmvl_node_sptr node1, const gmvl_node_sptr node2);
00031   void add_connections( const gmvl_node_sptr node1, vcl_vector<gmvl_node_sptr> nodes);
00032 
00033   // clever accessors
00034 
00035   //   nodes of a particular type
00036   vcl_vector<gmvl_node_sptr> get_nodes( const vcl_string type) const;
00037 
00038   //   nodes with a particular connection list
00039   vcl_vector<gmvl_node_sptr> get_connected_nodes( const gmvl_node_sptr node) const;
00040   vcl_vector<gmvl_node_sptr> get_connected_nodes( const gmvl_node_sptr node1,
00041                                                   const gmvl_node_sptr node2) const;
00042   vcl_vector<gmvl_node_sptr> get_connected_nodes( const gmvl_node_sptr node1,
00043                                                   const gmvl_node_sptr node2,
00044                                                   const gmvl_node_sptr node3) const;
00045   vcl_vector<gmvl_node_sptr> get_connected_nodes( const vcl_vector<gmvl_node_sptr> nodes) const;
00046 
00047   //   nodes with a particular connection list and a particular type
00048   vcl_vector<gmvl_node_sptr> get_connected_nodes( const gmvl_node_sptr node, const vcl_string type) const;
00049   vcl_vector<gmvl_node_sptr> get_connected_nodes( const vcl_vector<gmvl_node_sptr> nodes, const vcl_string type) const;
00050 
00051   // lookup a particular tag (returns null if not found)
00052   gmvl_node_sptr find_tag( const vcl_string &string) const;
00053 
00054   // output
00055   friend vcl_ostream &operator<<( vcl_ostream &os, const gmvl_database &db);
00056 
00057  protected:
00058 
00059   gmvl_node_cache nodecache_;
00060   gmvl_connection_cache connectioncache_;
00061 };
00062 
00063 vcl_ostream &operator<<( vcl_ostream &os, const gmvl_database &db);
00064 
00065 #endif // gmvl_database_h_