Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
xalloc.hh
Go to the documentation of this file.
1 
6 #ifndef VCSN_MISC_XALLOC_HH
7 # define VCSN_MISC_XALLOC_HH
8 
9 # include <iostream>
10 # include <functional>
11 
12 # include <vcsn/misc/attributes.hh>
13 
14 namespace vcsn
15 {
18  {
19  virtual void operator()(std::ostream& o) const = 0;
20  };
21 
27  std::ostream& operator<<(std::ostream& o, const iomanipulator& g);
28 
29 
38  template <class StoredType>
39  class xalloc
40  {
41  private:
46  class set_type : public iomanipulator
47  {
48  public:
50  set_type(const xalloc& slot, StoredType& data);
52  void operator()(std::ostream& ostr) const;
53  private:
55  const xalloc& slot_;
57  StoredType& data_;
58  };
59 
64  class get_type : public iomanipulator
65  {
66  public:
68  get_type(const xalloc& slot, StoredType& data);
69 
71  void operator()(std::ostream& ostr) const;
72  private:
74  const xalloc& slot_;
76  StoredType& data_;
77  };
78 
83  class swap_type : public iomanipulator
84  {
85  public:
87  swap_type(const xalloc& slot, StoredType& data);
88 
90  void operator()(std::ostream& ostr) const;
91  private:
93  const xalloc& slot_;
95  StoredType& data_;
96  };
97 
99  const long int index_;
100 
101  public:
103  xalloc();
105  long int index() const ATTRIBUTE_PURE;
107  StoredType& operator()(std::ostream& ostr) const;
108 
111  set_type set(StoredType& data) const;
112 
115  get_type get(StoredType& data) const;
116 
119  swap_type swap(StoredType& data) const;
120  };
121 
122 }
123 
124 # include <vcsn/misc/xalloc.hxx>
125 
126 #endif // !VCSN_MISC_XALLOC_HH
std::ostream & operator<<(std::ostream &os, direction d)
Pretty-printing.
Definition: direction.cc:19
get_type(const xalloc &slot, StoredType &data)
Set data_ to data.
Definition: xalloc.hxx:77
Handle the data to get from the xalloced place.
Definition: xalloc.hh:64
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:76
const xalloc & slot_
The xalloced data.
Definition: xalloc.hh:93
StoredType & data_
Variable in which we store the data to be swapped.
Definition: xalloc.hh:95
virtual void operator()(std::ostream &o) const =0
set_type set(StoredType &data) const
A setter.
Definition: xalloc.hxx:66
const xalloc & slot_
The xalloced data.
Definition: xalloc.hh:55
Handle the data to put in the xalloced place.
Definition: xalloc.hh:46
Defines the operator() for the classes get_type, set_type and swap_type.
Definition: xalloc.hh:17
xalloc()
Allocates the slot.
Definition: xalloc.hxx:26
void operator()(std::ostream &ostr) const
Set the data in the xalloced place.
Definition: xalloc.hxx:59
const long int index_
The index of the slot.
Definition: xalloc.hh:99
Allocate slots in std::ostreams.
Definition: xalloc.hh:39
get_type get(StoredType &data) const
A getter.
Definition: xalloc.hxx:91
const xalloc & slot_
The xalloced data.
Definition: xalloc.hh:74
void operator()(std::ostream &ostr) const
Get the data from the xalloced place.
Definition: xalloc.hxx:84
StoredType & data_
Data to put in the stream.
Definition: xalloc.hh:57
void operator()(std::ostream &ostr) const
Swap the data from the xalloced place for a given one.
Definition: xalloc.hxx:108
Swap the data stored in the stream for a given one.
Definition: xalloc.hh:83
swap_type(const xalloc &slot, StoredType &data)
Set data_ to data.
Definition: xalloc.hxx:102
long int index() const ATTRIBUTE_PURE
The xalloc index.
Definition: xalloc.hxx:32
set_type(const xalloc &slot, StoredType &data)
Set data_ to data.
Definition: xalloc.hxx:53