summaryrefslogtreecommitdiff
path: root/DAnCE/dance/LocalityManager/Scheduler/Dependency_Sorter.h
blob: 078d59b93942ba908295717befb959b23641cb8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// $Id$
/**
 * @file Dependency_Sorter.h
 * @author William R. Otte <wotte@dre.vanderbilt.edu>
 *
 */
#ifndef DEP_SORTER_H
#define DEP_SORTER_H

#include <map>
#include <set>
#include <string>
#include <vector>

namespace DAnCE
{
  class Dependency_Sorter
  {
  public:
    typedef std::vector < std::string > INSTALL_ORDER;
    typedef std::set < std::string > IH_DEPS;
    class Invalid_Install_Order : std::exception {};

    /// Add a handler which has no dependencies
    void add_nondependent (const std::string &subject);

    /// Add a dependency to the map.
    void add_dependency (const std::string &subject,
                         const IH_DEPS &deps);

    /// Add a dependency to the map.
    void add_dependency (const std::string &subject,
                         const std::string &install_after);

    void calculate_order (INSTALL_ORDER &);

  private:
    typedef std::map < std::string, IH_DEPS > DEP_MAP;

    DEP_MAP dep_map_;
  };
}

#endif