TrioCFD 1.9.9_beta
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 Pointer within the TRUST memory for an 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 Indicates whether the memory pointer is free, i.e. whether it points to a non-null Objet_U.
43 *
44 * @return (int) 1 if the pointer is free
45 */
46inline int Memoire_ptr::libre() const
47{
48 return o_ptr==0;
49}
50
51/*! @brief Assigns an Objet_U to a memory pointer.
52 *
53 * @param (Objet_U* ptr) pointer to an Objet_U
54 */
55inline void Memoire_ptr::set(Objet_U* ptr)
56{
57 o_ptr=ptr;
58}
59
60/*! @brief Returns a reference to the Objet_U pointed to by the memory pointer.
61 *
62 * @return (Objet_U&) reference to the pointed-to Objet_U
63 */
65{
66 assert(o_ptr!=0);
67 return *o_ptr;
68}
69
70
71/*! @brief Assignment operator between memory pointers. In the case A=B, the Objet_U pointed to by A becomes the Objet_U pointed to by B.
72 *
73 * @param (const Memoire_ptr& mptr) the memory pointer B
74 * @return (Memoire_ptr&) the memory pointer 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 &)
Assignment operator between memory pointers. In the case A=B, the Objet_U pointed to by A becomes the...
Definition Memoire_ptr.h:76
Memoire_ptr(Objet_U *ptr=0)
Constructor.
void set(Objet_U *ptr)
Assigns an Objet_U to a memory pointer.
Definition Memoire_ptr.h:55
Objet_U & obj()
Returns a reference to the Objet_U pointed to by the memory pointer.
Definition Memoire_ptr.h:64
int libre() const
Indicates whether the memory pointer is free, i.e. whether it points to a non-null Objet_U.
Definition Memoire_ptr.h:46
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68