COIN-OR::LEMON - Graph Library

Ticket #196: variant2-2d54d91a0fd9.patch

File variant2-2d54d91a0fd9.patch, 16.2 KB (added by Peter Kovacs, 16 years ago)
  • lemon/bits/graph_adaptor_extender.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1229120652 -3600
    # Node ID 2d54d91a0fd9df93a23505fa1c4bb280044beacc
    # Parent  09e416d35896ad42adc46b38056738b5f3dee209
    Hide docs of tools in lemon/bits (#196)
    
    diff --git a/lemon/bits/graph_adaptor_extender.h b/lemon/bits/graph_adaptor_extender.h
    a b  
    3434    typedef _Digraph Digraph;
    3535    typedef DigraphAdaptorExtender Adaptor;
    3636
    37     // Base extensions
    38 
    3937    typedef typename Parent::Node Node;
    4038    typedef typename Parent::Arc Arc;
    4139
     
    174172  };
    175173
    176174
    177   /// \ingroup digraphbits
    178   ///
    179   /// \brief Extender for the GraphAdaptors
    180175  template <typename _Graph>
    181176  class GraphAdaptorExtender : public _Graph {
    182177  public:
     
    189184    typedef typename Parent::Arc Arc;
    190185    typedef typename Parent::Edge Edge;
    191186
    192     // Graph extension
    193 
    194187    int maxId(Node) const {
    195188      return Parent::maxNodeId();
    196189    }
  • lemon/bits/variant.h

    diff --git a/lemon/bits/variant.h b/lemon/bits/variant.h
    a b  
    2121
    2222#include <lemon/assert.h>
    2323
    24 /// \file
    25 /// \brief Variant types
     24// \file
     25// \brief Variant types
    2626
    2727namespace lemon {
    2828
     
    3636  }
    3737
    3838
    39   /// \brief Simple Variant type for two types
    40   ///
    41   /// Simple Variant type for two types. The Variant type is a type
    42   /// safe union. The C++ has strong limitations for using unions, by
    43   /// example we can not store type with non default constructor or
    44   /// destructor in an union. This class always knowns the current
    45   /// state of the variant and it cares for the proper construction
    46   /// and destruction.
     39  // \brief Simple Variant type for two types
     40  //
     41  // Simple Variant type for two types. The Variant type is a type-safe
     42  // union. C++ has strong limitations for using unions, for
     43  // example you cannot store a type with non-default constructor or
     44  // destructor in a union. This class always knowns the current
     45  // state of the variant and it cares for the proper construction
     46  // and destruction.
    4747  template <typename _First, typename _Second>
    4848  class BiVariant {
    4949  public:
    5050
    51     /// \brief The \c First type.
     51    // \brief The \c First type.
    5252    typedef _First First;
    53     /// \brief The \c Second type.
     53    // \brief The \c Second type.
    5454    typedef _Second Second;
    5555
    56     /// \brief Constructor
    57     ///
    58     /// This constructor initalizes to the default value of the \c First
    59     /// type.
     56    // \brief Constructor
     57    //
     58    // This constructor initalizes to the default value of the \c First
     59    // type.
    6060    BiVariant() {
    6161      flag = true;
    6262      new(reinterpret_cast<First*>(data)) First();
    6363    }
    6464
    65     /// \brief Constructor
    66     ///
    67     /// This constructor initalizes to the given value of the \c First
    68     /// type.
     65    // \brief Constructor
     66    //
     67    // This constructor initalizes to the given value of the \c First
     68    // type.
    6969    BiVariant(const First& f) {
    7070      flag = true;
    7171      new(reinterpret_cast<First*>(data)) First(f);
    7272    }
    7373
    74     /// \brief Constructor
    75     ///
    76     /// This constructor initalizes to the given value of the \c
    77     /// Second type.
     74    // \brief Constructor
     75    //
     76    // This constructor initalizes to the given value of the \c
     77    // Second type.
    7878    BiVariant(const Second& s) {
    7979      flag = false;
    8080      new(reinterpret_cast<Second*>(data)) Second(s);
    8181    }
    8282
    83     /// \brief Copy constructor
    84     ///
    85     /// Copy constructor
     83    // \brief Copy constructor
     84    //
     85    // Copy constructor
    8686    BiVariant(const BiVariant& bivariant) {
    8787      flag = bivariant.flag;
    8888      if (flag) {
     
    9292      }
    9393    }
    9494
    95     /// \brief Destrcutor
    96     ///
    97     /// Destructor
     95    // \brief Destrcutor
     96    //
     97    // Destructor
    9898    ~BiVariant() {
    9999      destroy();
    100100    }
    101101
    102     /// \brief Set to the default value of the \c First type.
    103     ///
    104     /// This function sets the variant to the default value of the \c
    105     /// First type.
     102    // \brief Set to the default value of the \c First type.
     103    //
     104    // This function sets the variant to the default value of the \c
     105    // First type.
    106106    BiVariant& setFirst() {
    107107      destroy();
    108108      flag = true;
     
    110110      return *this;
    111111    }
    112112
    113     /// \brief Set to the given value of the \c First type.
    114     ///
    115     /// This function sets the variant to the given value of the \c
    116     /// First type.
     113    // \brief Set to the given value of the \c First type.
     114    //
     115    // This function sets the variant to the given value of the \c
     116    // First type.
    117117    BiVariant& setFirst(const First& f) {
    118118      destroy();
    119119      flag = true;
     
    121121      return *this;
    122122    }
    123123
    124     /// \brief Set to the default value of the \c Second type.
    125     ///
    126     /// This function sets the variant to the default value of the \c
    127     /// Second type.
     124    // \brief Set to the default value of the \c Second type.
     125    //
     126    // This function sets the variant to the default value of the \c
     127    // Second type.
    128128    BiVariant& setSecond() {
    129129      destroy();
    130130      flag = false;
     
    132132      return *this;
    133133    }
    134134
    135     /// \brief Set to the given value of the \c Second type.
    136     ///
    137     /// This function sets the variant to the given value of the \c
    138     /// Second type.
     135    // \brief Set to the given value of the \c Second type.
     136    //
     137    // This function sets the variant to the given value of the \c
     138    // Second type.
    139139    BiVariant& setSecond(const Second& s) {
    140140      destroy();
    141141      flag = false;
     
    143143      return *this;
    144144    }
    145145
    146     /// \brief Operator form of the \c setFirst()
     146    // \brief Operator form of the \c setFirst()
    147147    BiVariant& operator=(const First& f) {
    148148      return setFirst(f);
    149149    }
    150150
    151     /// \brief Operator form of the \c setSecond()
     151    // \brief Operator form of the \c setSecond()
    152152    BiVariant& operator=(const Second& s) {
    153153      return setSecond(s);
    154154    }
    155155
    156     /// \brief Assign operator
     156    // \brief Assign operator
    157157    BiVariant& operator=(const BiVariant& bivariant) {
    158158      if (this == &bivariant) return *this;
    159159      destroy();
     
    166166      return *this;
    167167    }
    168168
    169     /// \brief Reference to the value
    170     ///
    171     /// Reference to the value of the \c First type.
    172     /// \pre The BiVariant should store value of \c First type.
     169    // \brief Reference to the value
     170    //
     171    // Reference to the value of the \c First type.
     172    // \pre The BiVariant should store value of \c First type.
    173173    First& first() {
    174174      LEMON_DEBUG(flag, "Variant wrong state");
    175       return *reinterpret_cast<First*>(data); 
     175      return *reinterpret_cast<First*>(data);
    176176    }
    177177
    178     /// \brief Const reference to the value
    179     ///
    180     /// Const reference to the value of the \c First type.
    181     /// \pre The BiVariant should store value of \c First type.
    182     const First& first() const { 
     178    // \brief Const reference to the value
     179    //
     180    // Const reference to the value of the \c First type.
     181    // \pre The BiVariant should store value of \c First type.
     182    const First& first() const {
    183183      LEMON_DEBUG(flag, "Variant wrong state");
    184       return *reinterpret_cast<const First*>(data); 
     184      return *reinterpret_cast<const First*>(data);
    185185    }
    186186
    187     /// \brief Operator form of the \c first()
     187    // \brief Operator form of the \c first()
    188188    operator First&() { return first(); }
    189     /// \brief Operator form of the const \c first()
     189    // \brief Operator form of the const \c first()
    190190    operator const First&() const { return first(); }
    191191
    192     /// \brief Reference to the value
    193     ///
    194     /// Reference to the value of the \c Second type.
    195     /// \pre The BiVariant should store value of \c Second type.
    196     Second& second() { 
     192    // \brief Reference to the value
     193    //
     194    // Reference to the value of the \c Second type.
     195    // \pre The BiVariant should store value of \c Second type.
     196    Second& second() {
    197197      LEMON_DEBUG(!flag, "Variant wrong state");
    198       return *reinterpret_cast<Second*>(data); 
     198      return *reinterpret_cast<Second*>(data);
    199199    }
    200200
    201     /// \brief Const reference to the value
    202     ///
    203     /// Const reference to the value of the \c Second type.
    204     /// \pre The BiVariant should store value of \c Second type.
    205     const Second& second() const { 
     201    // \brief Const reference to the value
     202    //
     203    // Const reference to the value of the \c Second type.
     204    // \pre The BiVariant should store value of \c Second type.
     205    const Second& second() const {
    206206      LEMON_DEBUG(!flag, "Variant wrong state");
    207       return *reinterpret_cast<const Second*>(data); 
     207      return *reinterpret_cast<const Second*>(data);
    208208    }
    209209
    210     /// \brief Operator form of the \c second()
     210    // \brief Operator form of the \c second()
    211211    operator Second&() { return second(); }
    212     /// \brief Operator form of the const \c second()
     212    // \brief Operator form of the const \c second()
    213213    operator const Second&() const { return second(); }
    214214
    215     /// \brief %True when the variant is in the first state
    216     ///
    217     /// %True when the variant stores value of the \c First type.
     215    // \brief %True when the variant is in the first state
     216    //
     217    // %True when the variant stores value of the \c First type.
    218218    bool firstState() const { return flag; }
    219219
    220     /// \brief %True when the variant is in the second state
    221     ///
    222     /// %True when the variant stores value of the \c Second type.
     220    // \brief %True when the variant is in the second state
     221    //
     222    // %True when the variant stores value of the \c Second type.
    223223    bool secondState() const { return !flag; }
    224224
    225225  private:
     
    289289
    290290  }
    291291
    292   /// \brief Variant type
    293   ///
    294   /// Simple Variant type. The Variant type is a type safe union. The
    295   /// C++ has strong limitations for using unions, for example we
    296   /// cannot store type with non default constructor or destructor in
    297   /// a union. This class always knowns the current state of the
    298   /// variant and it cares for the proper construction and
    299   /// destruction.
    300   ///
    301   /// \param _num The number of the types which can be stored in the
    302   /// variant type.
    303   /// \param _TypeMap This class describes the types of the Variant. The
    304   /// _TypeMap::Map<index>::Type should be a valid type for each index
    305   /// in the range {0, 1, ..., _num - 1}. The \c VariantTypeMap is helper
    306   /// class to define such type mappings up to 10 types.
    307   ///
    308   /// And the usage of the class:
    309   ///\code
    310   /// typedef Variant<3, VariantTypeMap<int, std::string, double> > MyVariant;
    311   /// MyVariant var;
    312   /// var.set<0>(12);
    313   /// std::cout << var.get<0>() << std::endl;
    314   /// var.set<1>("alpha");
    315   /// std::cout << var.get<1>() << std::endl;
    316   /// var.set<2>(0.75);
    317   /// std::cout << var.get<2>() << std::endl;
    318   ///\endcode
    319   ///
    320   /// The result of course:
    321   ///\code
    322   /// 12
    323   /// alpha
    324   /// 0.75
    325   ///\endcode
     292  // \brief Variant type
     293  //
     294  // Simple Variant type. The Variant type is a type-safe union.
     295  // C++ has strong limitations for using unions, for example you
     296  // cannot store type with non-default constructor or destructor in
     297  // a union. This class always knowns the current state of the
     298  // variant and it cares for the proper construction and
     299  // destruction.
     300  //
     301  // \param _num The number of the types which can be stored in the
     302  // variant type.
     303  // \param _TypeMap This class describes the types of the Variant. The
     304  // _TypeMap::Map<index>::Type should be a valid type for each index
     305  // in the range {0, 1, ..., _num - 1}. The \c VariantTypeMap is helper
     306  // class to define such type mappings up to 10 types.
     307  //
     308  // And the usage of the class:
     309  //\code
     310  // typedef Variant<3, VariantTypeMap<int, std::string, double> > MyVariant;
     311  // MyVariant var;
     312  // var.set<0>(12);
     313  // std::cout << var.get<0>() << std::endl;
     314  // var.set<1>("alpha");
     315  // std::cout << var.get<1>() << std::endl;
     316  // var.set<2>(0.75);
     317  // std::cout << var.get<2>() << std::endl;
     318  //\endcode
     319  //
     320  // The result of course:
     321  //\code
     322  // 12
     323  // alpha
     324  // 0.75
     325  //\endcode
    326326  template <int _num, typename _TypeMap>
    327327  class Variant {
    328328  public:
     
    331331
    332332    typedef _TypeMap TypeMap;
    333333
    334     /// \brief Constructor
    335     ///
    336     /// This constructor initalizes to the default value of the \c type
    337     /// with 0 index.
     334    // \brief Constructor
     335    //
     336    // This constructor initalizes to the default value of the \c type
     337    // with 0 index.
    338338    Variant() {
    339339      flag = 0;
    340340      new(reinterpret_cast<typename TypeMap::template Map<0>::Type*>(data))
     
    342342    }
    343343
    344344
    345     /// \brief Copy constructor
    346     ///
    347     /// Copy constructor
     345    // \brief Copy constructor
     346    //
     347    // Copy constructor
    348348    Variant(const Variant& variant) {
    349349      flag = variant.flag;
    350350      _variant_bits::Memory<num - 1, TypeMap>::copy(flag, data, variant.data);
    351351    }
    352352
    353     /// \brief Assign operator
    354     ///
    355     /// Assign operator
     353    // \brief Assign operator
     354    //
     355    // Assign operator
    356356    Variant& operator=(const Variant& variant) {
    357357      if (this == &variant) return *this;
    358358      _variant_bits::Memory<num - 1, TypeMap>::
     
    363363      return *this;
    364364    }
    365365
    366     /// \brief Destrcutor
    367     ///
    368     /// Destructor
     366    // \brief Destrcutor
     367    //
     368    // Destructor
    369369    ~Variant() {
    370370      _variant_bits::Memory<num - 1, TypeMap>::destroy(flag, data);
    371371    }
    372372
    373     /// \brief Set to the default value of the type with \c _idx index.
    374     ///
    375     /// This function sets the variant to the default value of the
    376     /// type with \c _idx index.
     373    // \brief Set to the default value of the type with \c _idx index.
     374    //
     375    // This function sets the variant to the default value of the
     376    // type with \c _idx index.
    377377    template <int _idx>
    378378    Variant& set() {
    379379      _variant_bits::Memory<num - 1, TypeMap>::destroy(flag, data);
     
    383383      return *this;
    384384    }
    385385
    386     /// \brief Set to the given value of the type with \c _idx index.
    387     ///
    388     /// This function sets the variant to the given value of the type
    389     /// with \c _idx index.
     386    // \brief Set to the given value of the type with \c _idx index.
     387    //
     388    // This function sets the variant to the given value of the type
     389    // with \c _idx index.
    390390    template <int _idx>
    391391    Variant& set(const typename _TypeMap::template Map<_idx>::Type& init) {
    392392      _variant_bits::Memory<num - 1, TypeMap>::destroy(flag, data);
     
    396396      return *this;
    397397    }
    398398
    399     /// \brief Gets the current value of the type with \c _idx index.
    400     ///
    401     /// Gets the current value of the type with \c _idx index.
     399    // \brief Gets the current value of the type with \c _idx index.
     400    //
     401    // Gets the current value of the type with \c _idx index.
    402402    template <int _idx>
    403403    const typename TypeMap::template Map<_idx>::Type& get() const {
    404404      LEMON_DEBUG(_idx == flag, "Variant wrong index");
     
    406406        template Map<_idx>::Type*>(data);
    407407    }
    408408
    409     /// \brief Gets the current value of the type with \c _idx index.
    410     ///
    411     /// Gets the current value of the type with \c _idx index.
     409    // \brief Gets the current value of the type with \c _idx index.
     410    //
     411    // Gets the current value of the type with \c _idx index.
    412412    template <int _idx>
    413413    typename _TypeMap::template Map<_idx>::Type& get() {
    414414      LEMON_DEBUG(_idx == flag, "Variant wrong index");
     
    416416        (data);
    417417    }
    418418
    419     /// \brief Returns the current state of the variant.
    420     ///
    421     /// Returns the current state of the variant.
     419    // \brief Returns the current state of the variant.
     420    //
     421    // Returns the current state of the variant.
    422422    int state() const {
    423423      return flag;
    424424    }
     
    469469
    470470  }
    471471
    472   /// \brief Helper class for Variant
    473   ///
    474   /// Helper class to define type mappings for Variant. This class
    475   /// converts the template parameters to be mappable by integer.
    476   /// \see Variant
     472  // \brief Helper class for Variant
     473  //
     474  // Helper class to define type mappings for Variant. This class
     475  // converts the template parameters to be mappable by integer.
     476  // \see Variant
    477477  template <
    478478    typename _T0,
    479479    typename _T1 = void, typename _T2 = void, typename _T3 = void,