Arkanjo 0.1
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
orchestrator.cpp
Go to the documentation of this file.
1#include "orchestrator.hpp"
2
3void Orchestrator::help_command(){
4 cout << "Sorry I am tired I will do this latter" << '\n';
5}
6
7void Orchestrator::check_update_similarity(vector<string> parameters, Similarity_Table *similarity_table){
8 int number_parameters = parameters.size();
9 for(int i = 0; i < number_parameters-1; i++){
10 string param = parameters[i];
11 string next_param = parameters[i+1];
12 if(param == "-s"){
13 similarity_table->update_similarity(stod(next_param));
14 }
15 }
16}
17
18bool Orchestrator::check_force_preprocess(vector<string> parameters){
19 int number_parameters = parameters.size();
20 for(int i = 0; i < number_parameters; i++){
21 if(parameters[i] == "-pre"){
22 return true;
23 }
24 }
25 return false;
26}
27
28void Orchestrator::call_preprocess(vector<string> parameters){
29 bool should_force = check_force_preprocess(parameters);
30 Preprocessor preprocessor(should_force);
31}
32
33void Orchestrator::exploration_command(vector<string> parameters, Similarity_Table *similarity_table){
34 int number_parameters = parameters.size();
35
36 string pattern = "";
37 int limiter = 0;
38 bool both_need_to_match = false;
39 bool sorted_by_number_of_duplicated_code = false;
40 for(int i = 0; i < number_parameters-1; i++){
41 string param = parameters[i];
42 string next_param = parameters[i+1];
43 if(param == "-l"){
44 limiter = stoi(next_param);
45 }
46 if(param == "-p"){
47 pattern = next_param;
48 }
49 if(param == "-b"){
50 both_need_to_match = (next_param == "T");
51 }
52 if(param == "-c"){
53 sorted_by_number_of_duplicated_code = (next_param == "T");
54 }
55 }
56 Similarity_Explorer similarity_explorer(
57 similarity_table,
58 limiter,
59 pattern,
60 both_need_to_match,
61 sorted_by_number_of_duplicated_code);
62}
63
64void Orchestrator::random_command(vector<string> parameters, Similarity_Table *similarity_table){
65 int number_parameters = parameters.size();
66 if(number_parameters <= 2){
67 cout << "ERROR: Random expect three parameters, but less was given" << endl;
68 exit(0);
69 }
70 int minimum_similarity = stod(parameters[0]);
71 int maximum_similarity = stod(parameters[1]);
72 int maximum_quantity = stod(parameters[2]);
73 Random_Selector random(similarity_table,minimum_similarity,maximum_similarity,maximum_quantity);
74}
75
76void Orchestrator::duplication_command(vector<string> parameters, Similarity_Table *similarity_table){
77 Counter_Duplication_Code counter_duplication_code(similarity_table);
78}
79
80void Orchestrator::big_clone_formater_command(vector<string> parameters, Similarity_Table *similarity_table){
81 Big_Clone_Formater big_clone_formater(similarity_table);
82}
83
84void Orchestrator::big_clone_tailor_evaluator_command(vector<string> parameters, Similarity_Table *similarity_table){
85 Big_Clone_Tailor_Evaluator big_clone_tailor_evaluator(similarity_table);
86}
87
88void Orchestrator::similar_function_finder_command(vector<string> parameters, Similarity_Table *similarity_table){
89 int number_parameters = parameters.size();
90 if(number_parameters == 0){
91 cout << "ERROR: Similar Function Finder Command expect one parameter, but none was given" << endl;
92 exit(0);
93 }
94 Similar_Function_Finder similar_function_finder(parameters[0],similarity_table);
95}
96
97
98Orchestrator::Orchestrator(string command, vector<string> parameters){
99 call_preprocess(parameters);
100 Similarity_Table similarity_table;
101 check_update_similarity(parameters,&similarity_table);
102
103 if(command == "du"){
104 duplication_command(parameters,&similarity_table);
105 }else if(command == "ex"){
106 exploration_command(parameters,&similarity_table);
107 }else if(command == "fu"){
108 similar_function_finder_command(parameters,&similarity_table);
109 }else if(command == "bi"){
110 big_clone_formater_command(parameters,&similarity_table);
111 }else if(command == "ev"){
112 big_clone_tailor_evaluator_command(parameters,&similarity_table);
113 }else if(command == "ra"){
114 random_command(parameters,&similarity_table);
115 }else{
116 help_command();
117 }
118}
119
120int main(int argc, char *argv[]){
121 string command = "";
122 vector<string> parameters;
123 if(argc >= 2){
124 command = string(argv[1]);
125 }
126 for(int i = 2; i < argc; i++){
127 string param(argv[i]);
128 parameters.push_back(param);
129 }
130
131 Orchestrator(command,parameters);
132
133 return 0;
134}
135
Main command orchestrator.
Orchestrator(string command, vector< string > parameters)
Constructs orchestrator and executes requested command.
Manages and analyzes function similarity relationships.
void update_similarity(double new_similarity_threshold)
Updates similarity threshold.
int main(int argc, char *argv[])
Main command orchestration interface.