Commit 4b517a33 authored by neverlord's avatar neverlord

changed attachable to pure interface

parent 9e460ecd
...@@ -225,11 +225,16 @@ class functor_attachable : public attachable ...@@ -225,11 +225,16 @@ class functor_attachable : public attachable
{ {
} }
virtual void detach(std::uint32_t reason) void detach(std::uint32_t reason)
{ {
m_functor(reason); m_functor(reason);
} }
bool matches(const attachable::token&)
{
return false;
}
}; };
template<typename F> template<typename F>
......
...@@ -39,9 +39,9 @@ class attachable ...@@ -39,9 +39,9 @@ class attachable
* *
* The default implementation does nothing. * The default implementation does nothing.
*/ */
virtual void detach(std::uint32_t reason); virtual void detach(std::uint32_t reason) = 0;
virtual bool matches(const token&); virtual bool matches(const token&) = 0;
}; };
......
...@@ -51,11 +51,13 @@ class group : public channel ...@@ -51,11 +51,13 @@ class group : public channel
unsubscriber(const channel_ptr& s, const intrusive_ptr<group>& g); unsubscriber(const channel_ptr& s, const intrusive_ptr<group>& g);
~unsubscriber();
void detach(std::uint32_t);
// matches on m_group // matches on m_group
bool matches(const attachable::token& what); bool matches(const attachable::token& what);
virtual ~unsubscriber();
}; };
typedef std::unique_ptr<unsubscriber> subscription; typedef std::unique_ptr<unsubscriber> subscription;
......
...@@ -6,13 +6,13 @@ attachable::~attachable() ...@@ -6,13 +6,13 @@ attachable::~attachable()
{ {
} }
void attachable::detach(std::uint32_t) //void attachable::detach(std::uint32_t)
{ //{
} //}
bool attachable::matches(const attachable::token&) //bool attachable::matches(const attachable::token&)
{ //{
return false; // return false;
} //}
} // namespace cppa::detail } // namespace cppa::detail
...@@ -27,7 +27,21 @@ group::unsubscriber::unsubscriber(const channel_ptr& s, ...@@ -27,7 +27,21 @@ group::unsubscriber::unsubscriber(const channel_ptr& s,
group::unsubscriber::~unsubscriber() group::unsubscriber::~unsubscriber()
{ {
if (m_group) m_group->unsubscribe(m_self); if (m_group && m_self) m_group->unsubscribe(m_self);
}
void group::unsubscriber::detach(std::uint32_t)
{
// unsubscription is done in destructor
}
bool group::unsubscriber::matches(const attachable::token& what)
{
if (what.subtype == typeid(group::unsubscriber))
{
return m_group == reinterpret_cast<const group*>(what.ptr);
}
return false;
} }
group::module::module(const std::string& name) : m_name(name) group::module::module(const std::string& name) : m_name(name)
...@@ -43,15 +57,6 @@ const std::string& group::module::name() ...@@ -43,15 +57,6 @@ const std::string& group::module::name()
return m_name; return m_name;
} }
bool group::unsubscriber::matches(const attachable::token& what)
{
if (what.subtype == typeid(group::unsubscriber))
{
return m_group == reinterpret_cast<const group*>(what.ptr);
}
return false;
}
group::group(std::string&& id, std::string&& mod_name) group::group(std::string&& id, std::string&& mod_name)
: m_identifier(std::move(id)), m_module_name(std::move(mod_name)) : m_identifier(std::move(id)), m_module_name(std::move(mod_name))
{ {
......
...@@ -24,6 +24,13 @@ struct exit_observer : cppa::attachable ...@@ -24,6 +24,13 @@ struct exit_observer : cppa::attachable
{ {
cppa::detail::dec_actor_count(); cppa::detail::dec_actor_count();
} }
void detach(std::uint32_t)
{
}
bool matches(const token&)
{
return false;
}
}; };
} // namespace <anonymous> } // namespace <anonymous>
......
...@@ -25,11 +25,9 @@ using namespace cppa; ...@@ -25,11 +25,9 @@ using namespace cppa;
// GCC 4.7 supports non-static member initialization // GCC 4.7 supports non-static member initialization
#if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 7) #if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 7)
class event_testee : public fsm_actor<event_testee> struct event_testee : public fsm_actor<event_testee>
{ {
friend class fsm_actor<event_testee>;
invoke_rules wait4string = invoke_rules wait4string =
( (
on<std::string>() >> [=]() on<std::string>() >> [=]()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment