1 // Copyright (C) 2006-2014 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, or (at your option) any later version.
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
20 #ifndef __SHAREDPTR_HXX__
21 #define __SHAREDPTR_HXX__
24 * \brief: Allow to manage memory of instances of T.
25 * The only constraint on T is to have method incrRef and DecrRef.
26 * Typically T inherits from YACS::ENGINE::RefCounter.
34 SharedPtr(T *ptr):_ptr(ptr) { }
35 SharedPtr(const SharedPtr<T>& other):_ptr(other._ptr) { _ptr->incrRef(); }
36 SharedPtr<T> &operator=(const SharedPtr<T>& other);
37 T &operator*() { return *_ptr; }
38 const T &operator*() const { return *_ptr; }
39 T *operator->() { return _ptr; }
40 const T *operator->() const { return _ptr; }
41 ~SharedPtr() { _ptr->decrRef(); }
42 operator T *() { return _ptr; }
43 operator const T *() const { return _ptr; }
44 operator T &() { return *_ptr; }
45 operator const T &() const { return *_ptr; }
46 SharedPtr<T> operator[](int i) const;
47 SharedPtr<T> operator[](const char *key) const;
51 SharedPtr<T> &SharedPtr<T>::operator=(const SharedPtr<T>& other)
60 SharedPtr<T> SharedPtr<T>::operator[](int i) const
66 SharedPtr<T> SharedPtr<T>::operator[](const char *key) const