Skip to content

Commit

Permalink
Removed all references to EventReceiver.
Browse files Browse the repository at this point in the history
Compiles but fails tests
  • Loading branch information
gtremper committed Aug 1, 2014
1 parent 010251b commit c1c7603
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 84 deletions.
1 change: 1 addition & 0 deletions autowiring/Autowired.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once
#include "AutowirableSlot.h"
#include "Decompose.h"
#include "Deferred.h"
#include "GlobalCoreContext.h"
#include "TypeRegistry.h"
#include MEMORY_HEADER
Expand Down
30 changes: 16 additions & 14 deletions autowiring/CoreContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class CoreContext:
std::vector<ExceptionFilter*> m_filters;

// All known event receivers and receiver proxies originating from this context:
typedef std::set<JunctionBoxEntry<EventReceiver>> t_rcvrSet;
typedef std::set<JunctionBoxEntry<Object>> t_rcvrSet;
t_rcvrSet m_eventReceivers;

// List of eventReceivers to be added when this context in initiated
Expand Down Expand Up @@ -245,7 +245,7 @@ class CoreContext:
/// Adds the named event receiver to the collection of known receivers
/// </summary>
/// <param name="pRecvr">The junction box entry corresponding to the receiver type</param>
void AddEventReceiver(JunctionBoxEntry<EventReceiver> pRecvr);
void AddEventReceiver(JunctionBoxEntry<Object> pRecvr);

/// <summary>
/// Add delayed event receivers
Expand Down Expand Up @@ -313,7 +313,7 @@ class CoreContext:
pCoreRunnable(autowiring::fast_pointer_cast<CoreRunnable>(value)),
pFilter(autowiring::fast_pointer_cast<ExceptionFilter>(value)),
pBoltBase(autowiring::fast_pointer_cast<BoltBase>(value)),
pRecvr(autowiring::fast_pointer_cast<EventReceiver>(value))
pRecvr(autowiring::fast_pointer_cast<Object>(value))
{
if(!pObject)
throw autowiring_error("Cannot add a type which does not implement Object");
Expand All @@ -335,7 +335,7 @@ class CoreContext:
const std::shared_ptr<CoreRunnable> pCoreRunnable;
const std::shared_ptr<ExceptionFilter> pFilter;
const std::shared_ptr<BoltBase> pBoltBase;
const std::shared_ptr<EventReceiver> pRecvr;
const std::shared_ptr<Object> pRecvr;
};

/// <summary>
Expand Down Expand Up @@ -384,7 +384,7 @@ class CoreContext:
/// This method has no effect if the passed value is presently a snooper in this context; the
/// snooper collection must therefore be updated prior to the call to this method.
/// </remarks>
void UnsnoopEvents(Object* snooper, const JunctionBoxEntry<EventReceiver>& traits);
void UnsnoopEvents(Object* snooper, const JunctionBoxEntry<Object>& traits);

/// <summary>
/// Forwarding routine, only removes from this context
Expand Down Expand Up @@ -771,7 +771,7 @@ class CoreContext:
/// </summary>
/// <param name="pProxy">The sender of the event</param>
/// <param name="pRecipient">The recipient of the event</param>
void FilterFiringException(const JunctionBoxBase* pProxy, EventReceiver* pRecipient);
void FilterFiringException(const JunctionBoxBase* pProxy, Object* pRecipient);

