X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingRefCountObject.hxx;h=21014123e017bd3eddc1f1c734b962930938ffe3;hb=ffb8188e28b2b60ee207a8644286821bc4e8fcdc;hp=2c1e1640069331255f1aaea5189876c53e3f9759;hpb=378cb2ebe08f8f4543ef632b2bd5f77fe180f978;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.hxx b/src/MEDCoupling/MEDCouplingRefCountObject.hxx old mode 100755 new mode 100644 index 2c1e16400..21014123e --- a/src/MEDCoupling/MEDCouplingRefCountObject.hxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -18,24 +18,27 @@ // // Author : Anthony Geay (CEA/DEN) -#ifndef __PARAMEDMEM_MEDCOUPLINGREFCOUNTOBJECT_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGREFCOUNTOBJECT_HXX__ +#pragma once #include "MEDCoupling.hxx" #include +#include +#include #include #include #include -namespace ParaMEDMEM +namespace MEDCoupling { - typedef enum + enum class DeallocType { C_DEALLOC = 2, - CPP_DEALLOC = 3 - } DeallocType; + CPP_DEALLOC = 3, + C_DEALLOC_WITH_OFFSET = 4 + }; + //! The various spatial discretization of a field typedef enum { ON_CELLS = 0, @@ -45,6 +48,7 @@ namespace ParaMEDMEM ON_NODES_KR = 4 } TypeOfField; + //! The various temporal discretization of a field typedef enum { NO_TIME = 4, @@ -59,48 +63,71 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int MEDCouplingVersion(); MEDCOUPLING_EXPORT void MEDCouplingVersionMajMinRel(int& maj, int& minor, int& releas); MEDCOUPLING_EXPORT int MEDCouplingSizeOfVoidStar(); + MEDCOUPLING_EXPORT std::size_t MEDCouplingSizeOfIDs(); MEDCOUPLING_EXPORT bool MEDCouplingByteOrder(); MEDCOUPLING_EXPORT const char *MEDCouplingByteOrderStr(); - - class BigMemoryObject + MEDCOUPLING_EXPORT bool IsCXX11Compiled(); + + class MEDCOUPLING_EXPORT BigMemoryObject { public: - MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const; - MEDCOUPLING_EXPORT std::string getHeapMemorySizeStr() const; - MEDCOUPLING_EXPORT std::vector getDirectChildren() const; - MEDCOUPLING_EXPORT std::vector getAllTheProgeny() const; - MEDCOUPLING_EXPORT bool isObjectInTheProgeny(const BigMemoryObject *obj) const; - MEDCOUPLING_EXPORT static std::size_t GetHeapMemorySizeOfObjs(const std::vector& objs); - MEDCOUPLING_EXPORT virtual std::size_t getHeapMemorySizeWithoutChildren() const = 0; - MEDCOUPLING_EXPORT virtual std::vector getDirectChildrenWithNull() const = 0; - MEDCOUPLING_EXPORT virtual ~BigMemoryObject(); + std::size_t getHeapMemorySize() const; + std::string getHeapMemorySizeStr() const; + std::vector getDirectChildren() const; + std::vector getAllTheProgeny() const; + bool isObjectInTheProgeny(const BigMemoryObject *obj) const; + static std::size_t GetHeapMemorySizeOfObjs(const std::vector& objs); + virtual std::string getClassName() const { return "BigMemoryObject"; } + virtual std::size_t getHeapMemorySizeWithoutChildren() const = 0; + virtual std::vector getDirectChildrenWithNull() const = 0; + std::string debugHeapMemorySize() const; + virtual ~BigMemoryObject(); private: static std::size_t GetHeapMemoryOfSet(std::set& s1, std::set& s2); }; - class RefCountObjectOnly + class MEDCOUPLING_EXPORT RefCountObjectOnly { protected: - MEDCOUPLING_EXPORT RefCountObjectOnly(); - MEDCOUPLING_EXPORT RefCountObjectOnly(const RefCountObjectOnly& other); + RefCountObjectOnly(); + RefCountObjectOnly(const RefCountObjectOnly& other); public: - MEDCOUPLING_EXPORT bool decrRef() const; - MEDCOUPLING_EXPORT void incrRef() const; - MEDCOUPLING_EXPORT int getRCValue() const; - MEDCOUPLING_EXPORT RefCountObjectOnly& operator=(const RefCountObjectOnly& other); + bool decrRef() const; + void incrRef() const; + int getRCValue() const; + RefCountObjectOnly& operator=(const RefCountObjectOnly& other); protected: virtual ~RefCountObjectOnly(); private: - mutable int _cnt; + mutable std::atomic _cnt; }; - class RefCountObject : public RefCountObjectOnly, public BigMemoryObject + class MEDCOUPLING_EXPORT RefCountObject : public RefCountObjectOnly, public BigMemoryObject { protected: - MEDCOUPLING_EXPORT RefCountObject(); - MEDCOUPLING_EXPORT RefCountObject(const RefCountObject& other); - MEDCOUPLING_EXPORT virtual ~RefCountObject(); + RefCountObject(); + RefCountObject(const RefCountObject& other); + virtual ~RefCountObject(); + }; + + class MEDCOUPLING_EXPORT GlobalDict + { + public: + static GlobalDict *GetInstance(); + bool hasKey(const std::string& key) const; + std::string value(const std::string& key) const; + std::vector keys() const; + void erase(const std::string& key); + void clear(); + void setKeyValue(const std::string& key, const std::string& val); + void setKeyValueForce(const std::string& key, const std::string& val); + std::string printSelf() const; + private: + GlobalDict() { } + private: + static GlobalDict *UNIQUE_INSTANCE; + private: + std::map _my_map; }; } -#endif