-// Copyright (C) 2007-2016 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
//
// Author : Anthony Geay (CEA/DEN)
-#ifndef __PARAMEDMEM_MEDCOUPLINGAUTOREFCOUNTOBJECTPTR_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGAUTOREFCOUNTOBJECTPTR_HXX__
+#pragma once
#include "MEDCouplingRefCountObject.hxx"
#include "InterpKernelException.hxx"
MCAuto(const MCAuto& other):_ptr(0) { referPtr(other._ptr); }
MCAuto(T *ptr=0):_ptr(ptr) { }
~MCAuto() { destroyPtr(); }
+ void checkNotNull() const { if(!_ptr) throw INTERP_KERNEL::Exception("Pointer is nullptr !"); }
bool isNull() const { return _ptr==0; }
bool isNotNull() const { return !isNull(); }
void nullify() { destroyPtr(); _ptr=0; }
operator T *() { return _ptr; }
operator const T *() const { return _ptr; }
T *retn() { if(_ptr) _ptr->incrRef(); return _ptr; }
+ T *retnConstCast() const { if(_ptr) _ptr->incrRef(); return _ptr; }
T *iAmATrollConstCast() const { return _ptr; }
private:
void referPtr(T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); }
const T *_ptr;
};
}
-
-#endif