Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TraceAccessor2.h
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/* TraceAccessor2.h (C) 2000-2020 */
9/* */
10/* Traces. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_TRACEACCESSOR2_H
13#define ARCANE_UTILS_TRACEACCESSOR2_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/String.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane::internal
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
31class ARCANE_UTILS_EXPORT TraceAccessor2
32: public TraceAccessor
33{
34 public:
36 public:
37 bool isActive() const { return m_is_active; }
38 private:
39 bool m_is_active = false;
40};
41
42template<typename T>
44{
45 public:
46 TracePrinter(const char* name,const T& r) : m_name(name), m_r(r){}
47 friend std::ostream& operator<<(std::ostream& o,const TracePrinter<T>& x)
48 {
49 o << " " << x.m_name << "=" << x.m_r;
50 return o;
51 }
52 public:
53 const char* m_name;
54 const T& m_r;
55};
56
57template<typename T>
58inline TracePrinter<T> makeTracePrinter(const char* name,const T& field_name)
59{
60 return TracePrinter<T>(name,field_name);
61}
62
63template<typename ...Args> String
64format2(const String& str,const Args& ...args)
65{
66 return String::format(str,args...);
67}
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71
72inline bool
73isTraceActive(const TraceAccessor2* tr)
74{
75 return tr->isActive();
76}
77
78#define A_TR(field_name) Arcane::internal::makeTracePrinter(#field_name,field_name)
79
80#define A_TR2(name,field_name) Arcane::internal::makeTracePrinter(name,field_name)
81
82#define A_INFO(...)\
83 do {\
84 if (Arcane::internal::isTraceActive(this)) { \
85 info() << Arcane::String::format(__VA_ARGS__); \
86 }\
87 } while(false)
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92} // End namespace Arcane
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97#endif
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
API EN COURS DE CONCEPTION. NE PAS UTILISER.
Interface du gestionnaire de traces.
Chaîne de caractères unicode.