TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
MD_Vector.cpp
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#include <MD_Vector.h>
17#include <Memoire.h>
18
19//Implemente_base_sans_constructeur_ni_destructeur(MD_Vector_base,"MD_Vector_base",Objet_U);
20
21/*! @brief Constructs an MD_Vector object by copying an existing object.
22 *
23 * This is the recommended method for creating an MD_Vector object (other than
24 * by copying another MD_Vector).
25 */
27{
28 int num_obj = src.duplique();
29 MD_Vector_base * p = dynamic_cast<MD_Vector_base *>(Memoire::Instance().objet_u_ptr(num_obj));
30 assert(p!= nullptr);
31 ptr_.reset(p);
32}
33
34/*! @brief Returns 1 if the structures are identical, 0 otherwise.
35 *
36 */
37int MD_Vector::operator==(const MD_Vector& md) const
38{
39 // For now, very strict test: the two structures are
40 // identical if and only if the pointers are identical,
41 // (i.e. the second was created by copying the first).
42 // If we want to remove the multi-reference system and duplicate
43 // the structures on copy, a full equality test
44 // over the entire structure must be done!
45 return ptr_ == md.ptr_;
46}
47
48/*! @brief Inverse of ==.
49 */
50int MD_Vector::operator!=(const MD_Vector& md) const
51{
52 return !operator==(md);
53}
Base class for distributed vectors parallel descriptors.
void copy(const MD_Vector_base &)
Constructs an MD_Vector object by copying an existing object.
Definition MD_Vector.cpp:26
int operator!=(const MD_Vector &) const
Inverse of ==.
Definition MD_Vector.cpp:50
int operator==(const MD_Vector &) const
Returns 1 if the structures are identical, 0 otherwise.
Definition MD_Vector.cpp:37
Objet_U * objet_u_ptr(int)
Returns a pointer to the Objet_U at index num in memory.
Definition Memoire.cpp:258
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
virtual int duplique() const =0