Skip to content

Commit

Permalink
Refactory monitor_factory to dynamically create the default monitor u…
Browse files Browse the repository at this point in the history
…sing the factory registration info.
  • Loading branch information
emcrisostomo committed Dec 16, 2015
1 parent 13e2f9a commit 0c3e4e9
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions libfswatch/src/libfswatch/c++/monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,6 @@
#include <regex.h>
#include <sstream>
#include <time.h>
/*
* Conditionally include monitor headers for default construction.
*/
#if defined(HAVE_FSEVENTS_FILE_EVENTS)
# include "fsevents_monitor.hpp"
#endif
#if defined(HAVE_SYS_EVENT_H)
# include "kqueue_monitor.hpp"
#endif
#if defined(HAVE_PORT_H)
# include "fen_monitor.hpp"
#endif
#if defined(HAVE_SYS_INOTIFY_H)
# include "inotify_monitor.hpp"
#endif
#if defined(HAVE_WINDOWS)
# include "windows_monitor.hpp"
#endif
#include "poll_monitor.hpp"

using namespace std;

Expand Down Expand Up @@ -218,19 +199,23 @@ namespace fsw
FSW_EVENT_CALLBACK *callback,
void *context)
{
fsw_monitor_type type;

#if defined(HAVE_FSEVENTS_FILE_EVENTS)
return new fsevents_monitor(paths, callback, context);
type = fsw_monitor_type::fsevents_monitor_type;
#elif defined(HAVE_SYS_EVENT_H)
return new kqueue_monitor(paths, callback, context);
type = fsw_monitor_type::kqueue_monitor_type;
#elif defined(HAVE_PORT_H)
return new fen_monitor(paths, callback, context);
type = fsw_monitor_type::fen_monitor_type;
#elif defined(HAVE_SYS_INOTIFY_H)
return new inotify_monitor(paths, callback, context);
type = fsw_monitor_type::inotify_monitor_type;
#elif defined(HAVE_WINDOWS)
return new windows_monitor(paths, callback, context);
type = fsw_monitor_type::windows_monitor_type;
#else
return new poll_monitor(paths, callback, context);
type = fsw_monitor_type::poll_monitor_type;
#endif

return monitor_factory::create_monitor(type, paths, callback, context);
}

monitor *monitor_factory::create_monitor(fsw_monitor_type type,
Expand Down

0 comments on commit 0c3e4e9

Please sign in to comment.