Vaucanson  1.4.1
bmig_handlers_op.hxx
1 // bmig_handlers_op.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2007, 2008, 2009 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_AUTOMATA_IMPLEMENTATION_BMIG_BMIG_HANDLERS_OP_HXX
18 # define VCSN_AUTOMATA_IMPLEMENTATION_BMIG_BMIG_HANDLERS_OP_HXX
19 
21 # include <vaucanson/automata/concept/handlers.hh>
22 
23 
24 //Operator for htransition_t storing iterators
25 #define HOPERATOR(Op) \
26 template<typename T, typename U> \
27 bool operator Op (const handler<transition_h, boost::multi_index::detail::hashed_index_iterator<T, U> >& h1,\
28  const handler<transition_h, boost::multi_index::detail::hashed_index_iterator<T, U> >& h2)\
29 { \
30  if (h1.value()->from_ == h2.value()->from_) \
31  if (h1.value()->to_ == h2.value()->to_) \
32  return h1.value()->label_ Op h2.value()->label_; \
33  else \
34  return h1.value()->to_ Op h2.value()->to_; \
35  else \
36  return h1.value()->from_ Op h2.value()->from_; \
37 }
38 
39 namespace vcsn
40 {
41  HOPERATOR(<);
42  HOPERATOR(>);
43  HOPERATOR(<=);
44  HOPERATOR(>=);
45 }
46 #undef HOPERATOR
47 
48 #define HOPERATOR(Op) \
49 template<typename T, typename U> \
50 bool operator Op (const handler<transition_h, \
51  boost::multi_index::detail::hashed_index_iterator<T, U> >& h1,\
52  const handler<transition_h, \
53  boost::multi_index::detail::hashed_index_iterator<T, U> >& h2)\
54 { \
55  return h1.value() Op h2.value(); \
56 }
57 namespace vcsn
58 {
59  HOPERATOR(==);
60  HOPERATOR(!=);
61 }
62 #undef HOPERATOR
63 
64 
65 
66 
67 #define HOPERATOR(Op) \
68 inline \
69 bool operator Op (const handler<state_h, boost::shared_ptr<std::size_t> >& h1, \
70  const handler<state_h, boost::shared_ptr<std::size_t> >& h2) \
71 { \
72  return h1.value() Op h2.value(); \
73 }
74 
75 namespace vcsn
76 {
77  HOPERATOR(==);
78  HOPERATOR(!=);
79  HOPERATOR(<);
80 
81  inline
82  bool operator> (const handler<state_h, boost::shared_ptr<std::size_t> >& h1,
83  const handler<state_h, boost::shared_ptr<std::size_t> >& h2)
84  {
85  return h2 > h1;
86  }
87 
88  inline
89  bool operator<= (const handler<state_h, boost::shared_ptr<std::size_t> >& h1,
90  const handler<state_h, boost::shared_ptr<std::size_t> >& h2)
91  {
92  return h1 < h2 || h1 == h2;
93  }
94 
95  inline
96  bool operator>= (const handler<state_h, boost::shared_ptr<std::size_t> >& h1,
97  const handler<state_h, boost::shared_ptr<std::size_t> >& h2)
98  {
99  return !(h1 < h2);
100  }
101 }
102 #undef HOPERATOR
103 
104 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_BMIG_BMIG_HANDLERS_OP_HXX
105