+ /** Indicates if it's possible to build this target. */
+ bool is_buildable() const { return tool!=0; }
+
+ /** Indicates if this target needs rebuilding. Only makes sense after the
+ target has been prepared. */
+ bool needs_rebuild() const { return state>PREPARING && state<UPTODATE; }
+
+ /** Returns the reason for rebuilding this target. Only makes sense after
+ the target has been prepared. */
+ const std::string &get_rebuild_reason() const { return rebuild_reason; }
+
+ /** Forces rebuild of the target. */
+ void force_rebuild();
+
+protected:
+ /** Marks the target to be rebuilt and specified a reason for it. */
+ void mark_rebuild(const std::string &);
+
+ /** Checks if the target needs to be rebuilt and why. */
+ virtual void check_rebuild() = 0;
+
+public:
+ /** Prepares the target by finding dependencies, recursively preparing them
+ and then checking whether rebuilding is needed. */
+ void prepare();
+
+ /** Invokes the associated Tool to build the target and returns the
+ resulting Task. The task must be started by the caller. */
+ virtual Task *build();
+
+protected:
+ /** Handler for Task::signal_finished. */
+ virtual void build_finished(bool);
+
+public:
+ /** Removes any results of building the target. */
+ virtual void clean() { }
+};