Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

mmn_dependancy.h

Go to the documentation of this file.
00001 #ifndef mmn_dependancy_h_
00002 #define mmn_dependancy_h_
00003 
00004 //:
00005 // \file
00006 // \brief Store information about which node a given node depends on.
00007 // \author Tim Cootes
00008 
00009 #include <vsl/vsl_binary_io.h>
00010 
00011 //: Store information about which node a given node depends on
00012 //  If n_dep==1, then v0 depends only on v1 through arc1
00013 //  If n_dep==2 then v0 depends on v1 and v2, through arc1 and arc2
00014 class mmn_dependancy
00015 {
00016 public:
00017   unsigned v0,v1,v2;
00018   unsigned arc1, arc2, arc12;
00019   unsigned n_dep;
00020 
00021   //: Default constructor
00022   mmn_dependancy() :v0(0), v1(0),v2(0),arc1(0),arc2(0),arc12(0),n_dep(0) {};
00023 
00024   //: Construct with a single dependancy
00025   mmn_dependancy(unsigned u0, unsigned u1, unsigned a1) 
00026     : v0(u0), v1(u1), v2(9999), arc1(a1), arc2(9999), n_dep(1) {};
00027 
00028   //: Construct with a dual dependancy
00029   mmn_dependancy(unsigned u0, unsigned u1, unsigned u2,
00030                  unsigned a1, unsigned a2, unsigned a12) 
00031     : v0(u0), v1(u1), v2(u2), arc1(a1), arc2(a2),arc12(a12), n_dep(2) {};
00032 
00033 };
00034 
00035 inline vcl_ostream& operator<<(vcl_ostream& os, const mmn_dependancy& t)
00036 {
00037   os<<"{";
00038   if (t.n_dep==1) os<<t.v0<<":"<<t.v1<<"}";
00039   if (t.n_dep==2) os<<t.v0<<":("<<t.v1<<","<<t.v2<<")}";
00040   return os;
00041 }
00042 
00043 inline void vsl_b_write(vsl_b_ostream& bfs, const mmn_dependancy& t)
00044 {
00045   vsl_b_write(bfs,t.v0);
00046   vsl_b_write(bfs,t.v1);
00047   vsl_b_write(bfs,t.v2);
00048   vsl_b_write(bfs,t.arc1);
00049   vsl_b_write(bfs,t.arc2);
00050   vsl_b_write(bfs,t.arc12);
00051   vsl_b_write(bfs,t.n_dep);
00052 }
00053 
00054 inline void vsl_b_read(vsl_b_istream& bfs, mmn_dependancy& t)
00055 {
00056   vsl_b_read(bfs,t.v0);
00057   vsl_b_read(bfs,t.v1);
00058   vsl_b_read(bfs,t.v2);
00059   vsl_b_read(bfs,t.arc1);
00060   vsl_b_read(bfs,t.arc2);
00061   vsl_b_read(bfs,t.arc12);
00062   vsl_b_read(bfs,t.n_dep);
00063 }
00064 
00065 #endif // mmn_dependancy_h_
00066 

Generated on Thu Jan 10 14:44:52 2008 for contrib/mul/mmn by  doxygen 1.4.4