Fix static analysis issues
[platform/core/appfw/app-installers.git] / src / common / utils / property.h
1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMMON_UTILS_PROPERTY_H_
6 #define COMMON_UTILS_PROPERTY_H_
7
8 #include <memory>
9 #include <utility>
10
11 /** Template class for defining smart attributes.
12  *
13  *  Property should be used when, given attribute needs to have pure
14  *  setter and getter. This template class will generate getter and setter.
15  *  It uses operator() overloading.
16  */
17 template<typename Type>
18 class Property {
19  public:
20   Property() {} // NOLINT
21   Property(const Type &val): value_(val) { } // NOLINT
22   Property(Type &&val): value_(std::move(val)) { } // NOLINT
23   const Type& get() const { return value_; }
24   Type& get() { return value_; }
25   void set(Type val) { value_ = std::move(val); }
26  private:
27   Type value_{};
28 };
29
30 #endif  // COMMON_UTILS_PROPERTY_H_