TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Memoire_ptr.h
1/****************************************************************************
2* Copyright (c) 2024, 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 Memoire_ptr_included
17#define Memoire_ptr_included
18
19#include <Objet_U.h>
20#include <assert.h>
21
22
23/*! @brief Pointeur dans la Memoire de TRUST pour un Objet_U
24 *
25 * @sa Objet_U Memoire
26 */
28{
29public :
30
31 int next;
32
33 Memoire_ptr(Objet_U* ptr=0) ;
34 inline int libre() const;
35 inline void set(Objet_U* ptr);
36 inline Objet_U& obj();
37 inline Memoire_ptr& operator=(const Memoire_ptr&);
38private :
39 Objet_U* o_ptr;
40};
41
42/*! @brief Indique si le pointeur memoire est libre, c'est-a-dire s'il pointe sur un Objet_U non nul
43 *
44 * @return (int) 1 si le pointeur est libre
45 */
46inline int Memoire_ptr::libre() const
47{
48 return o_ptr==0;
49}
50
51/*! @brief Affecte un Objet_U a un pointeur memoire
52 *
53 * @param (Objet_U* ptr) pointeur sur un Objet_U
54 */
55inline void Memoire_ptr::set(Objet_U* ptr)
56{
57 o_ptr=ptr;
58}
59
60/*! @brief Retourne une reference sur l'Objet_U pointe par le pointeur memoire
61 *
62 * @return (Objet_U&) reference sur l'Objet_U pointe
63 */
65{
66 assert(o_ptr!=0);
67 return *o_ptr;
68}
69
70
71/*! @brief Operateur d'affectation entre pointeurs memoire Dans le cas A=B, l'Objet_U pointe par A est l'Objet_U pointe par B
72 *
73 * @param (const Memoire_ptr& mptr) le pointeur memoire B
74 * @return (Memoire_ptr&) le pointeur memoire A
75 */
77{
78 o_ptr=mptr.o_ptr;
79 next=mptr.next;
80 return *this;
81}
82
83#endif
Memoire_ptr & operator=(const Memoire_ptr &)
Operateur d'affectation entre pointeurs memoire Dans le cas A=B, l'Objet_U pointe par A est l'Objet_U...
Definition Memoire_ptr.h:76
Memoire_ptr(Objet_U *ptr=0)
Constructeur.
void set(Objet_U *ptr)
Affecte un Objet_U a un pointeur memoire.
Definition Memoire_ptr.h:55
Objet_U & obj()
Retourne une reference sur l'Objet_U pointe par le pointeur memoire.
Definition Memoire_ptr.h:64
int libre() const
Indique si le pointeur memoire est libre, c'est-a-dire s'il pointe sur un Objet_U non nul.
Definition Memoire_ptr.h:46
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73