/// <summary>
/// Enables the passed event receiver to obtain messages broadcast by this context
Expand All @@ -786,17 +786,18 @@ class CoreContext:
/// </remarks>
template<class T>
void Snoop(const std::shared_ptr<T>& pSnooper) {
static_assert(std::is_base_of<EventReceiver, T>::value ||
has_autofilter<T>::value,
"Cannot snoop on a type which is not an EventReceiver or implements AutoFilter");
// GRAHAM
//static_assert(std::is_base_of<EventReceiver, T>::value ||
// has_autofilter<T>::value,
// "Cannot snoop on a type which is not an EventReceiver or implements AutoFilter");

const AddInternalTraits traits(AutoFilterDescriptorSelect<T>(pSnooper), pSnooper);
// Add to collections of snoopers
InsertSnooper(pSnooper);

// Add EventReceiver
if(traits.pRecvr)
AddEventReceiver(JunctionBoxEntry<EventReceiver>(this, traits.pRecvr));
AddEventReceiver(JunctionBoxEntry<Object>(this, traits.pRecvr));

// Add PacketSubscriber;
if(traits.subscriber)
Expand All @@ -811,9 +812,10 @@ class CoreContext:
/// </remarks>
template<class T>
void Unsnoop(const std::shared_ptr<T>& pSnooper) {
static_assert(std::is_base_of<EventReceiver, T>::value ||
has_autofilter<T>::value,
"Cannot snoop on a type which is not an EventReceiver or implements AutoFilter");
//GRAHAM
//static_assert(std::is_base_of<EventReceiver, T>::value ||
// has_autofilter<T>::value,
// "Cannot snoop on a type which is not an EventReceiver or implements AutoFilter");

const AddInternalTraits traits(AutoFilterDescriptorSelect<T>(pSnooper), pSnooper);
RemoveSnooper(pSnooper);
Expand All @@ -822,7 +824,7 @@ class CoreContext:

// Cleanup if its an EventReceiver
if(traits.pRecvr)
UnsnoopEvents(oSnooper.get(), JunctionBoxEntry<EventReceiver>(this, traits.pRecvr));
UnsnoopEvents(oSnooper.get(), JunctionBoxEntry<Object>(this, traits.pRecvr));

// Cleanup if its a packet listener
if(traits.subscriber)
Expand Down
10 changes: 0 additions & 10 deletions autowiring/Deferred.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,3 @@ class FatalDeferredInvocation:
assert(false);
}
};

/// <summary>
/// Used to identify event recipients
/// </summary>
class EventReceiver {
public:
virtual ~EventReceiver(void) {
}
};

