Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ExternalRef.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ExternalRef.cc (C) 2000-2019 */
9/* */
10/* Gestion d'une référence sur un objet externe au C++. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/base/ExternalRef.h"
15
16#include <iostream>
17
18/*---------------------------------------------------------------------------*/
19/*---------------------------------------------------------------------------*/
20
21namespace Arccore::Internal
22{
23namespace
24{
25ExternalRef::DestroyFuncType m_destroy_functor = nullptr;
26}
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31ExternalRef::Handle::
32~Handle()
33{
34 if (!handle)
35 return;
36 //std::cerr << "TRY DESTROY EXTERNAL Object f=" << m_destroy_functor << " h=" << handle << "\n";
37 if (m_destroy_functor && handle)
38 (*m_destroy_functor)(handle);
39}
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
44extern "C" ARCCORE_BASE_EXPORT void
45_SetExternalRefDestroyFunctor(ExternalRef::DestroyFuncType d)
46{
47 //std::cerr << "SET DESTROY FUNCTOR d=" << d << "\n";
48 m_destroy_functor = d;
49}
50
51/*---------------------------------------------------------------------------*/
52/*---------------------------------------------------------------------------*/
53
54} // End namespace Arccore::Internal
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58