1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDCouplingRefCountObject.hxx"
22 #include "MED_version.h"
26 using namespace ParaMEDMEM;
28 const char *ParaMEDMEM::MEDCouplingVersionStr()
30 return SALOMEMED_VERSION_STR;
33 int ParaMEDMEM::MEDCouplingVersion()
35 return SALOMEMED_VERSION;
38 void ParaMEDMEM::MEDCouplingVersionMajMinRel(int& maj, int& minor, int& releas)
40 int ver=SALOMEMED_VERSION;
41 maj=(ver & 0xFF0000) >> 16;
42 minor=(ver & 0xFF00) >> 8;
46 int ParaMEDMEM::MEDCouplingSizeOfVoidStar()
48 return 8*sizeof(std::size_t);
52 * If true is returned it is a LittleEndian machine.
53 * If false it is a BigEndian machine.
54 * \return the coding mode of integers of the machine.
56 bool ParaMEDMEM::MEDCouplingByteOrder()
59 unsigned char *xc(reinterpret_cast<unsigned char *>(&x));
63 const char *ParaMEDMEM::MEDCouplingByteOrderStr()
65 static const char LITTLEENDIAN_STR[]="LittleEndian";
66 static const char BIGENDIAN_STR[]="BigEndian";
67 if(MEDCouplingByteOrder())
68 return LITTLEENDIAN_STR;
73 RefCountObject::RefCountObject():_cnt(1)
77 RefCountObject::RefCountObject(const RefCountObject& other):_cnt(1)
82 * Do nothing here ! It is not a bug ( I hope :) ) because all subclasses that
83 * copies using operator= should not copy the ref counter of \a other !
85 RefCountObject& RefCountObject::operator=(const RefCountObject& other)
90 std::size_t RefCountObject::getHeapMemorySize() const
92 std::size_t ret(getHeapMemorySizeWithoutChildren());
93 std::vector<RefCountObject *> v(getDirectChildren());
94 std::set<RefCountObject *> s1,s2(v.begin(),v.end());
97 std::set<RefCountObject *> s3;
98 for(std::set<RefCountObject *>::const_iterator it=s2.begin();it!=s2.end();it++)
100 if(s1.find(*it)==s1.end())
102 ret+=(*it)->getHeapMemorySizeWithoutChildren();
104 std::vector<RefCountObject *> v2((*it)->getDirectChildren());
105 for(std::vector<RefCountObject *>::const_iterator it2=v2.begin();it2!=v2.end();it2++)
106 if(s1.find(*it2)==s1.end())
115 bool RefCountObject::decrRef() const
117 bool ret=((--_cnt)==0);
123 void RefCountObject::incrRef() const
128 int RefCountObject::getRCValue() const
133 RefCountObject::~RefCountObject()