Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Properties.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/* Properties.cc (C) 2000-2020 */
9/* */
10/* Liste de propriétés. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/Properties.h"
15
16#include "arcane/utils/String.h"
17#include "arcane/utils/Array.h"
18#include "arcane/utils/TraceAccessor.h"
19#include "arcane/utils/TraceInfo.h"
20#include "arcane/utils/ArgumentException.h"
21#include "arcane/utils/FatalErrorException.h"
22
23#include "arcane/datatype/SmallVariant.h"
24#include "arcane/datatype/DataTypeTraits.h"
25
26#include "arcane/IPropertyMng.h"
27#include "arcane/ISerializer.h"
28
29#include <map>
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34namespace Arcane
35{
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
41{
42 public:
43
44 enum eType
45 {
46 PV_None = 0,
47
48 PV_ScalarReal = 1,
49 PV_ScalarInt32 = 2,
50 PV_ScalarInt64 = 3,
51 PV_ScalarBool = 4,
52 PV_ScalarString = 5,
53
54 PV_ArrayReal = 6,
55 PV_ArrayInt32 = 7,
56 PV_ArrayInt64 = 8,
57 PV_ArrayBool = 9,
58 PV_ArrayString = 10,
59 };
60 static const int NB_TYPE = 11;
61 private:
62
64 : m_int32(0), m_int64(0), m_real(0), m_bool(0), m_string(0), m_is_scalar(false), m_type(PV_None)
65 {
66 }
67
68 public:
70 {
71 delete m_int32;
72 delete m_int64;
73 delete m_real;
74 delete m_bool;
75 delete m_string;
76 }
77 static PropertyVariant* create(Int32ConstArrayView v)
78 {
80 p->m_int32 = new UniqueArray<Int32>(v);
81 p->m_type = PV_ArrayInt32;
82 return p;
83 }
84
85 static PropertyVariant* create(Int64ConstArrayView v)
86 {
88 p->m_int64 = new UniqueArray<Int64>(v);
89 p->m_type = PV_ArrayInt64;
90 return p;
91 }
92
93 static PropertyVariant* create(RealConstArrayView v)
94 {
96 p->m_real = new UniqueArray<Real>(v);
97 p->m_type = PV_ArrayReal;
98 return p;
99 }
100
101 static PropertyVariant* create(BoolConstArrayView v)
102 {
104 p->m_bool = new UniqueArray<bool>(v);
105 p->m_type = PV_ArrayBool;
106 return p;
107 }
108
109 static PropertyVariant* create(StringConstArrayView v)
110 {
112 p->m_string = new UniqueArray<String>(v);
113 p->m_type = PV_ArrayString;
114 return p;
115 }
116
117 static PropertyVariant* create(const SmallVariant& sv)
118 {
120 p->m_is_scalar = true;
121 p->m_scalar = sv;
122 switch(sv.type()){
123 case SmallVariant::TUnknown: p->m_type = PV_None; break;
124 case SmallVariant::TReal: p->m_type = PV_ScalarReal; break;
125 case SmallVariant::TInt32: p->m_type = PV_ScalarInt32; break;
126 case SmallVariant::TInt64: p->m_type = PV_ScalarInt64; break;
127 case SmallVariant::TBool: p->m_type = PV_ScalarBool; break;
128 case SmallVariant::TString: p->m_type = PV_ScalarString; break;
129 }
130 return p;
131 }
132
133 SmallVariant* getScalar()
134 {
135 if (!m_is_scalar)
136 return 0;
137 return &m_scalar;
138 }
139
140 UniqueArray<Int32>* get(Int32) const
141 {
142 return m_int32;
143 }
144
145 UniqueArray<Int64>* get(Int64) const
146 {
147 return m_int64;
148 }
149
150 UniqueArray<Real>* get(Real) const
151 {
152 return m_real;
153 }
154
155 UniqueArray<bool>* get(bool) const
156 {
157 return m_bool;
158 }
159
160 UniqueArray<String>* get(const String&) const
161 {
162 return m_string;
163 }
164
165 eType type() const { return m_type; }
166
167 private:
168
169 UniqueArray<Int32>* m_int32;
170 UniqueArray<Int64>* m_int64;
171 UniqueArray<Real>* m_real;
172 UniqueArray<bool>* m_bool;
173 UniqueArray<String>* m_string;
174 bool m_is_scalar;
175 eType m_type;
176 SmallVariant m_scalar;
177};
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
182class IPropertyType
183{
184 public:
185 virtual ~IPropertyType(){}
186 public:
187 virtual void print(std::ostream& o,PropertyVariant* v) =0;
188 virtual const String& typeName() const =0;
189 virtual void serializeReserve(ISerializer* s,PropertyVariant* v) =0;
190 virtual void serializePut(ISerializer* s,PropertyVariant* v) =0;
191};
192
193/*---------------------------------------------------------------------------*/
194/*---------------------------------------------------------------------------*/
195
196namespace
197{
198
199template<typename DataType>
200void _directPutScalar(ISerializer* s,const DataType& value)
201{
202 s->put(value);
203}
204
205void _directPutScalar(ISerializer* s,const bool& value)
206{
207 s->putByte(value);
208}
209
210template<typename DataType>
211void _directReserveScalar(ISerializer* s,const DataType&)
212{
213 s->reserve(DataTypeTraitsT<DataType>::type(),1);
214}
215
216void _directReserveScalar(ISerializer* s,const String& value)
217{
218 s->reserve(value);
219}
220
221template<typename DataType>
222void _directReserve(ISerializer* s,Span<const DataType> values)
223{
224 s->reserve(DT_Int64,1);
225 s->reserveSpan(DataTypeTraitsT<DataType>::type(),values.size());
226}
227
228
229void _directReserve(ISerializer* s,Span<const bool> values)
230{
231 Int64 n = values.size();
232 s->reserve(DT_Int64,1);
233 s->reserveSpan(DT_Byte,n);
234}
235
236void _directReserve(ISerializer* s,Span<const String> values)
237{
238 s->reserve(DT_Int64,1);
239 Int64 n = values.size();
240 for( Integer i=0; i<n; ++i )
241 s->reserve(values[i]);
242}
243
244template<typename DataType>
245void _directPut(ISerializer* s,Span<const DataType> values)
246{
247 s->putInt64(values.size());
248 s->putSpan(values);
249}
250
251void _directPut(ISerializer* s,Span<const bool> values)
252{
253 Int64 n = values.size();
254 s->putInt64(n);
255 UniqueArray<Byte> bytes(n);
256 for( Int64 i=0; i<n; ++i )
257 bytes[i] = values[i] ? 1 : 0;
258
259 s->putSpan(bytes);
260}
261
262void _directPut(ISerializer* s,Span<const String> values)
263{
264 Int64 n = values.size();
265 s->putInt64(n);
266 for( Integer i=0; i<n; ++i )
267 s->put(values[i]);
268}
269
270template<typename DataType>
271void _directGet(ISerializer* s,Array<DataType>& values)
272{
273 Int64 n = s->getInt64();
274 //std::cout << "GET_N=" << n << '\n';
275 values.resize(n);
276 s->getSpan(values);
277}
278
279void _directGet(ISerializer* s,Array<bool>& values)
280{
281 Int64 n = s->getInt64();
282 values.resize(n);
283
284 UniqueArray<Byte> bytes(n);
285 s->getSpan(bytes);
286
287 for( Integer i=0; i<n; ++i )
288 values[i] = (bytes[i]!=0);
289}
290
291void _directGet(ISerializer* s,Array<String>& values)
292{
293 Int64 n = s->getInt64();
294 values.resize(n);
295
296 for( Integer i=0; i<n; ++i )
297 s->get(values[i]);
298}
299}
300
301/*---------------------------------------------------------------------------*/
302/*---------------------------------------------------------------------------*/
303
304template<typename DataType>
306: public IPropertyType
307{
308 public:
309
311 {
312 m_type_name = DataTypeTraitsT<DataType>::name();
313 }
314
315 public:
316
317 void print(std::ostream& o,PropertyVariant* v) override
318 {
319 SmallVariant* x = v->getScalar();
320 DataType d = DataType();
321 x->value(d);
322 o << d;
323 }
324
325 const String& typeName() const override
326 {
327 return m_type_name;
328 }
329
330 void serializeReserve(ISerializer* s,PropertyVariant* v) override
331 {
332 SmallVariant* x = v->getScalar();
333 DataType d = DataType();
334 x->value(d);
336 }
337
338 void serializePut(ISerializer* s,PropertyVariant* v) override
339 {
340 SmallVariant* x = v->getScalar();
341 DataType d = DataType();
342 x->value(d);
343 _directPutScalar(s,d);
344 }
345
346 private:
347 String m_type_name;
348};
349
350/*---------------------------------------------------------------------------*/
351/*---------------------------------------------------------------------------*/
352
353template<typename DataType>
355: public IPropertyType
356{
357 public:
359 {
360 m_type_name = String(DataTypeTraitsT<DataType>::name()) + "[]";
361 }
362 public:
363 virtual void print(std::ostream& o,PropertyVariant* v)
364 {
365 UniqueArray<DataType>* x = v->get(DataType());
366 Integer n = x->size();
367 o << "(size=" << n;
368 if (n>=1){
369 for( Integer i=0; i<n; ++i )
370 o << ',' << '[' << i << "]=" << x->operator[](i);
371 }
372 o << ')';
373 }
374 virtual const String& typeName() const
375 {
376 return m_type_name;
377 }
378 virtual void serializeReserve(ISerializer* s,PropertyVariant* v)
379 {
380 UniqueArray<DataType>* x = v->get(DataType());
381 //s->reserve(DataTypeTraitsT<DataType>::type(),x->size());
382 _directReserve(s,x->constSpan());
383 }
384 virtual void serializePut(ISerializer* s,PropertyVariant* v)
385 {
386 UniqueArray<DataType>* x = v->get(DataType());
387 _directPut(s,x->constSpan());
388 }
389 private:
390 String m_type_name;
391};
392
393/*---------------------------------------------------------------------------*/
394/*---------------------------------------------------------------------------*/
401: public PropertiesImplBase
402, public TraceAccessor
403{
404 public:
405
406 // A modifier si les sérialisations sont modifiées et incompatibles avec les
407 // anciennes versions. La version 2 (décembre 2019) utilise la sérialisation
408 // des chaînes de caractères sur un Int64.
409 static const Int32 SERIALIZE_VERSION = 2;
410
411 public:
412
413 typedef std::map<String,PropertyVariant*> MapType;
414
415 public:
416
417 PropertiesImpl(IPropertyMng* pm,const String& name);
419
420 public:
421
422 virtual void deleteMe() { delete this; }
423
424 public:
425
426 IPropertyMng* m_property_mng;
427 PropertiesImpl* m_parent_property;
428 String m_name;
429 String m_full_name;
430 MapType m_property_map;
432
433 public:
434
435 template<typename DataType>
436 bool getScalarValue(const String& name,DataType& value)
437 {
438 typename MapType::const_iterator v = m_property_map.find(name);
439 if (v==m_property_map.end()){
440 return false;
441 }
442
443 SmallVariant* x = v->second->getScalar();
444 if (!x)
445 throw ArgumentException(A_FUNCINFO,"Bad data dimension for property (expecting scalar but property is array)");
446 x->value(value);
447 return true;
448 }
449
450 template<typename DataType>
451 void _setScalarValue(SmallVariant& s,const DataType& value)
452 {
453 s.setValueAll(value);
454 }
455 void _setScalarValue(SmallVariant& s,const String& value)
456 {
457 s.setValue(value);
458 }
459
460 template<typename DataType>
461 DataType setScalarValue(const String& name,const DataType& value)
462 {
463 DataType old_value = DataType();
464 MapType::iterator v = m_property_map.find(name);
465 if (v!=m_property_map.end()){
466 SmallVariant* x = v->second->getScalar();
467 if (!x)
468 throw ArgumentException(A_FUNCINFO,"Bad data dimension for property (expecting scalar but property is array)");
469 // Récupère l'ancienne valeur
470 x->value(old_value);
471 _setScalarValue(*x,value);
472 }
473 else{
474 SmallVariant sv;
475 _setScalarValue(sv,value);
476 m_property_map.insert(std::make_pair(name,PropertyVariant::create(sv)));
477 }
478 return old_value;
479 }
480
481 template<typename DataType>
482 void setArrayValue(const String& name,ConstArrayView<DataType> value)
483 {
484 MapType::iterator v = m_property_map.find(name);
485 if (v!=m_property_map.end()){
486 UniqueArray<DataType>* x = v->second->get(DataType());
487 if (!x)
488 throw ArgumentException(A_FUNCINFO,"Bad datatype for property");
489 x->copy(value);
490 }
491 else{
492 m_property_map.insert(std::make_pair(name,PropertyVariant::create(value)));
493 }
494 }
495
496 template<typename DataType>
497 void getArrayValue(const String& name,Array<DataType>& value)
498 {
499 MapType::const_iterator v = m_property_map.find(name);
500 if (v==m_property_map.end()){
501 value.clear();
502 return;
503 }
504 UniqueArray<DataType>* x = v->second->get(DataType());
505 if (!x)
506 throw ArgumentException(A_FUNCINFO,"Bad datatype for property");
507 value.copy(*x);
508 }
509
510 public:
511
512 void print(std::ostream& o);
513
514 void serialize(ISerializer* serializer);
515
516 void serializeReserve(ISerializer* serializer);
517 void serializePut(ISerializer* serializer);
518 void serializeGet(ISerializer* serializer);
519
520 private:
521
522 template<typename DataType> void
523 _serializeGetArray(ISerializer* serializer,const String& name,const DataType&)
524 {
525 UniqueArray<DataType> values;
526 _directGet(serializer,values);
527 setArrayValue(name,values.constView());
528 }
529};
530
531/*---------------------------------------------------------------------------*/
532/*---------------------------------------------------------------------------*/
533
534PropertiesImpl::
535PropertiesImpl(IPropertyMng* pm,const String& name)
536: TraceAccessor(pm->traceMng())
537, m_property_mng(pm)
538, m_parent_property(0)
539, m_name(name)
540, m_full_name(name)
541{
542 m_types.resize(PropertyVariant::NB_TYPE);
543 m_types.fill(0);
544 m_types[PropertyVariant::PV_ScalarReal] = new ScalarPropertyType<Real>();
545 m_types[PropertyVariant::PV_ScalarInt32] = new ScalarPropertyType<Int32>();
546 m_types[PropertyVariant::PV_ScalarInt64] = new ScalarPropertyType<Int64>();
547 m_types[PropertyVariant::PV_ScalarBool] = new ScalarPropertyType<bool>();
548 m_types[PropertyVariant::PV_ScalarString] = new ScalarPropertyType<String>();
549
550 m_types[PropertyVariant::PV_ArrayReal] = new ArrayPropertyType<Real>();
551 m_types[PropertyVariant::PV_ArrayInt32] = new ArrayPropertyType<Int32>();
552 m_types[PropertyVariant::PV_ArrayInt64] = new ArrayPropertyType<Int64>();
553 m_types[PropertyVariant::PV_ArrayBool] = new ArrayPropertyType<bool>();
554 m_types[PropertyVariant::PV_ArrayString] = new ArrayPropertyType<String>();
555}
556
557/*---------------------------------------------------------------------------*/
558/*---------------------------------------------------------------------------*/
559
560PropertiesImpl::
561~PropertiesImpl()
562{
563 MapType::iterator v = m_property_map.begin();
564 MapType::iterator vend = m_property_map.end();
565 for( ; v!=vend; ++v )
566 delete v->second;
567
568 for( Integer i=0, n=m_types.size(); i<n; ++i )
569 delete m_types[i];
570
571 info(5) << "DESTROY PROPERTY name=" << m_name << " this=" << this;
572}
573
574/*---------------------------------------------------------------------------*/
575/*---------------------------------------------------------------------------*/
576
577void PropertiesImpl::
578print(std::ostream& o)
579{
580 MapType::iterator v = m_property_map.begin();
581 MapType::iterator vend = m_property_map.end();
582 for( ; v!=vend; ++v ){
583 PropertyVariant* p = v->second;
584 PropertyVariant::eType et = p->type();
585 IPropertyType* pt = m_types[et];
586 o << " " << v->first << " = ";
587 if (pt){
588 o << "(" << pt->typeName();
589 o << ") ";
590 pt->print(o,p);
591 }
592 else{
593 o << "??";
594 }
595 o << '\n';
596 }
597}
598
599/*---------------------------------------------------------------------------*/
600/*---------------------------------------------------------------------------*/
601
602void PropertiesImpl::
603serialize(ISerializer* serializer)
604{
605 switch(serializer->mode()){
606 case ISerializer::ModeReserve:
607 serializeReserve(serializer);
608 break;
610 serializePut(serializer);
611 break;
613 serializeGet(serializer);
614 break;
615 }
616}
617
618/*---------------------------------------------------------------------------*/
619/*---------------------------------------------------------------------------*/
620
621void PropertiesImpl::
622serializeReserve(ISerializer* serializer)
623{
624 serializer->reserve(DT_Int32,1); // SERIALIZE_VERSION
625 serializer->reserve(DT_Int64,1); // Nombre d'éléments dans la map
626
627 MapType::iterator v = m_property_map.begin();
628 MapType::iterator vend = m_property_map.end();
629 for( ; v!=vend; ++v ){
630 PropertyVariant* p = v->second;
631 PropertyVariant::eType et = p->type();
632 serializer->reserve(DT_Int32,1);
633 serializer->reserve(v->first);
634 IPropertyType* pt = m_types[et];
635 pt->serializeReserve(serializer,p);
636 }
637}
638
639/*---------------------------------------------------------------------------*/
640/*---------------------------------------------------------------------------*/
641
642void PropertiesImpl::
643serializePut(ISerializer* serializer)
644{
645 serializer->putInt32(SERIALIZE_VERSION);
646
647 Int64 n = (Int64)m_property_map.size();
648 serializer->putInt64(n);
649
650 MapType::iterator v = m_property_map.begin();
651 MapType::iterator vend = m_property_map.end();
652 for( ; v!=vend; ++v ){
653 PropertyVariant* p = v->second;
654 PropertyVariant::eType et = p->type();
655 IPropertyType* pt = m_types[et];
656 serializer->putInt32(et);
657 serializer->put(v->first);
658 pt->serializePut(serializer,p);
659 }
660}
661
662/*---------------------------------------------------------------------------*/
663/*---------------------------------------------------------------------------*/
664
665void PropertiesImpl::
666serializeGet(ISerializer* serializer)
667{
668 Int64 version = serializer->getInt32();
669 if (version!=SERIALIZE_VERSION){
670 // La relecture se fait avec une protection issue d'une ancienne version de Arcane
671 // et qui n'est pas compatible. Affiche un avertissement et ne fait rien.
672 // (NOTE: cela risque quand même de poser problême pour ceux qui utilisent les
673 // propriétés donc il faudrait peut-être faire un fatal ?)
674 pwarning() << "Can not reading properties from imcompatible checkpoint";
675 return;
676 }
677
678 Int64 n = serializer->getInt64();
679 String name;
680 for( Integer i=0; i<n; ++i ){
681 Int32 type = serializer->getInt32();
682 serializer->get(name);
683 //std::cout << "TYPE=" << type << " name=" << name << '\n';
684 //TODO: Verifier validités des valeurs + faire ca proprement sans switch
685 switch(type){
686 case PropertyVariant::PV_ScalarReal: setScalarValue(name,serializer->getReal()); break;
687 case PropertyVariant::PV_ScalarInt32:setScalarValue(name,serializer->getInt32()); break;
688 case PropertyVariant::PV_ScalarInt64:setScalarValue(name,serializer->getInt64()); break;
689 case PropertyVariant::PV_ScalarBool: setScalarValue(name,(bool)serializer->getByte()); break;
690 case PropertyVariant::PV_ScalarString: { String str; serializer->get(str); setScalarValue(name,str); } break;
691
692 case PropertyVariant::PV_ArrayReal: _serializeGetArray(serializer,name,Real()); break;
693 case PropertyVariant::PV_ArrayInt32:_serializeGetArray(serializer,name,Int32()); break;
694 case PropertyVariant::PV_ArrayInt64:_serializeGetArray(serializer,name,Int64()); break;
695 case PropertyVariant::PV_ArrayBool:_serializeGetArray(serializer,name,bool()); break;
696 case PropertyVariant::PV_ArrayString:_serializeGetArray(serializer,name,String()); break;
697 default:
698 throw FatalErrorException(A_FUNCINFO,"Bad type");
699 }
700 }
701}
702
703/*---------------------------------------------------------------------------*/
704/*---------------------------------------------------------------------------*/
705
706/*---------------------------------------------------------------------------*/
707/*---------------------------------------------------------------------------*/
708
711: m_p(0)
712, m_ref(0)
713{
714 PropertiesImpl* pi = pm->getPropertiesImpl(aname);
715 bool has_create = false;
716 if (!pi){
717 pi = new PropertiesImpl(pm,aname);
718 has_create = true;
719 }
720 m_p = pi;
721 m_ref = pi;
722 if (has_create)
723 pm->registerProperties(*this);
724}
725
726/*---------------------------------------------------------------------------*/
727/*---------------------------------------------------------------------------*/
728
731{
732 String full_name = parent_property.fullName()+"."+aname;
733 IPropertyMng* pm = parent_property.propertyMng();
734 PropertiesImpl* pi = pm->getPropertiesImpl(full_name);
735
736 bool has_create = false;
737 if (!pi){
738 pi = new PropertiesImpl(pm,full_name);
739 has_create = true;
740 }
741 m_p = pi;
742 m_ref = pi;
743 if (has_create)
744 pm->registerProperties(*this);
745}
746
747/*---------------------------------------------------------------------------*/
748/*---------------------------------------------------------------------------*/
749
752: m_p(p)
753, m_ref(m_p)
754{
755}
756
757/*---------------------------------------------------------------------------*/
758/*---------------------------------------------------------------------------*/
759
764
765/*---------------------------------------------------------------------------*/
766/*---------------------------------------------------------------------------*/
767
770: m_p(rhs.m_p)
771, m_ref(rhs.m_ref)
772{
773}
774
775/*---------------------------------------------------------------------------*/
776/*---------------------------------------------------------------------------*/
777
780{
781 if (&rhs!=this){
782 m_p = rhs.m_p;
783 m_ref = rhs.m_ref;
784 }
785 return (*this);
786}
787
788/*---------------------------------------------------------------------------*/
789/*---------------------------------------------------------------------------*/
790
792setBool(const String& aname,bool value)
793{
794 m_p->setScalarValue(aname,value);
795}
797set(const String& aname,bool value)
798{
799 setBool(aname,value);
800}
803{
804 bool v = default_value;
805 get(aname,v);
806 return v;
807}
809getBool(const String& aname) const
810{
811 return getBoolWithDefault(aname,false);
812}
814get(const String& aname,bool& value) const
815{
816 return m_p->getScalarValue(aname,value);
817}
818
819/*---------------------------------------------------------------------------*/
820/*---------------------------------------------------------------------------*/
821
823setInt32(const String& aname,Int32 value)
824{
825 m_p->setScalarValue(aname,value);
826}
828set(const String& aname,Int32 value)
829{
830 setInt32(aname,value);
831}
833getInt32WithDefault(const String& name,Int32 default_value) const
834{
835 Int32 v = default_value;
836 m_p->getScalarValue(name,v);
837 return v;
838}
840getInt32(const String& name) const
841{
842 return getInt32WithDefault(name,0);
843}
845get(const String& name,Int32& value) const
846{
847 return m_p->getScalarValue(name,value);
848 //value = getInt32(name);
849}
850
851/*---------------------------------------------------------------------------*/
852/*---------------------------------------------------------------------------*/
853
855setInt64(const String& aname,Int64 value)
856{
857 m_p->setScalarValue(aname,value);
858}
860set(const String& aname,Int64 value)
861{
862 setInt64(aname,value);
863}
866{
867 Int64 v = default_value;
868 m_p->getScalarValue(aname,v);
869 return v;
870}
872getInt64(const String& aname) const
873{
874 return getInt64WithDefault(aname,0);
875}
877get(const String& aname,Int64& value) const
878{
879 return m_p->getScalarValue(aname,value);
880}
881
882/*---------------------------------------------------------------------------*/
883/*---------------------------------------------------------------------------*/
884
886setInteger(const String& aname,Integer value)
887{
888 set(aname,value);
889}
892{
893 Integer x = default_value;
894 m_p->getScalarValue(aname,x);
895 return x;
896}
898getInteger(const String& name) const
899{
900 return getIntegerWithDefault(name,0);
901}
902
903/*---------------------------------------------------------------------------*/
904/*---------------------------------------------------------------------------*/
905
907setReal(const String& aname,Real value)
908{
909 m_p->setScalarValue(aname,value);
910}
912set(const String& aname,Real value)
913{
914 setReal(aname,value);
915}
918{
919 Real v = default_value;
920 m_p->getScalarValue(aname,v);
921 return v;
922}
924getReal(const String& aname) const
925{
926 return getRealWithDefault(aname,0.0);
927}
929get(const String& aname,Real& value) const
930{
931 return m_p->getScalarValue(aname,value);
932}
933
934/*---------------------------------------------------------------------------*/
935/*---------------------------------------------------------------------------*/
936
938setString(const String& aname,const String& value)
939{
940 m_p->setScalarValue(aname,value);
941}
943set(const String& aname,const String& value)
944{
945 setString(aname,value);
946}
949{
951 m_p->getScalarValue(aname,v);
952 return v;
953}
955getString(const String& aname) const
956{
958}
960get(const String& aname,String& value) const
961{
962 return m_p->getScalarValue(aname,value);
963}
964
965/*---------------------------------------------------------------------------*/
966/*---------------------------------------------------------------------------*/
967
970{
971 m_p->setArrayValue(aname,value);
972}
974get(const String& aname,BoolArray& value) const
975{
976 m_p->getArrayValue(aname,value);
977}
978
979/*---------------------------------------------------------------------------*/
980/*---------------------------------------------------------------------------*/
981
984{
985 m_p->setArrayValue(aname,value);
986}
988get(const String& aname,Int32Array& value) const
989{
990 m_p->getArrayValue(aname,value);
991}
992
993/*---------------------------------------------------------------------------*/
994/*---------------------------------------------------------------------------*/
995
998{
999 m_p->setArrayValue(aname,value);
1000}
1002get(const String& aname,Int64Array& value) const
1003{
1004 m_p->getArrayValue(aname,value);
1005}
1006
1007/*---------------------------------------------------------------------------*/
1008/*---------------------------------------------------------------------------*/
1009
1011set(const String& aname,RealConstArrayView value)
1012{
1013 m_p->setArrayValue(aname,value);
1014}
1016get(const String& aname,RealArray& value) const
1017{
1018 m_p->getArrayValue(aname,value);
1019}
1020
1021/*---------------------------------------------------------------------------*/
1022/*---------------------------------------------------------------------------*/
1023
1026{
1027 m_p->setArrayValue(aname,value);
1028}
1030get(const String& aname,StringArray& value) const
1031{
1032 m_p->getArrayValue(aname,value);
1033}
1034
1035/*---------------------------------------------------------------------------*/
1036/*---------------------------------------------------------------------------*/
1037
1039print(std::ostream& o) const
1040{
1041 m_p->print(o);
1042}
1043
1044/*---------------------------------------------------------------------------*/
1045/*---------------------------------------------------------------------------*/
1046
1048serialize(ISerializer* serializer)
1049{
1050 m_p->serialize(serializer);
1051}
1052
1053/*---------------------------------------------------------------------------*/
1054/*---------------------------------------------------------------------------*/
1055
1057name() const
1058{
1059 return m_p->m_name;
1060}
1061
1062/*---------------------------------------------------------------------------*/
1063/*---------------------------------------------------------------------------*/
1064
1066fullName() const
1067{
1068 return m_p->m_full_name;
1069}
1070
1071/*---------------------------------------------------------------------------*/
1072/*---------------------------------------------------------------------------*/
1073
1074IPropertyMng* Properties::
1075propertyMng() const
1076{
1077 return m_p->m_property_mng;
1078}
1079
1080/*---------------------------------------------------------------------------*/
1081/*---------------------------------------------------------------------------*/
1082
1084destroy()
1085{
1086 m_p->m_property_mng->destroyProperties(*this);
1087}
1088
1089/*---------------------------------------------------------------------------*/
1090/*---------------------------------------------------------------------------*/
1091
1092} // End namespace Arcane
1093
1094/*---------------------------------------------------------------------------*/
1095/*---------------------------------------------------------------------------*/
Tableau d'items de types quelconques.
Interface du gestionnaire des propriétés.
virtual void destroyProperties(const Properties &p)=0
Supprime les propriétés référencées par p.
Interface d'un type de propriété.
Definition IProperty.h:105
virtual ~IPropertyType()
Libère les ressources.
Definition IProperty.h:108
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
virtual void deleteMe()
Détruit l'objet référencé
Liste de propriétés.
Definition Properties.h:64
Int64 getInt64(const String &name) const
Valeur de la propriété de nom name.
bool get(const String &name, bool &value) const
Valeur de la propriété de nom name.
bool getBoolWithDefault(const String &name, bool default_value) const
Valeur de la propriété de nom name.
const String & name() const
Nom de la propriété.
Int32 getInt32WithDefault(const String &name, Int32 default_value) const
Valeur de la propriété de nom name.
Int32 getInt32(const String &name) const
Valeur de la propriété de nom name.
Integer getInteger(const String &name) const
Valeur de la propriété de nom name.
Integer getIntegerWithDefault(const String &name, Integer default_value) const
Valeur de la propriété de nom name.
bool getBool(const String &name) const
Valeur de la propriété de nom name.
void setInteger(const String &name, Integer value)
Positionne une propriété de type Integer de nom name et de valeur value.
void setInt64(const String &name, Int64 value)
Positionne une propriété de type Int64 de nom name et de valeur value.
void destroy()
Supprime les valeurs associées des propriétés associées à cette référence.
Real getReal(const String &name) const
Valeur de la propriété de nom name.
void setInt32(const String &name, Int32 value)
Positionne une propriété de type Int32 de nom name et de valeur value.
Int64 getInt64WithDefault(const String &name, Int64 default_value) const
Valeur de la propriété de nom name.
void set(const String &name, bool value)
Positionne une propriété de type bool de nom name et de valeur value.
String getString(const String &name) const
Valeur de la propriété de nom name.
Real getRealWithDefault(const String &name, Real default_value) const
Valeur de la propriété de nom name.
const Properties & operator=(const Properties &rhs)
Opérateur de recopie.
String getStringWithDefault(const String &name, const String &default_value) const
Valeur de la propriété de nom name.
void serialize(ISerializer *serializer)
Effectue la sérialisation des propriétés.
Properties(IPropertyMng *pm, const String &name)
Créé ou récupère une liste de propriétés de nom name.
virtual ~Properties()
Détruit la référence à cette propriété
void setBool(const String &name, bool value)
Positionne une propriété de type bool de nom name et de valeur value.
void setString(const String &name, const String &value)
Positionne une propriété de type String de nom name et de valeur value.
const String & fullName() const
Nom complet de la propriété.
void print(std::ostream &o) const
Sort les propriétés et leurs valeurs sur le flot o.
void setReal(const String &name, Real value)
Positionne une propriété de type Real de nom name et de valeur value.
Classe gérant un type polymorphe.
Vue constante d'un tableau de type T.
Chaîne de caractères unicode.
TraceMessage pwarning() const
TraceMessage info() const
Flot pour un message d'information.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
@ DT_Int32
Donnée de type entier 32 bits.
Definition DataTypes.h:43
@ DT_Int64
Donnée de type entier 64 bits.
Definition DataTypes.h:44
@ DT_Byte
Donnée de type octet.
Definition DataTypes.h:40