contrib/gel/gmvl/gmvl_connection_cache.h
Go to the documentation of this file.
00001 // This is gel/gmvl/gmvl_connection_cache.h
00002 #ifndef gmvl_connection_cache_h_
00003 #define gmvl_connection_cache_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author crossge@crd.ge.com
00010 
00011 #include <vcl_vector.h>
00012 #include <vcl_iosfwd.h>
00013 
00014 #include <vbl/vbl_bit_array_2d.h>
00015 #include <gmvl/gmvl_connection_sptr.h>
00016 
00017 class gmvl_connection_cache
00018 {
00019  public:
00020 
00021   // constructors / destructors
00022   gmvl_connection_cache();
00023   ~gmvl_connection_cache();
00024 
00025   // simple accessors
00026   void add( const gmvl_node_sptr node1, const gmvl_node_sptr node2);
00027 
00028   // clever accessors
00029   vcl_vector<int> get_connected_nodes( const gmvl_node_sptr node) const { return cache_[node->ref_]; }
00030   vcl_vector<int> get_connected_nodes( const gmvl_node_sptr node1,
00031                                        const gmvl_node_sptr node2) const;
00032   vcl_vector<int> get_connected_nodes( const gmvl_node_sptr node1,
00033                                        const gmvl_node_sptr node2,
00034                                        const gmvl_node_sptr node3) const;
00035   vcl_vector<int> get_connected_nodes( const vcl_vector<gmvl_node_sptr> nodes) const;
00036 
00037   void rebuild();
00038 
00039   // input output
00040   friend vcl_ostream &operator<<( vcl_ostream &os, const gmvl_connection_cache &c);
00041 
00042  protected:
00043 
00044   // raw connections
00045   vcl_vector<gmvl_connection_sptr> connections_;
00046 
00047   // cached connections
00048   vcl_vector<vcl_vector<int> > cache_;
00049 
00050   // and more caching...
00051   vbl_bit_array_2d cachebool_;
00052 };
00053 
00054 vcl_ostream &operator<<( vcl_ostream &os, const gmvl_connection_cache &c);
00055 
00056 #endif // gmvl_connection_cache_h_