daemon: Implement 'get_job_names' call to list all loaded jobs.
[whenjobs.git] / lib / whenstate.mli
index 084cd49..f056c44 100644 (file)
@@ -47,6 +47,17 @@ val copy_variables : t -> t -> t
     the variables from [old_state], adding them to [current_state],
     returning a new state.  Note the order of arguments. *)
 
+val copy_prev_state : t -> t -> t
+(** [copy_prev_state old_state current_state -> new_state] is an
+    obscure function used to make the [prev] function work predictably
+    across file reloads.  Since a file reload creates a new state
+    object, it would normally "forget" that jobs had run previously,
+    so any job that used [prev], [changes] etc would run again
+    unnecessarily.  This function copies the prev state, allowing us
+    to remember which jobs ran previously and the state of the
+    variables at that time, making these functions work predictably.
+    State is only copied for jobs that have explicit names. *)
+
 val get_variable : t -> string -> Whenexpr.variable
 (** Return the value of a variable, when unknown variables defaulting
     to empty string. *)
@@ -62,8 +73,8 @@ val get_variable_names : t -> string list
 val nr_jobs : t -> int
 (** Returns the number of jobs in the state. *)
 
-val get_dependencies : t -> string -> Whenexpr.job list
-(** Return the jobs which depend on the named variable. *)
+val get_dependencies : t -> string list -> Whenexpr.job list
+(** Return the jobs which depend on the named variables. *)
 
 val get_whenjobs : t -> Whenexpr.job list
 val get_everyjobs : t -> Whenexpr.job list
@@ -72,6 +83,9 @@ val get_everyjobs : t -> Whenexpr.job list
 val get_job : t -> string -> Whenexpr.job
 (** Return the named job, or raise [Not_found]. *)
 
+val get_job_names : t -> string list
+(** Return the names of all jobs (running or not). *)
+
 val evaluate_whenjob : ?onload:bool -> t -> Whenexpr.job -> bool * t
 (** This evaluates the whenjob and returns [true] iff the whenjob
     should be run now.