00001 #ifndef mmn_dependancy_h_
00002 #define mmn_dependancy_h_
00003
00004
00005
00006
00007
00008
00009 #include <vsl/vsl_binary_io.h>
00010
00011
00012 const unsigned mmn_no_arc=99999;
00013
00014
00015 const unsigned mmn_no_tri=99999;
00016
00017
00018
00019
00020 class mmn_dependancy
00021 {
00022 public:
00023 unsigned v0,v1,v2;
00024 unsigned arc1, arc2, arc12;
00025 unsigned n_dep;
00026 unsigned tri1;
00027
00028
00029 mmn_dependancy()
00030 : v0(0), v1(0),v2(0),
00031 arc1(0),arc2(0),arc12(0),
00032 n_dep(0),tri1(mmn_no_tri) {}
00033
00034
00035 mmn_dependancy(unsigned u0, unsigned u1, unsigned a1)
00036 : v0(u0), v1(u1), v2(9999),
00037 arc1(a1), arc2(mmn_no_arc),arc12(mmn_no_arc),
00038 n_dep(1),tri1(mmn_no_tri) {}
00039
00040
00041 mmn_dependancy(unsigned u0, unsigned u1, unsigned u2,
00042 unsigned a1, unsigned a2, unsigned a12)
00043 : v0(u0), v1(u1), v2(u2),
00044 arc1(a1), arc2(a2),arc12(a12),
00045 n_dep(2), tri1(mmn_no_tri) {}
00046
00047
00048 mmn_dependancy(unsigned u0, unsigned u1, unsigned u2,
00049 unsigned a1, unsigned a2, unsigned a12, unsigned t1)
00050 : v0(u0), v1(u1), v2(u2),
00051 arc1(a1), arc2(a2),arc12(a12),
00052 n_dep(2), tri1(t1) {}
00053 };
00054
00055 inline vcl_ostream& operator<<(vcl_ostream& os, const mmn_dependancy& t)
00056 {
00057 os<<'{';
00058 if (t.n_dep==1) os<<t.v0<<':'<<t.v1<<'}';
00059 if (t.n_dep==2) os<<t.v0<<":("<<t.v1<<','<<t.v2<<")}";
00060 return os;
00061 }
00062
00063 inline void vsl_b_write(vsl_b_ostream& bfs, const mmn_dependancy& t)
00064 {
00065 vsl_b_write(bfs,short(1));
00066 vsl_b_write(bfs,t.v0);
00067 vsl_b_write(bfs,t.v1);
00068 vsl_b_write(bfs,t.v2);
00069 vsl_b_write(bfs,t.arc1);
00070 vsl_b_write(bfs,t.arc2);
00071 vsl_b_write(bfs,t.arc12);
00072 vsl_b_write(bfs,t.tri1);
00073 vsl_b_write(bfs,t.n_dep);
00074 }
00075
00076 inline void vsl_b_read(vsl_b_istream& bfs, mmn_dependancy& t)
00077 {
00078 if (!bfs) return;
00079 short version;
00080 vsl_b_read(bfs,version);
00081 switch (version)
00082 {
00083 case 1:
00084 vsl_b_read(bfs,t.v0);
00085 vsl_b_read(bfs,t.v1);
00086 vsl_b_read(bfs,t.v2);
00087 vsl_b_read(bfs,t.arc1);
00088 vsl_b_read(bfs,t.arc2);
00089 vsl_b_read(bfs,t.arc12);
00090 vsl_b_read(bfs,t.tri1);
00091 vsl_b_read(bfs,t.n_dep);
00092 return;
00093 default:
00094 vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&)\n"
00095 << " Unknown version number "<< version << vcl_endl;
00096 bfs.is().clear(vcl_ios::badbit);
00097 return;
00098 }
00099 }
00100
00101 #endif // mmn_dependancy_h_
00102