Skip to content

Commit

Permalink
Fixing final failing test
Browse files Browse the repository at this point in the history
Failing ContextCleanupTest.VerifyContextDtor
  • Loading branch information
gtremper committed Aug 2, 2014
1 parent e963698 commit fba7a70
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
13 changes: 11 additions & 2 deletions autowiring/Autowired.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Decompose.h"
#include "Deferred.h"
#include "GlobalCoreContext.h"
#include "TypeRegistry.h"
#include MEMORY_HEADER
#include ATOMIC_HEADER

Expand Down Expand Up @@ -120,6 +121,8 @@ class Autowired:
AutowirableSlot<T>(ctxt ? ctxt->template ResolveAnchor<T>() : ctxt),
m_pFirstChild(nullptr)
{
// Add this type to the TypeRegistry
(void) RegType<T>::r;
if(ctxt)
ctxt->Autowire(*this);
}
Expand Down Expand Up @@ -251,15 +254,21 @@ class AutoRequired:
// !!!!! Read comment in Autowired if you get a compiler error here !!!!!
AutoRequired(const std::shared_ptr<CoreContext>& ctxt = CoreContext::CurrentContext()):
std::shared_ptr<T>(ctxt->template Inject<T>())
{}
{
// Add this type to the TypeRegistry
(void) RegType<T>::r;
}

/// <summary>
/// Construct overload, for types which take constructor arguments
/// </summary>
template<class... Args>
AutoRequired(const std::shared_ptr<CoreContext>& ctxt, Args&&... args) :
std::shared_ptr<T>(ctxt->template Construct<T>(std::forward<Args>(args)...))
{}
{
// Add this type to the TypeRegistry
(void) RegType<T>::r;
}

operator bool(void) const {
return IsAutowired();
Expand Down
5 changes: 1 addition & 4 deletions autowiring/CoreContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "EventInputStream.h"
#include "ExceptionFilter.h"
#include "TeardownNotifier.h"
#include "TypeRegistry.h"
#include "EventRegistry.h"
#include "TypeUnifier.h"

#include <list>
Expand Down Expand Up @@ -512,9 +512,6 @@ class CoreContext:
/// </summary>
template<typename T, typename... Args>
std::shared_ptr<T> Construct(Args&&... args) {
// Add this type to the TypeRegistry
(void) RegType<T>::r;

// If T doesn't inherit Object, then we need to compose a unifying type which does
typedef typename SelectTypeUnifier<T>::type TActual;
static_assert(std::is_base_of<Object, TActual>::value, "Constructive type does not implement Object as expected");
Expand Down
16 changes: 1 addition & 15 deletions autowiring/TypeRegistry.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#pragma once
#include "CreationRules.h"
#include "CoreContext.h"
#include <typeinfo>
#include STL_TUPLE_HEADER
#include MEMORY_HEADER

template<class T>
class JunctionBox;

class JunctionBoxBase;
class Object;

// Checks if an Object* listens to a event T;
Expand Down Expand Up @@ -45,11 +42,6 @@ struct TypeRegistryEntry {
/// </summary>
virtual const std::type_info& GetTypeInfo(void) const = 0;

/// <summary>
/// Constructor method, used to generate a new junction box
/// </summary>
virtual std::shared_ptr<JunctionBoxBase> NewJunctionBox(void) const = 0;

/// <summary>
/// Used to create a type identifier value, for use with AutoNet
/// </summary>
Expand Down Expand Up @@ -83,12 +75,6 @@ struct TypeRegistryEntryT:

virtual const std::type_info& GetTypeInfo(void) const override { return typeid(T); }

virtual std::shared_ptr<JunctionBoxBase> NewJunctionBox(void) const override {
return std::static_pointer_cast<JunctionBoxBase>(
std::make_shared<JunctionBox<T>>()
);
}

std::shared_ptr<TypeIdentifierBase> NewTypeIdentifier(void) const override {
return std::static_pointer_cast<TypeIdentifierBase>(
std::make_shared<TypeIdentifier<T>>()
Expand Down

0 comments on commit fba7a70

Please sign in to comment.