Derived const & operator -- ()
{ derived().value( derived.value()-1 ); return derived(); }
+ Derived const & operator ++ (int)
+ { Value v (derived.value()); derived().value( v+1 ); return v; }
+ Derived const & operator -- (int)
+ { Value v (derived.value()); derived().value( v-1 ); return v; }
+
private:
Derived & derived() { return *static_cast<Derived *>(this); }
Derived const & derived() const { return *static_cast<Derived const *>(this); };
// Definition of inline template functions
-//#include "ParserBase.ih"
+#include "ParserBase.ih"
// Custom includes
// Custom includes
#include <utility>
+#include <boost/iterator/iterator_facade.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp>
#include "ParserBase.ih"
namespace impl { struct ParserBase; }
- struct nil {};
+ struct nil
+ : public boost::iterator_facade<nil,char,boost::random_access_traversal_tag>
+ {
+ // Theese are declared to make nil a valid iterator. All
+ // access to an instance of this iterator however is invalid
+ // (these members are not implemented only declared)
+ char & dereference() const;
+ bool equal(nil other) const;
+ void increment();
+ void decrement();
+ void advance(int n);
+ int distance_to(nil other) const;
+ };
/** \brief Parser framework
throw SystemException(errno);
}
-prefix_ void satcom::lib::Scheduler::add(int fd, Callback const & cb, EventId eventMask)
+prefix_ void satcom::lib::Scheduler::do_add(int fd, InternalCallback const & cb, EventId eventMask)
{
FdTable::iterator i (fdTable_.find(fd));
int action (EPOLL_CTL_MOD);
throw SystemException(errno);
}
-prefix_ void satcom::lib::Scheduler::remove(int fd, EventId eventMask)
+prefix_ void satcom::lib::Scheduler::do_remove(int fd, EventId eventMask)
{
FdTable::iterator i (fdTable_.find(fd));
if (i == fdTable_.end())
if (ev.events & EPOLLIN) {
BOOST_ASSERT(spec.cb_read);
- spec.cb_read(ev.data.fd, EV_READ);
+ spec.cb_read(EV_READ);
}
else if (ev.events & EPOLLPRI) {
BOOST_ASSERT(spec.cb_prio);
- spec.cb_prio (ev.data.fd, EV_PRIO);
+ spec.cb_prio(EV_PRIO);
}
else if (ev.events & EPOLLOUT) {
BOOST_ASSERT(spec.cb_write);
- spec.cb_write(ev.data.fd, EV_WRITE);
+ spec.cb_write(EV_WRITE);
}
else if (ev.events & EPOLLHUP) {
BOOST_ASSERT(spec.cb_hup);
- spec.cb_hup(ev.data.fd, EV_HUP);
+ spec.cb_hup(EV_HUP);
}
else if (ev.events & EPOLLERR) {
BOOST_ASSERT(spec.cb_err);
- spec.cb_err(ev.data.fd, EV_ERR);
+ spec.cb_err(EV_ERR);
}
}
}
terminate_ = true;
}
+prefix_ int satcom::lib::retrieve_filehandle(int fd)
+{
+ return fd;
+}
+
///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_
typename GenericCallback<Handle>::Callback const & cb,
EventId eventMask)
{
- add(retrieve_filehandle(handle),boost::bind(cb,handle,_2),eventMask);
+ // retrieve_filehandle is found via ADL
+ do_add(retrieve_filehandle(handle),boost::bind(cb,handle,_1),eventMask);
}
template <class Handle>
prefix_ void satcom::lib::Scheduler::remove(Handle const & handle, EventId eventMask)
{
// retrieve_filehandle is found via ADL
- remove(retrieve_filehandle(handle),eventMask);
+ do_remove(retrieve_filehandle(handle),eventMask);
}
///////////////////////////////cti.e///////////////////////////////////////
typedef boost::function<void (typename boost::call_traits<Handle>::param_type,
EventId) > Callback;
};
- typedef GenericCallback<int>::Callback Callback;
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
///@}
///////////////////////////////////////////////////////////////////////////
- void add(int fd, Callback const & cb, EventId eventMask = EV_ALL);
- void remove(int fd, EventId eventMask = EV_ALL);
-
template <class Handle>
void add(Handle const & handle,
typename GenericCallback<Handle>::Callback const & cb,
private:
Scheduler();
-
- struct EventSpec
+
+ typedef boost::function<void (EventId)> InternalCallback;
+
+ void do_add(int fd, InternalCallback const & cb, EventId eventMask = EV_ALL);
+ void do_remove(int fd, EventId eventMask = EV_ALL);
+
+ struct EventSpec
{
- Callback cb_read;
- Callback cb_prio;
- Callback cb_write;
- Callback cb_hup;
- Callback cb_err;
+ InternalCallback cb_read;
+ InternalCallback cb_prio;
+ InternalCallback cb_write;
+ InternalCallback cb_hup;
+ InternalCallback cb_err;
int epollMask() const;
};
bool terminate_;
};
+ int retrieve_filehandle(int fd);
+
}}
///////////////////////////////hh.e////////////////////////////////////////