Branch: Tag:

2015-10-05

2015-10-05 13:23:05 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Filesystem.Monitor: Added DefaultMonitor.

This class alias simplifies other code by reducing the need for
preprocessor checks.

714:    }   }    + //! @class DefaultMonitor + //! This symbol evaluates to the @[Monitor] class used by + //! the default implementation of @[monitor_factory()]. + //! + //! It is currently one of the values @[Monitor], @[EventStreamMonitor] + //! or @[InotifyMonitor]. + //! + //! @seealso + //! @[monitor_factory()] +  + // NB: See further below for the actual definitions. +  + //! @decl inherit Monitor +  + //! @endclass +    //   // Some necessary setup activities for systems that provide   // filesystem event monitoring
800: Inside #if HAVE_EVENTSTREAM
   }   }    + constant DefaultMonitor = EventStreamMonitor; +    #elseif HAVE_INOTIFY      protected System.Inotify._Instance instance;
946:    ::unregister_path(dying);    }   } +  + constant DefaultMonitor = InotifyMonitor; +  + #else +  + constant DefaultMonitor = Monitor; +    #endif /* HAVE_EVENTSTREAM || HAVE_INOTIFY */      //! Canonicalize a path.
1056:   //! This function is called by @[monitor()] to create a new @[Monitor]   //! object.   //! - //! The default implementation just calls @[Monitor()] (or one of - //! @[EventStreamMonitor] or @[InotifyMonitor]) with the same - //! arguments. + //! The default implementation just calls @[DefaultMonitor] with the + //! same arguments.   //!   //! @seealso - //! @[monitor()] - protected Monitor monitor_factory(string path, MonitorFlags|void flags, + //! @[monitor()], @[DefaultMonitor] + protected DefaultMonitor monitor_factory(string path, MonitorFlags|void flags,    int(0..)|void max_dir_check_interval,    int(0..)|void file_interval_factor,    int(0..)|void stable_time)   { - #if HAVE_EVENTSTREAM -  return EventStreamMonitor(path, flags, max_dir_check_interval, +  return DefaultMonitor(path, flags, max_dir_check_interval,    file_interval_factor, stable_time); - #elseif HAVE_INOTIFY -  return InotifyMonitor(path, flags, max_dir_check_interval, -  file_interval_factor, stable_time); - #else /* !HAVE_EVENTSTREAM && !HAVE_INOTIFY */ -  return Monitor(path, flags, max_dir_check_interval, -  file_interval_factor, stable_time); - #endif /* HAVE_EVENTSTREAM || HAVE_INOTIFY */ +    }