TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Objet_U_ptr.h
1/****************************************************************************
2* Copyright (c) 2026, 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 Objet_U_ptr_included
17#define Objet_U_ptr_included
18
19#include <Objet_U.h>
20
21class Nom;
22
23/*! @brief Pointeur sur un Objet_U.
24 *
25 * Le constructeur par defaut construit un pointeur "nul".
26 *
27 *
28 * @sa TRUST_Deriv
29 */
30class Objet_U_ptr: public Objet_U
31{
32 Declare_base_sans_constructeur_ni_destructeur(Objet_U_ptr);
33
34public:
35 static constexpr bool HAS_POINTER = true;
36 Objet_U_ptr(const Objet_U_ptr&) = delete;
37 const Objet_U_ptr& operator=(const Objet_U_ptr&) = delete;
38
39 explicit operator bool() const noexcept
40 {
41 assert(get_Objet_U_ptr_check() || 1); // this should disappear. when the factory is fixed probably
42 return (cle_ >= 0) ? true : false;
43 }
44
45 [[deprecated("Do not use naming logic on OWN_PTR, Trust_Deriv, Objet_U_ptr. Will be removed")]]
46 const Nom& le_nom() const override
47 {
48 throw std::logic_error("Error: le_nom() called on Objet_U_ptr\nDo not use naming logic on OWN_PTR, Trust_Deriv, Objet_U_ptr. Will be removed");
49 }
50
51 [[deprecated("Do not use naming logic on OWN_PTR, Trust_Deriv, Objet_U_ptr. Will be removed")]]
52 void nommer(const Nom&) override
53 {
54 throw std::logic_error("Error: nommer() called on Objet_U_ptr\nDo not use naming logic on OWN_PTR, Trust_Deriv, Objet_U_ptr. Will be removed");
55 }
56
57 Objet_U * typer(const char * nom_type);
58 void detach();
59#ifndef LATATOOLS
60 int associer_(Objet_U& objet) override;
61#endif
62
63protected:
64 ~Objet_U_ptr() override;
66
67 virtual void set_Objet_U_ptr(Objet_U*);
68 virtual Objet_U* get_Objet_U_ptr() const;
69
70 void recopie(const Objet_U&);
71#ifndef LATATOOLS
72 int change_num(const int* const) override; // renumerotation des objets
73#endif
74
76 int check_Objet_U_ptr_type(const Objet_U *ptr) const;
77
78 // Renvoie le Type_info du type de base accepte par le pointeur (l'objet pointe derive obligatoirement de ce type).
79 virtual const Type_info& get_info_ptr() const = 0;
80
81private:
82 // cle_ est le numero de cle de l'objet en reference.
83 // Si cle_ == -1, le pointeur est "nul".
84 // L'objet peut etre recupere par la_memoire().objet_u(cle_)
85 // Attention, la cle_ peut changer au cours du deroulement du programme (voir Memoire::comprimer())
86 int cle_ = -1;
87 // ptr_object_id_ est l'object_id_ de l'objet en reference.
88 // Permet de tester facilement si on pointe sur l'objet que l'on croit.
89 int ptr_object_id_ = -1;
90};
91
92#endif // Objet_U_ptr_H
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
int associer_(Objet_U &objet) override
Associe l'Objet_U a un autre Objet_U Methode virtuelle a surcharger.
static constexpr bool HAS_POINTER
Definition Objet_U_ptr.h:35
int change_num(const int *const) override
Pour mettre a jour les cles lorsque les Objet_U ont etes renumerotes.
Objet_U * get_Objet_U_ptr_check() const
Verifie si le pointeur est valide.
virtual void set_Objet_U_ptr(Objet_U *)
Fait pointer *this sur l'objet *ptr L'adresse peut etre nulle (pointeur nul).
void recopie(const Objet_U &)
Duplique l'Objet_U obj puis change le pointeur vers cette copie.
int check_Objet_U_ptr_type(const Objet_U *ptr) const
Verifie que l'objet pointe par ptr est d'un type acceptable pour le pointeur (avec get_info_ptr).
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Objet_U_ptr.h:46
Objet_U_ptr(const Objet_U_ptr &)=delete
~Objet_U_ptr() override
Destructeur.
void nommer(const Nom &) override
Donne un nom a l'Objet_U Methode virtuelle a surcharger.
Definition Objet_U_ptr.h:52
Objet_U_ptr()
construit un pointeur nul (cle a -1)
const Objet_U_ptr & operator=(const Objet_U_ptr &)=delete
Objet_U * typer(const char *nom_type)
Essaie de creer une instance du type "type".
virtual Objet_U * get_Objet_U_ptr() const
Renvoie un pointeur sur l'Objet_U associe ATTENTION: l'adresse peut etre nulle (si le pointeur est nu...
virtual const Type_info & get_info_ptr() const =0
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55
modelise une information de type pour les Objet_U
Definition Type_info.h:30