OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be found | |
3 // in the LICENSE file. | |
4 | |
5 #ifndef EXPERIMENTAL_WEBGTT_TASKMAP_H_ | |
6 #define EXPERIMENTAL_WEBGTT_TASKMAP_H_ | |
7 | |
8 /// @fileoverview This file provides a utility class which instantiates a lookup | |
9 /// vector, each element of which provides information about the function to be | |
10 /// called, and the number of arguments needed for that function call, for a | |
11 /// specific taskID (that corresponds to a specific graph algorithm). | |
12 /// | |
13 /// @author ragad@google.com (Raga Gopalakrishnan) | |
14 | |
15 #include <boost/function.hpp> | |
16 | |
17 #include <string> | |
18 #include <vector> | |
19 | |
20 namespace graph { | |
21 class Graph; | |
22 } | |
23 | |
24 namespace webgtt { | |
25 | |
26 /// This constant specifies the maximum number of arguments that a graph | |
27 /// algorithm will ever need. | |
28 const int kMaxArgs = 10; | |
29 | |
30 /// This structure stores the information required to call a function that | |
31 /// implements a particular graph algorithm. | |
32 struct FunctionInfo { | |
33 /// The number of arguments that the graph algorithm would need to work. | |
34 int number_of_arguments; | |
35 /// The function that obtains the response string containing the formatted | |
36 /// output of the graph algorithm. | |
37 boost::function<std::string()> function_to_call; | |
38 }; | |
39 | |
40 /// The TaskMap class. This class initializes a vector of instances of the | |
41 /// FunctionInfo structure - one instance per task ID. The function call for a | |
42 /// particular task ID needs to be customized based on the input graph, and the | |
43 /// arguments, so the constructor takes these as parameters. | |
44 class TaskMap { | |
45 public: | |
46 /// The constructor takes in an input graph and a vector of arguments, and | |
47 /// initializes the lookup vector of FunctionInfo instances. | |
48 /// | |
49 /// @param[in] input_graph The input graph to be used in the function | |
50 /// bindings. | |
51 /// @param[in] args The vector of arguments from which the arguments to be | |
52 /// used in the function bindings are obtained. | |
53 /// @constructor | |
54 TaskMap(const graph::Graph& input_graph, const std::vector<int>& args); | |
55 | |
56 /// Accessor function for task_map. | |
57 const std::vector<FunctionInfo>& task_map() const { return task_map_; } | |
58 | |
59 private: | |
60 std::vector<FunctionInfo> task_map_; | |
61 /// This disallows usage of copy and assignment constructors. | |
62 TaskMap(const TaskMap&); | |
63 void operator=(const TaskMap&); | |
64 }; | |
65 | |
66 } // namespace webgtt | |
67 | |
68 #endif // EXPERIMENTAL_WEBGTT_TASKMAP_H_ | |
OLD | NEW |