Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from GabrielHare/feature-DeclareAutoFilter
Declarative AutoFilter initialization
- Loading branch information
Showing
4 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. | ||
#pragma once | ||
|
||
#include "CoreContext.h" | ||
#include "MicroAutoFilter.h" | ||
|
||
/// <summary> | ||
/// Wraps any method in a MicroAutoFilter class and registers it with the current context. | ||
/// </summary> | ||
/// <remarks> | ||
/// In the constructor of a class that will be Injected into a context call this function as: | ||
/// DeclareAutoFilter(this, &MyClass::MyMethod) | ||
/// for each method that should be used as an AutoFilter. | ||
/// </remarks> | ||
template<class Base, class Ret, class... Args> | ||
std::shared_ptr<MicroAutoFilter<Ret, Args...>> DeclareAutoFilter(Base* that, Ret (Base::*filter)(Args...)) { | ||
return std::shared_ptr<MicroAutoFilter<Ret, Args...>>( | ||
AutoCurrentContext()->template Construct<MicroAutoFilter<Ret, Args...>>( | ||
[that, filter] (Args... args) { | ||
return (that->*filter)(args...); | ||
} | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters