Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
ownership_policy.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Roc Streaming authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_core/ownership_policy.h
10 //! @brief Ownership policies.
11 
12 #ifndef ROC_CORE_OWNERSHIP_POLICY_H_
13 #define ROC_CORE_OWNERSHIP_POLICY_H_
14 
15 namespace roc {
16 namespace core {
17 
18 template <class T, template <class TT> class Ownership> class SharedPtr;
19 
20 //! Reference counted object ownership.
21 template <class T> struct RefCountedOwnership {
22  //! Pointer type returned from containers.
24 
25  //! Acquire ownership.
26  static void acquire(T& object) {
27  object.incref();
28  }
29 
30  //! Release ownership.
31  static void release(T& object) {
32  object.decref();
33  }
34 };
35 
36 //! No ownership.
37 template <class T> struct NoOwnership {
38  //! Pointer type returned from containers.
39  typedef T* Pointer;
40 
41  //! Acquire ownership.
42  static void acquire(T&) {
43  }
44 
45  //! Release ownership.
46  static void release(T&) {
47  }
48 };
49 
50 } // namespace core
51 } // namespace roc
52 
53 #endif // ROC_CORE_OWNERSHIP_POLICY_H_
Shared ownership intrusive pointer.
Definition: shared_ptr.h:32
Root namespace.
static void acquire(T &)
Acquire ownership.
static void release(T &)
Release ownership.
T * Pointer
Pointer type returned from containers.
Reference counted object ownership.
SharedPtr< T, core::RefCountedOwnership > Pointer
Pointer type returned from containers.
static void acquire(T &object)
Acquire ownership.
static void release(T &object)
Release ownership.