14#include "arcane/utils/TraceAccessor.h"
15#include "arcane/utils/String.h"
16#include "arcane/utils/Ref.h"
18#include "arcane/core/IPropertyMng.h"
19#include "arcane/core/Properties.h"
20#include "arcane/core/ISerializer.h"
21#include "arcane/core/SerializeBuffer.h"
22#include "arcane/core/VariableTypes.h"
23#include "arcane/core/Observable.h"
45 static const Int32 SERIALIZE_VERSION = 1;
50 ~PropertyMng()
override;
68 void print(std::ostream& o)
const override;
75 typedef std::map<String, Properties> PropertiesMapType;
77 PropertiesMapType m_properties_map;
86extern "C++" IPropertyMng*
87arcaneCreatePropertyMng(ITraceMng* tm)
89 auto pm =
new PropertyMng(tm);
98arcaneCreatePropertyMngReference(
ITraceMng* tm)
100 auto pm = arcaneCreatePropertyMng(tm);
110, m_property_values_var(nullptr)
120 delete m_property_values_var;
141 auto v = m_properties_map.find(full_name);
142 if (v != m_properties_map.end())
143 return v->second.impl();
154 m_properties_map.insert(std::make_pair(p.
fullName(), p));
163 auto v = m_properties_map.find(p.
fullName());
164 if (v != m_properties_map.end())
165 m_properties_map.erase(v);
174 switch (serializer->
mode()) {
175 case ISerializer::ModeReserve:
181 for (
auto& v : m_properties_map) {
184 v.second.serialize(serializer);
188 serializer->
putInt32(SERIALIZE_VERSION);
189 serializer->
putInt64(m_properties_map.size());
191 for (
auto& v : m_properties_map) {
192 serializer->
put(v.first);
194 v.second.serialize(serializer);
200 if (version != SERIALIZE_VERSION) {
205 pwarning() <<
"Can not reading properties from imcompatible checkpoint";
211 for (
Integer i = 0; i < n; ++i) {
212 serializer->
get(name);
227 m_write_observable.notifyAllObservers();
231 sb.
setMode(ISerializer::ModeReserve);
238 info(4) <<
"SaveProperties nb_byte=" << buf_bytes.
size();
239 bytes.copy(buf_bytes);
248 info(4) <<
"ReadProperties nb_read_byte=" << bytes.size();
255 m_read_observable.notifyAllObservers();
265print(std::ostream& o)
const
267 for (
const auto& v : m_properties_map) {
Observable that automatically calls IObservable::detachAllObservers() in the destructor.
void initFromBuffer(Span< const Byte > buf)
Initializes the serializer for reading from the data buf.
void setSerializeTypeInfo(bool v)
Indicates whether to serialize the data type to ensure consistency.
void allocateBuffer() override
Allocates the serializer memory.
void setMode(eMode new_mode) override
Sets the current mode.
Interface of an observable.
Interface of the property manager.
void reserveInt64(Int64 n)
Reserve for n Int64.
virtual void reserve(eBasicDataType dt, Int64 n)=0
Reserves memory for n objects of type dt.
void reserveInt32(Int64 n)
Reserve for n Int32.
@ ModePut
The serializer expects reserve().
@ ModeGet
The serializer expects get().
virtual Int64 getInt64()=0
Retrieve a size.
virtual void put(Span< const Real > values)=0
Add the array values.
virtual void putInt32(Int32 value)=0
Add the integer value.
virtual eMode mode() const =0
Current operating mode.
virtual Int32 getInt32()=0
Retrieve an integer.
virtual void get(ArrayView< Real > values)=0
Retrieve the array values.
virtual void putInt64(Int64 value)=0
Add the integer value.
void serialize(ISerializer *serializer)
Performs the serialization of the properties.
const String & fullName() const
Full name of the property.
void print(std::ostream &o) const
Prints the properties and their values to the stream o.
void print(std::ostream &o) const override
Displays the properties and their values on the stream o.
void destroyProperties(const Properties &p) override
Deletes the properties referenced by p.
IObservable * readObservable() override
Observable for reading.
IObservable * writeObservable() override
Observable for writing.
void serialize(ISerializer *serializer) override
Performs serialization.
PropertiesImpl * getPropertiesImpl(const String &full_name) override
Retrieves the list of properties by full name full_name.
void writeTo(ByteArray &bytes) override
Serializes property information into bytes.
void registerProperties(const Properties &p) override
Registers the properties referenced by p.
void readFrom(Span< const Byte > bytes) override
Reads the serialized information contained in bytes.
Reference to an instance.
Implementation of a buffer for serialization.
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
View of an array of elements of type T.
Unicode character string.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage info() const
Flow for an information message.
ITraceMng * traceMng() const
Trace manager.
TraceMessage pwarning() const
VariableRefArrayT< Byte > VariableArrayByte
Array variable of byte type.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
std::int32_t Int32
Signed integer type of 32 bits.