Vaucanson  1.4.1
geometry.hxx
1 // GEOMETRY.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2005, 2006 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_GEOMETRY_HXX
18 # define VCSN_AUTOMATA_IMPLEMENTATION_GEOMETRY_HXX
19 
20 namespace vcsn
21 {
22 # define GEOMETRY_TPARAM \
23  template<typename HState, typename HTransition, typename Coords>
24 
25 # define GEOMETRY \
26  geometry<HState, HTransition, Coords>
27 
28  GEOMETRY_TPARAM
29  inline
30  GEOMETRY::geometry()
31  : states_(0), transitions_(0), initials_(0), finals_(0), name_(0)
32  {}
33 
34  GEOMETRY_TPARAM
35  inline
36  GEOMETRY& GEOMETRY::operator=(const GEOMETRY& obj)
37  {
38  return copy_from(obj);
39  }
40 
41  GEOMETRY_TPARAM
42  inline
43  GEOMETRY::geometry(const GEOMETRY& obj)
44  : states_(0), transitions_(0), initials_(0), finals_(0), name_(0)
45  {
46  copy_from(obj);
47  }
48 
49  GEOMETRY_TPARAM
50  inline
51  GEOMETRY& GEOMETRY::copy_from(const GEOMETRY& obj)
52  {
53  if (obj.states_ != 0)
54  {
55  delete states_;
56  states_ = new states_geometry_map_t(obj.states());
57  }
58  if (obj.transitions_ != 0)
59  {
60  delete transitions_;
61  transitions_ = new transitions_geometry_map_t(obj.transitions());
62  }
63  if (obj.initials_ != 0)
64  {
65  delete initials_;
66  initials_ = new initials_geometry_map_t(obj.initials());
67  }
68  if (obj.finals_ != 0)
69  {
70  delete finals_;
71  finals_ = new finals_geometry_map_t(obj.finals());
72  }
73  if (obj.name_ != 0)
74  {
75  delete name_;
76  name_ = new std::string(obj.name());
77  }
78  return *this;
79  }
80 
81  GEOMETRY_TPARAM
82  inline
83  GEOMETRY::~geometry()
84  {
85  delete states_;
86  delete transitions_;
87  delete initials_;
88  delete finals_;
89  delete name_;
90  }
91 
92 
93  GEOMETRY_TPARAM
94  inline
95  typename GEOMETRY::states_geometry_map_t&
96  GEOMETRY::states()
97  {
98  if (! states_)
99  states_ = new states_geometry_map_t();
100  return *states_;
101  }
102 
103  GEOMETRY_TPARAM
104  inline
105  const typename GEOMETRY::states_geometry_map_t&
106  GEOMETRY::states() const
107  {
108  if (! states_)
109  states_ = new states_geometry_map_t();
110  return *states_;
111  }
112 
113 
114  GEOMETRY_TPARAM
115  inline
116  typename GEOMETRY::transitions_geometry_map_t&
117  GEOMETRY::transitions()
118  {
119  if (! transitions_)
120  transitions_ = new transitions_geometry_map_t();
121  return *transitions_;
122  }
123 
124  GEOMETRY_TPARAM
125  inline
126  const typename GEOMETRY::transitions_geometry_map_t&
127  GEOMETRY::transitions() const
128  {
129  if (! transitions_)
130  transitions_ = new transitions_geometry_map_t();
131  return *transitions_;
132  }
133 
134 
135  GEOMETRY_TPARAM
136  inline
137  typename GEOMETRY::initials_geometry_map_t&
138  GEOMETRY::initials()
139  {
140  if (! initials_)
141  initials_ = new initials_geometry_map_t();
142  return *initials_;
143  }
144 
145  GEOMETRY_TPARAM
146  inline
147  const typename GEOMETRY::initials_geometry_map_t&
148  GEOMETRY::initials() const
149  {
150  if (! initials_)
151  initials_ = new initials_geometry_map_t();
152  return *initials_;
153  }
154 
155 
156  GEOMETRY_TPARAM
157  inline
158  typename GEOMETRY::finals_geometry_map_t&
159  GEOMETRY::finals()
160  {
161  if (! finals_)
162  finals_ = new finals_geometry_map_t();
163  return *finals_;
164  }
165 
166  GEOMETRY_TPARAM
167  inline
168  const typename GEOMETRY::finals_geometry_map_t&
169  GEOMETRY::finals() const
170  {
171  if (! finals_)
172  finals_ = new finals_geometry_map_t();
173  return *finals_;
174  }
175 
176 
177  GEOMETRY_TPARAM
178  inline
179  std::string&
180  GEOMETRY::name()
181  {
182  if (! name_)
183  name_ = new std::string();
184  return *name_;
185  }
186 
187  GEOMETRY_TPARAM
188  inline
189  const std::string&
190  GEOMETRY::name() const
191  {
192  if (! name_)
193  name_ = new std::string();
194  return *name_;
195  }
196 
197 
198 } // !vcsn
199 
200 
201 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_GEOMETRY_HXX