本文整理汇总了C++中Operation::getParameter方法的典型用法代码示例。如果您正苦于以下问题:C++ Operation::getParameter方法的具体用法?C++ Operation::getParameter怎么用?C++ Operation::getParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation::getParameter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
ListContainer list_container;
StackContainer stack_container;
stack_container.all_lists = &list_container;
TreeContainer tree_container;
tree_container.all_lists = &list_container;
HashContainer hash_container;
hash_container.all_lists = &list_container;
hash_container.stopword_tree = &tree_container;
GraphContainer *graph_container[64];
for(int i = 0; i<64; i++)
graph_container[i] = NULL;
if ( argc != 2 )
{
list_container.error("No file input or too many arguments, please try again");
return -1;
}
ArgumentManager argMgr(argv[1]);
string filename = argMgr.get("script");
//string dict_filename = argMgr.get("dictionary");
char* fn = new char[filename.length()+1];
strcpy(fn, filename.c_str());
//list_container.initialize("dictionary", dict_filename); //insert the dictionary into a list
//ListNode* dictionary_list = list_container.find_list("dictionary");
//tree_container.initiate_tree(dictionary_list->list);
//tree_container.printLevelOrder(tree_container.root, 6);
ifstream fin(fn);
if(fin.fail())
{
list_container.error("Failure to open script file "+filename+" exiting program...");
return -1;
}
list_container.error("||||||||||||| Start log for script file "+filename+" |||||||||||||");
OperationQueue opQueue(filename);
while(!opQueue.isEmpty())
{
Operation op = opQueue.pop();
//cout << op;
if(op.isExpression()) //if true, operation is an expression that needs to be evaluated
{
stack_container.convertToPostfix(op.getExpression()); //convert infix to postfix
stack_container.postfixCalc(op.getName()); //calculte the postfix expression and perform the operations
}
else if(op.getName() == "load" || op.getName() == "rank" || op.getName() == "dijkstra" || op.getName() == "topsort" )
{
if(op.getName() == "load") //loads a file-list text file into an object of graph_container, that is unique to the graph_container's web_id.
{ //and then uses the objects initialize_graph function to build a graph based on the given file-list text file.
string cleaned_filename = list_container.clean_file_name(op.getParameter(1));
for(int i = 0; i<64; i++)//find the first empty graph_container. (support for up to 64 different load functions)
{
if(graph_container[i] == NULL) //once found, create an instance of the object, and initialize the graph with the given file list
{
graph_container[i] = new GraphContainer();
graph_container[i]->web_id = op.getParameter(0);
graph_container[i]->initialize_graph(cleaned_filename);
break;
}
}
}
else if(op.getName() == "rank")
{
string cleaned_filename = list_container.clean_file_name(op.getParameter(1));
for(int i = 0; i<64; i++)
{
if(op.getParameter(0) == graph_container[i]->web_id)
{
graph_container[i]->rank_output(cleaned_filename);
break;
}
}
}
else if(op.getName() == "dijkstra")//call in script with dijkstra(WEBNAME,'vertexname.html')
{
string cleaned_filename = list_container.clean_file_name(op.getParameter(1));
for(int i = 0; i<64; i++)
{
if(op.getParameter(0) == graph_container[i]->web_id)
{
graph_container[i]->dijkstra_calculate(cleaned_filename);
break;
}
}
}
}
else if(op.getName() == "write" || op.getName() == "read") //if false, the operation could be a simple read or write
{
if(op.getName() == "write")
{
if(op.parameterCount() == 2) //this means there is no 'forward' or 'reverse' specification in which we will just assume forward
{
//.........这里部分代码省略.........
示例2:
void
Server::listen()
{
while (true)
{
Socket new_server_socket;
cout << "Wait for input..." << endl;
this->socket.accept(new_server_socket);
cout << "accept new socket." << endl;
string recv_cmd;
bool recv_return = new_server_socket.recv(recv_cmd);
if (!recv_return)
{
cerr << "receive command from client error. @Server::listen" << endl;
continue;
}
cout << "received msg: " << recv_cmd << endl;
Operation operation;
bool parser_return = this->parser(recv_cmd, operation);
cout << "parser_return=" << parser_return << endl; //debug
if (!parser_return)
{
cout << "parser command error. @Server::listen" << endl;
string ret_msg = "invalid command.";
this->response(new_server_socket, ret_msg);
new_server_socket.close();
continue;
}
string ret_msg;
bool _stop = false;
CommandType cmd_type = operation.getCommand();
switch (cmd_type)
{
case CMD_TEST:
{
ret_msg = "OK";
break;
}
case CMD_LOAD:
{
string db_name = operation.getParameter(0);
this->loadDatabase(db_name, "", ret_msg);
break;
}
case CMD_UNLOAD:
{
string db_name = operation.getParameter(0);
this->unloadDatabase(db_name, "", ret_msg);
break;
}
case CMD_IMPORT:
{
string db_name = operation.getParameter(0);
string rdf_path = operation.getParameter(1);
this->importRDF(db_name, "", rdf_path, ret_msg);
break;
}
case CMD_DROP:
{
string db_name = operation.getParameter(0);
this->dropDatabase(db_name, "", ret_msg);
break;
}
case CMD_QUERY:
{
string query = operation.getParameter(0);
this->query(query, ret_msg);
break;
}
case CMD_SHOW:
{
string para = operation.getParameter(0);
if (para == "databases" || para == "all")
{
this->showDatabases(para, "", ret_msg);
}
else
{
ret_msg = "invalid command.";
}
break;
}
case CMD_INSERT:
{
string db_name = operation.getParameter(0);
string rdf_path = operation.getParameter(1);
this->insertTriple(db_name, "", rdf_path, ret_msg);
break;
}
case CMD_STOP:
{
this->stopServer(ret_msg);
_stop = true;
//.........这里部分代码省略.........
示例3: main
int main(int argc, char *argv[])
{
ListContainer list_container;
StackContainer stack_container;
TimeComplexity time_complexity; //TODO: ensure that the below sharing of the same list_container does not interfere with the stack or arithmetic infix to postfix conversions.
time_complexity.all_lists = &list_container; //gives the TimeComplexity object an address to the listContainer
stack_container.all_lists = &list_container; //gives the stackContainer an address to the listContainer
/*
time_actual = 0;
list_container.initialize("A", "A20.txt");
ListNode* list = list_container.find_list("A");
int n_hi = list_container.getN("A");
int estimate = (n_hi*(6*n_hi))+ 9;
cout << estimate << " ESTIMATE " << endl;
list->list.alphabetize();
cout << time_actual << endl;
list->list.output();
return 99; */
if ( argc != 2 )
{
list_container.error("No file input or too many arguments, please try again");
return -1;
}
ArgumentManager argMgr(argv[1]);
string filename = argMgr.get("script");
time_complexity.result_filename = argMgr.get("result");
time_complexity.output("L1,L2,,,,-----,---,O(g(n)),--------,,", "");
time_complexity.output("size,size,operation,T(n) estimate,T(n) actual,c,n0,g(n)=n^2", "append");
char* fn = new char[filename.length()+1];
strcpy(fn, filename.c_str());
ifstream fin(fn);
if(fin.fail())
{
list_container.error("Failure to open script file "+filename+" exiting program...");
return -1;
}
list_container.error("||||||||||||| Start log for script file "+filename+" |||||||||||||");
OperationQueue opQueue(filename);
while(!opQueue.isEmpty())
{
Operation op = opQueue.pop();
//cout << op << endl;
if(op.isExpression()) //if true, operation is an expression that needs to be evaluated
{
stack_container.convertToPostfix(op.getExpression()); //convert infix to postfix
stack_container.postfixCalc(op.getName()); //calculte the postfix expression and perform the operations
}
else if(op.getName() == "write" || op.getName() == "read") //if false, the operation could be a simple read or write
{
if(op.getName() == "write")
{
if(op.parameterCount() == 2) //this means there is no 'forward' or 'reverse' specification in which we will just assume forward
{
list_container.writeForward(op.getParameter(0), op.getParameter(1));
}
else if(op.getParameter(2) == "forward")
{
list_container.writeForward(op.getParameter(0), op.getParameter(1));
}
else if(op.getParameter(2) == "reverse")
{
list_container.writeReverse(op.getParameter(0), op.getParameter(1));
}
else
{
list_container.writeForward(op.getParameter(0), op.getParameter(1));
}
continue;
}
if(op.getName() == "read")
{
list_container.initialize(op.getParameter(0), op.getParameter(1));
continue;
}
}
else if(op.getName() == "union" || op.getName() == "intersection") //if not expression or read/write, it must be a union or intersection command
{
if(op.getName() == "union")
{
// call time complex func, and union here using op.getParameter(0) 1 and 2
time_complexity.union_tracktime(op.getParameter(0), op.getParameter(1), op.getParameter(2));
continue;
}
else if(op.getName() == "intersection")
{
// call time complex func, and intersection here using op.getParameter(0) 1 and 2
time_complexity.intersection_tracktime(op.getParameter(0), op.getParameter(1), op.getParameter(2));
continue;
}
}
else
list_container.error("operation is neither an expression, read/write, or union/intersection and therefore invalid");
}
//.........这里部分代码省略.........