// file      : build/cxx/rule -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#ifndef BUILD_CXX_RULE
#define BUILD_CXX_RULE

#include <build/types>
#include <build/rule>

namespace build
{
  class scope;

  namespace cxx
  {
    class cxx;

    // @@ Can't we do match(obj&) and then registration code extracts
    // that. And no virtuals?
    //
    class compile: public rule
    {
    public:
      virtual match_result
      match (action, target&, const std::string& hint) const;

      virtual recipe
      apply (action, target&, const match_result&) const;

      static target_state
      perform_update (action, target&);
    };

    class link: public rule
    {
    public:
      virtual match_result
      match (action, target&, const std::string& hint) const;

      virtual recipe
      apply (action, target&, const match_result&) const;

      static target_state
      perform_update (action, target&);

    private:
      enum class type {e, a, so};
      enum class order {a, so, a_so, so_a};

      static type
      link_type (target&);

      static order
      link_order (target&);
    };
  }
}

#endif // BUILD_CXX_RULE