4 changes: 1 addition & 3 deletions autowiring/DispatchQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class dispatch_aborted_exception:
/// <remarks>
/// A DispatchQueue is a type of event receiver which allows for the reception of deferred events.
/// </remarks>
class DispatchQueue:
public virtual EventReceiver
{
class DispatchQueue {
public:
DispatchQueue(void);

Expand Down
12 changes: 4 additions & 8 deletions autowiring/EventInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@ struct Expression<R(W::*)(ToBindArgs...) >: public ExpressionBase
/// Allows the deserialization of events from an output stream, in order to replay them in-process
/// </summary>
template<class T>
class EventInputStream
{
public:
static_assert(std::is_base_of<EventReceiver, T>::value, "Cannot instantiate an event input stream on a non-event type");

private:
std::map<std::string, std::shared_ptr<ExpressionBase> > m_EventMap;

class EventInputStream {
public:
EventInputStream(){}

Expand Down Expand Up @@ -118,4 +111,7 @@ class EventInputStream
}
return location + 1;
}

private:
std::map<std::string, std::shared_ptr<ExpressionBase> > m_EventMap;
};
1 change: 0 additions & 1 deletion autowiring/ExceptionFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include FUNCTIONAL_HEADER

class JunctionBoxBase;
class EventReceiver;

/// <summary>
/// Implements an exception filter type, invoked when an unhandled exception is thrown
Expand Down
1 change: 1 addition & 0 deletions autowiring/JunctionBoxBase.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#pragma once
#include <vector>
#include "Object.h"
#include MUTEX_HEADER
#include MEMORY_HEADER
#include STL_UNORDERED_SET
Expand Down
8 changes: 6 additions & 2 deletions autowiring/JunctionBoxEntry.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#pragma once
#include "TypeUnifier.h"
#include "fast_pointer_cast.h"
#include <stdexcept>
#include MEMORY_HEADER

Expand All @@ -20,12 +22,14 @@ template<class T>
struct JunctionBoxEntry:
JunctionBoxEntryBase
{
typedef typename SelectTypeUnifier<T>::type EntryType_t;

JunctionBoxEntry(CoreContext* owner, std::shared_ptr<T> ptr) :
JunctionBoxEntryBase(owner),
m_ptr(ptr)
m_ptr(autowiring::fast_pointer_cast<EntryType_t>(ptr))
{}

std::shared_ptr<T> m_ptr;
std::shared_ptr<EntryType_t> m_ptr;

JunctionBoxEntry& operator=(const JunctionBoxEntry& rhs) {
// This shouldn't be used. non-c++11 containers require this...
Expand Down
6 changes: 2 additions & 4 deletions autowiring/JunctionBoxManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include STL_UNORDERED_MAP
#include TYPE_TRAITS_HEADER

class EventReceiver;
class EventOutputStreamBase;
class CoreContext;
class JunctionBoxBase;
Expand Down Expand Up @@ -62,8 +61,8 @@ class JunctionBoxManager {
/// </summary>
void Initiate(void);

void AddEventReceiver(JunctionBoxEntry<EventReceiver> receiver);
void RemoveEventReceiver(JunctionBoxEntry<EventReceiver> pRecvr);
void AddEventReceiver(JunctionBoxEntry<Object> receiver);
void RemoveEventReceiver(JunctionBoxEntry<Object> pRecvr);

/// <summary>
/// This method checks whether eventoutputstream listeners for the given type still exist.
Expand Down Expand Up @@ -110,7 +109,6 @@ class JunctionBoxManager {
/// </summary>
template<class T>
std::shared_ptr<EventOutputStream<T>> CreateEventOutputStream(void) {
static_assert(std::is_base_of<EventReceiver, T>::value, "Cannot create an output stream based on a non-event type");
static_assert(uuid_of<T>::value, "Cannot create an output stream on type T, the type was not defined with DECLARE_UUID");
auto retval = std::make_shared<EventOutputStream<T>>();
auto upcastptr = static_cast<std::shared_ptr<EventOutputStreamBase>>(retval);
Expand Down
1 change: 1 addition & 0 deletions autowiring/TypeRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct TypeRegistryEntryT:

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

//GRAHAM
//bool IsEventReceiver(void) const override { return std::is_base_of<EventReceiver, T>::value; }

virtual std::shared_ptr<JunctionBoxBase> NewJunctionBox(void) const override {
Expand Down
8 changes: 4 additions & 4 deletions src/autowiring/CoreContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void CoreContext::AddInternal(const AddInternalTraits& traits) {

// Event receivers:
if(traits.pRecvr) {
JunctionBoxEntry<EventReceiver> entry(this, traits.pRecvr);
JunctionBoxEntry<Object> entry(this, traits.pRecvr);

// Add to our vector of local receivers first:
(std::lock_guard<std::mutex>)m_stateBlock->m_lock,
Expand Down Expand Up @@ -647,7 +647,7 @@ void CoreContext::UpdateDeferredElements(std::unique_lock<std::mutex>&& lk, cons
cur.first->Finalize(cur.second);
}

void CoreContext::AddEventReceiver(JunctionBoxEntry<EventReceiver> entry) {
void CoreContext::AddEventReceiver(JunctionBoxEntry<Object> entry) {
{
std::lock_guard<std::mutex> lk(m_stateBlock->m_lock);

Expand Down Expand Up @@ -690,7 +690,7 @@ void CoreContext::RemoveEventReceivers(t_rcvrSet::const_iterator first, t_rcvrSe
m_pParent->RemoveEventReceivers(first, last);
}

void CoreContext::UnsnoopEvents(Object* oSnooper, const JunctionBoxEntry<EventReceiver>& receiver) {
void CoreContext::UnsnoopEvents(Object* oSnooper, const JunctionBoxEntry<Object>& receiver) {
{
std::lock_guard<std::mutex> lk(m_stateBlock->m_lock);
if(
Expand Down Expand Up @@ -743,7 +743,7 @@ void CoreContext::FilterException(void) {
throw;
}

void CoreContext::FilterFiringException(const JunctionBoxBase* pProxy, EventReceiver* pRecipient) {
void CoreContext::FilterFiringException(const JunctionBoxBase* pProxy, Object* pRecipient) {
// Filter in order:
for(CoreContext* pCur = this; pCur; pCur = pCur->GetParentContext().get())
for(auto q = pCur->m_filters.begin(); q != pCur->m_filters.end(); q++)
Expand Down
2 changes: 1 addition & 1 deletion src/autowiring/JunctionBoxBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void JunctionBoxBase::TerminateAll(const std::vector<std::weak_ptr<CoreContext>>
}
}

void JunctionBoxBase::FilterFiringException(const std::shared_ptr<EventReceiver>& pRecipient) const {
void JunctionBoxBase::FilterFiringException(const std::shared_ptr<Object>& pRecipient) const {
// Obtain the current context and pass control:
CoreContext::CurrentContext()->FilterFiringException(this, pRecipient.get());
}
Expand Down
4 changes: 2 additions & 2 deletions src/autowiring/JunctionBoxManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ void JunctionBoxManager::Initiate(void) {
q.second->Initiate();
}

void JunctionBoxManager::AddEventReceiver(JunctionBoxEntry<EventReceiver> receiver) {
void JunctionBoxManager::AddEventReceiver(JunctionBoxEntry<Object> receiver) {
// Notify all junctionboxes that there is a new event
for(auto q : m_junctionBoxes)
q.second->Add(receiver);
}

void JunctionBoxManager::RemoveEventReceiver(JunctionBoxEntry<EventReceiver> receiver) {
void JunctionBoxManager::RemoveEventReceiver(JunctionBoxEntry<Object> receiver) {
// Notify all compatible senders that we're going away:
for(auto q : m_junctionBoxes)
q.second->Remove(receiver);
Expand Down
1 change: 1 addition & 0 deletions src/autowiring/test/AutoFilterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "TestFixtures/Decoration.hpp"
#include <autowiring/AutoPacket.h>
#include <autowiring/AutoPacketFactory.h>
#include <autowiring/Deferred.h>
#include <autowiring/NewAutoFilter.h>
#include THREAD_HEADER

Expand Down
4 changes: 1 addition & 3 deletions src/autowiring/test/CoreJobTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ TEST_F(CoreJobTest, VerifyTeardown) {
EXPECT_TRUE(check3) << "Lambda 3 didn't finish";
}

struct SimpleListen:
virtual EventReceiver
{
struct SimpleListen{
SimpleListen():
m_flag(false)
{}
Expand Down
3 changes: 1 addition & 2 deletions src/autowiring/test/CoreThreadTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ TEST_F(CoreThreadTest, VerifyNestedTermination) {
ASSERT_FALSE(st->IsRunning()) << "Child thread was running even though the enclosing context was terminated";
}

class SleepEvent : public virtual EventReceiver
{
class SleepEvent {
public:
virtual Deferred SleepFor(int seconds) = 0;
virtual Deferred SleepForThenThrow(int seconds) = 0;
Expand Down
4 changes: 1 addition & 3 deletions src/autowiring/test/DtorCorrectnessTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ class CtorDtorCopyCounter {
std::atomic<int> CtorDtorCopyCounter::s_outstanding;
std::atomic<size_t> CtorDtorCopyCounter::s_construction;

class CtorDtorListener:
public virtual EventReceiver
{
class CtorDtorListener {
public:
virtual void DoFired(CtorDtorCopyCounter ctr) = 0;
virtual Deferred DoDeferred(CtorDtorCopyCounter ctr) = 0;
Expand Down
8 changes: 2 additions & 6 deletions src/autowiring/test/EventReceiverTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,7 @@ TEST_F(EventReceiverTest, NoEventsAfterShutdown) {
EXPECT_FALSE(receiver->m_zero) << "A context member caught an event after its enclosing context was torn down";
}

class PassByValueInterface:
public virtual EventReceiver
{
class PassByValueInterface {
public:
PassByValueInterface() {}
virtual ~PassByValueInterface() {}
Expand Down Expand Up @@ -467,9 +465,7 @@ TEST_F(EventReceiverTest, VerifyCorrectContext){
}

TEST_F(EventReceiverTest, EventChain){
class Middle:
public EventReceiver
{
class Middle{
public:
virtual void MyEvent() = 0;
};
Expand Down
3 changes: 1 addition & 2 deletions src/autowiring/test/MarshalingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ struct StandardType : public Auto::Serialize{
}
};

DECLARE_UUID(EventWithUuid, "6EC2129F-5DD7-43D5-ACB5-864E8BB5D6B4") :
public virtual EventReceiver
DECLARE_UUID(EventWithUuid, "6EC2129F-5DD7-43D5-ACB5-864E8BB5D6B4")
{
public:
virtual void SampleEventFiring(const std::string* str) = 0;
Expand Down
8 changes: 2 additions & 6 deletions src/autowiring/test/SnoopTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include "SnoopTest.hpp"
#include "TestFixtures/Decoration.hpp"

class UpBroadcastListener:
public virtual EventReceiver
{
class UpBroadcastListener {
public:
virtual void SimpleCall(void) {}
};
Expand Down Expand Up @@ -45,9 +43,7 @@ class IgnoredParentMember:
public SnoopTestBase
{};

class SimpleEvent:
public virtual EventReceiver
{
class SimpleEvent {
public:
virtual void ZeroArgs(void) {}
};
Expand Down
Loading

0 comments on commit c1c7603

Please sign in to comment.