Twitch SDK (Internal)
raiiwrapper.h
Go to the documentation of this file.
1 /********************************************************************************************
2 * Twitch Broadcasting SDK
3 *
4 * This software is supplied under the terms of a license agreement with Twitch Interactive, Inc. and
5 * may not be copied or used except in accordance with the terms of that agreement
6 * Copyright (c) 2012-2016 Twitch Interactive, Inc.
7 *********************************************************************************************/
8 
9 #pragma once
10 
11 template <typename _ctorRet_t>
13 {
14  RaiiWrapper(std::function<_ctorRet_t()> createCall, std::function<void()> destroyCall)
15  : mCtorRet( createCall() )
16  , mDestroyCall(destroyCall)
17  {
18  }
19 
21  {
22  mDestroyCall();
23  }
24 
25  void Release()
26  {
27  mDestroyCall = nullptr;
28  }
29 
30  std::function<void()> mDestroyCall;
31  _ctorRet_t mCtorRet;
32 
33 private:
34  RaiiWrapper(const RaiiWrapper& rhs);
35  RaiiWrapper& operator=(const RaiiWrapper& rhs);
36 };
void Release()
Definition: raiiwrapper.h:25
_ctorRet_t mCtorRet
Definition: raiiwrapper.h:31
~RaiiWrapper()
Definition: raiiwrapper.h:20
RaiiWrapper & operator=(const RaiiWrapper &rhs)
std::function< void()> mDestroyCall
Definition: raiiwrapper.h:30
RaiiWrapper(std::function< _ctorRet_t()> createCall, std::function< void()> destroyCall)
Definition: raiiwrapper.h:14
Definition: raiiwrapper.h:12