TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Memoire.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_included
17#define Memoire_included
18
19#include <type_traits>
20#include <Memoire_ptr.h>
21
22class Objet_U;
23class Sortie;
24class Nom;
25
26/*! @brief La memoire de Trio-U
27 *
28 */
30{
31public :
32 static Memoire& Instance();
33 int add (Objet_U* );
34 int suppr(int );
35 Objet_U& objet_u(int);
36 const Objet_U& objet_u(int) const;
37 Objet_U* objet_u_ptr(int);
38 const Objet_U* objet_u_ptr(int) const;
39 int rang(const Nom& type, const Nom& nom) const;
40 int rang(const Nom& nom) const;
41 friend Sortie& operator <<(Sortie&, const Memoire&);
42 void compacte();
43
44 int verifie() const;
45 int imprime() const;
46
47private :
48 int size;
49 Memoire_ptr* data;
50 static int step;
51 static int prems;
52
53 static Memoire* _instance;
54
55protected :
56 Memoire();
57};
58
59Sortie& operator <<(Sortie& , const Memoire&);
60
61#endif /* Memoire_included */
Pointer within the TRUST memory for an Objet_U.
Definition Memoire_ptr.h:28
La memoire de Trio-U.
Definition Memoire.h:30
int rang(const Nom &type, const Nom &nom) const
Returns the index in memory of the object with the given type and name.
Definition Memoire.cpp:166
Objet_U & objet_u(int)
Returns a reference to the Objet_U at index num in memory.
Definition Memoire.cpp:206
int verifie() const
Verifies the content of all memory slots.
Definition Memoire.cpp:388
Objet_U * objet_u_ptr(int)
Returns a pointer to the Objet_U at index num in memory.
Definition Memoire.cpp:258
void compacte()
Compacts memory. This compaction is performed automatically when it becomes necessary.
Definition Memoire.cpp:306
static Memoire & Instance()
Returns a pointer to the memory instance. Creates a new memory object if no instance has been created...
Definition Memoire.cpp:32
int suppr(int)
Removes from memory the Objet_U with index num. The Objet_U itself is not deleted; only its pointer i...
Definition Memoire.cpp:105
Memoire()
Constructor. Initializes a working area for Objet_U, "double", and "int" objects.
Definition Memoire.cpp:42
friend Sortie & operator<<(Sortie &, const Memoire &)
Output operator that prints the state of memory mem to output stream os.
Definition Memoire.cpp:412
int imprime() const
Prints a memory state summary to the error output stream.
Definition Memoire.cpp:347
int add(Objet_U *)
Adds an Objet_U to the TRUST memory.
Definition Memoire.cpp:54
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
Base class for output streams.
Definition Sortie.h:52