TrioCFD 1.9.9_beta
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 Pointer to an Objet_U.
24 *
25 * The default constructor builds a "null" pointer.
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; // renumbering of objects
73#endif
74
76 int check_Objet_U_ptr_type(const Objet_U *ptr) const;
77
78 // Returns the Type_info of the base type accepted by the pointer (the pointed object must necessarily derive from this type).
79 virtual const Type_info& get_info_ptr() const = 0;
80
81private:
82 // cle_ is the key number of the referenced object.
83 // If cle_ == -1, the pointer is "null".
84 // The object can be retrieved via la_memoire().objet_u(cle_)
85 // Warning, cle_ may change during program execution (see Memoire::comprimer())
86 int cle_ = -1;
87 // ptr_object_id_ is the object_id_ of the referenced object.
88 // Allows easy verification that we are pointing to the expected object.
89 int ptr_object_id_ = -1;
90};
91
92#endif // Objet_U_ptr_H
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
int associer_(Objet_U &objet) override
Associates the Objet_U with another Objet_U. Virtual method to override.
static constexpr bool HAS_POINTER
Definition Objet_U_ptr.h:35
int change_num(const int *const) override
Updates keys when Objet_U objects have been renumbered.
Objet_U * get_Objet_U_ptr_check() const
Checks if the pointer is valid.
virtual void set_Objet_U_ptr(Objet_U *)
Makes *this point to the object *ptr. The address may be null (null pointer).
void recopie(const Objet_U &)
Duplicates the Objet_U obj and then changes the pointer to this copy.
int check_Objet_U_ptr_type(const Objet_U *ptr) const
Verifies that the object pointed to by ptr is of an acceptable type for the pointer (via get_info_ptr...
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U_ptr.h:46
Objet_U_ptr(const Objet_U_ptr &)=delete
~Objet_U_ptr() override
Destructor.
void nommer(const Nom &) override
Assigns a name to the Objet_U. Virtual method to override.
Definition Objet_U_ptr.h:52
Objet_U_ptr()
Builds a null pointer (key set to -1).
const Objet_U_ptr & operator=(const Objet_U_ptr &)=delete
Objet_U * typer(const char *nom_type)
Tries to create an instance of type "type".
virtual Objet_U * get_Objet_U_ptr() const
Returns a pointer to the associated Objet_U. WARNING: the address may be null (if the pointer is null...
virtual const Type_info & get_info_ptr() const =0
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
Models type information for Objet_U objects.
Definition Type_info.h:30