2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief This file is the implementation file of scoped pointer RAII
22 * This module is deprecated, please use standard C++11 feature: std::unique_ptr
24 #ifndef DPL_SCOPED_PTR_H
25 #define DPL_SCOPED_PTR_H
29 #include <dpl/scoped_resource.h>
30 #include <dpl/assert.h>
31 #include <dpl/availability.h>
34 template<typename Class>
35 struct ScopedPtrPolicy
38 static Type NullValue()
42 static void Destroy(Type ptr)
48 template<typename Class, typename ClassPolicy = ScopedPtrPolicy<Class> >
49 class ScopedPtr : public ScopedResource<ClassPolicy>
51 typedef ClassPolicy Policy;
52 typedef ScopedResource<Policy> BaseType;
55 explicit ScopedPtr(Class *ptr = Policy::NullValue()) : BaseType(ptr) { }
57 Class *operator->() const throw()
59 Assert(this->m_value != Policy::NullValue() &&
60 "Dereference of scoped NULL pointer!");
64 Class &operator *() const throw()
66 Assert(this->m_value != Policy::NullValue() &&
67 "Dereference of scoped NULL pointer!");
68 return *this->m_value;
70 } DPL_DEPRECATED_WITH_MESSAGE("use standard C++11 feature: std::unique_ptr");
73 #endif // DPL_SCOPED_PTR_H