Vcsn  2.4
Be Rational
xalloc.hh
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <iostream>
9 #include <functional>
10 
11 #include <vcsn/misc/attributes.hh>
12 
13 namespace vcsn
14 {
17  {
18  virtual void operator()(std::ostream& o) const = 0;
19  };
20 
26  std::ostream& operator<<(std::ostream& o, const iomanipulator& g);
27 
28 
37  template <typename StoredType>
38  class xalloc
39  {
40  private:
45  class set_type : public iomanipulator
46  {
47  public:
49  set_type(const xalloc& slot, StoredType& data);
51  void operator()(std::ostream& ostr) const;
52  private:
54  const xalloc& slot_;
56  StoredType& data_;
57  };
58 
63  class get_type : public iomanipulator
64  {
65  public:
67  get_type(const xalloc& slot, StoredType& data);
68 
70  void operator()(std::ostream& ostr) const;
71  private:
73  const xalloc& slot_;
75  StoredType& data_;
76  };
77 
82  class swap_type : public iomanipulator
83  {
84  public:
86  swap_type(const xalloc& slot, StoredType& data);
87 
89  void operator()(std::ostream& ostr) const;
90  private:
92  const xalloc& slot_;
94  StoredType& data_;
95  };
96 
98  const long int index_;
99 
100  public:
102  xalloc();
104  long int index() const ATTRIBUTE_PURE;
106  StoredType& operator()(std::ostream& ostr) const;
107 
110  set_type set(StoredType& data) const;
111 
114  get_type get(StoredType& data) const;
115 
118  swap_type swap(StoredType& data) const;
119  };
120 
121 }
122 
123 #include <vcsn/misc/xalloc.hxx>
STL namespace.
swap_type swap(StoredType &data) const
A swapper.
Definition: xalloc.hxx:115
StoredType & data_
Variable in which we return the xalloc data.
Definition: xalloc.hh:75
Handle the data to get from the xalloced place.
Definition: xalloc.hh:63
set_type(const xalloc &slot, StoredType &data)
Set data_ to data.
Definition: xalloc.hxx:53
const xalloc & slot_
The xalloced data.
Definition: xalloc.hh:54
xalloc()
Allocates the slot.
Definition: xalloc.hxx:26
Swap the data stored in the stream for a given one.
Definition: xalloc.hh:82
Handle the data to put in the xalloced place.
Definition: xalloc.hh:45
std::ostream & operator<<(std::ostream &os, direction d)
Pretty-printing.
Definition: direction.cc:19
const xalloc & slot_
The xalloced data.
Definition: xalloc.hh:92
Definition: a-star.hh:8
Allocate slots in std::ostreams.
Definition: xalloc.hh:38
StoredType & data_
Data to put in the stream.
Definition: xalloc.hh:56
const xalloc & slot_
The xalloced data.
Definition: xalloc.hh:73
void operator()(std::ostream &ostr) const
Swap the data from the xalloced place for a given one.
Definition: xalloc.hxx:108
const long int index_
The index of the slot.
Definition: xalloc.hh:98
StoredType & data_
Variable in which we store the data to be swapped.
Definition: xalloc.hh:94
get_type get(StoredType &data) const
A getter.
Definition: xalloc.hxx:91
void operator()(std::ostream &ostr) const
Set the data in the xalloced place.
Definition: xalloc.hxx:59
long int index() const ATTRIBUTE_PURE
The xalloc index.
Definition: xalloc.hxx:32
swap_type(const xalloc &slot, StoredType &data)
Set data_ to data.
Definition: xalloc.hxx:102
set_type set(StoredType &data) const
A setter.
Definition: xalloc.hxx:66
get_type(const xalloc &slot, StoredType &data)
Set data_ to data.
Definition: xalloc.hxx:77
virtual void operator()(std::ostream &o) const =0
void operator()(std::ostream &ostr) const
Get the data from the xalloced place.
Definition: xalloc.hxx:84
Defines the operator() for the classes get_type, set_type and swap_type.
Definition: xalloc.hh:16