TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Liste_bloc.h
1/****************************************************************************
2* Copyright (c) 2023, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Liste_bloc_included
17#define Liste_bloc_included
18
19#include <TRUST_Deriv.h>
20
21/*! @brief The Liste_bloc and Liste_bloc_curseur classes represent a list of Deriv<Objet_U> elements and an associated cursor.
22 *
23 */
24class Liste_bloc: public Objet_U
25{
26 Declare_instanciable_sans_constructeur_ni_destructeur(Liste_bloc);
27public:
28 Liste_bloc() { suivant_ = this; }
29 ~Liste_bloc() override;
30
31 inline int est_vide() const { return suivant_ == this; }
32 inline Objet_U& valeur() { return data.valeur(); }
33 inline const Objet_U& valeur() const { return data.valeur(); }
34 inline int est_dernier() const { return (est_vide() || (!suivant_)); }
35 inline Objet_U* operator ->() { return &(valeur()); }
36 inline const Objet_U* operator ->() const { return &(valeur()); }
37 inline const Liste_bloc& suivant() const { return *suivant_; }
38 inline Liste_bloc& suivant() { return *suivant_; }
39
40 Objet_U& operator[](int);
41 Objet_U& add_deplace(DerObjU&);
42
43 void vide();
45
46protected:
47 DerObjU data;
48 Liste_bloc *suivant_ = nullptr;
49};
50
52{
53public :
54 inline Liste_bloc_curseur(const Liste_bloc& a_list) : curseur((Liste_bloc*) &a_list) { if(a_list.est_vide()) curseur = nullptr; }
55 inline const Objet_U& valeur() const { return curseur->valeur(); }
56 inline Objet_U& valeur() { return curseur->valeur(); }
57 inline Objet_U* operator ->() { return curseur->operator->(); }
58 inline const Objet_U* operator ->() const { return curseur->operator->(); }
59 inline const Liste_bloc& list() const { return *curseur; }
60 inline Liste_bloc& list() { return *curseur; }
61 inline operator bool() const { return (curseur != nullptr); }
62 inline void operator ++()
63 {
64 if (curseur->est_dernier()) curseur = nullptr;
65 else curseur = &(curseur->suivant());
66 }
67
68 inline Liste_bloc& operator=(const Liste_bloc& a_list)
69 {
70 curseur = (Liste_bloc*) (&a_list);
71 return *curseur;
72 }
73
74private :
75 Liste_bloc* curseur = nullptr;
76};
77
78#endif /* Liste_bloc_included */
const Liste_bloc & list() const
Definition Liste_bloc.h:59
Objet_U & valeur()
Definition Liste_bloc.h:56
Objet_U * operator->()
Definition Liste_bloc.h:57
Liste_bloc & operator=(const Liste_bloc &a_list)
Definition Liste_bloc.h:68
const Objet_U & valeur() const
Definition Liste_bloc.h:55
Liste_bloc & list()
Definition Liste_bloc.h:60
Liste_bloc_curseur(const Liste_bloc &a_list)
Definition Liste_bloc.h:54
The Liste_bloc and Liste_bloc_curseur classes represent a list of Deriv<Objet_U> elements and an asso...
Definition Liste_bloc.h:25
~Liste_bloc() override
int est_dernier() const
Definition Liste_bloc.h:34
const Liste_bloc & suivant() const
Definition Liste_bloc.h:37
Liste_bloc & dernier()
Returns the last element of the list.
Objet_U * operator->()
Definition Liste_bloc.h:35
Objet_U & operator[](int)
Access operator to the i-th element of the list.
Liste_bloc & suivant()
Definition Liste_bloc.h:38
int est_vide() const
Definition Liste_bloc.h:31
Liste_bloc * suivant_
Definition Liste_bloc.h:48
const Objet_U & valeur() const
Definition Liste_bloc.h:33
void vide()
Clears the list.
Objet_U & valeur()
Definition Liste_bloc.h:32
Objet_U & add_deplace(DerObjU &)
Adds an Objet_U to the list. to_add is released on exit.
DerObjU data
Definition Liste_bloc.h:47
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54