Exemplo n.º 1
0
int main(int argc, char * argv[])
{
	MOOS::MOOSAsyncCommClient C;
	MOOS::CommandLineParser P(argc,argv);

	if(P.GetFlag("-h","--help"))
	{
		PrintHelpAndExit();
	}

	InterestedParty aClass;

	//C.AddMessageRouteToActiveQueue("CallbackA","la",func,NULL);
	//C.AddMessageRouteToActiveQueue("CallbackB","di",func,NULL);
	//C.AddMessageRouteToActiveQueue("CallbackC","di",func_alt,NULL);
	//C.AddMessageRouteToActiveQueue("Wildcard","*", func_wild,NULL);
	//C.AddMessageRouteToActiveQueue("ClassMember","la", &aClass,&InterestedParty::HandleMessageA);
	//C.AddMessageRouteToActiveQueue("ClassMember","di", &aClass,&InterestedParty::HandleMessageB);
	//C.AddWildcardActiveQueue("WCA","*", func_wildcard,NULL);

	//C.PrintMessageToActiveQueueRouting();


	MOOS::MessageQueueAccumulator Acc;

	std::vector<std::string> Names;
	Names.push_back("di");
	Names.push_back("la");

	Acc.Configure(Names);
	C.AddMessageRouteToActiveQueue("Accumulator","di", &Acc,&MOOS::MessageQueueAccumulator::AddMessage);
	C.AddMessageRouteToActiveQueue("Accumulator","la", &Acc,&MOOS::MessageQueueAccumulator::AddMessage);
	Acc.SetCallback(&aClass,&InterestedParty::HandleMessageSet);



	//C.lala();
	C.SetOnConnectCallBack(on_connect, &C);
	C.Run("localhost",9000,"queue_test");


	unsigned int j = 0;
	while(++j)
	{
		if(j%100==0)
		{
			C.AddWildcardActiveQueue("WCB","d*", &aClass,&InterestedParty::HandleMessageC);
			C.PrintMessageToActiveQueueRouting();
		}
		MOOSPause(100);
		continue;
	}




}
Exemplo n.º 2
0
//--------------------------------------------------------------------------------------------------
static void CommandArgHandler
(
    const char* command
)
{
    if (strcmp(command, "help") == 0)
    {
        PrintHelpAndExit();
    }

    else if (strcmp(command, "level") == 0)
    {
        Command = LOG_CMD_SET_LEVEL;

        // Expect a log level next.
        le_arg_AddPositionalCallback(LogLevelArgHandler);
    }
    else if (strcmp(command, "trace") == 0)
    {
        Command = LOG_CMD_ENABLE_TRACE;

        // Expect a trace keyword next.
        le_arg_AddPositionalCallback(TraceKeywordArgHandler);
    }
    else if (strcmp(command, "stoptrace") == 0)
    {
        Command = LOG_CMD_DISABLE_TRACE;

        // Expect a trace keyword next.
        le_arg_AddPositionalCallback(TraceKeywordArgHandler);
    }
    else if (strcmp(command, "list") == 0)
    {
        Command = LOG_CMD_LIST_COMPONENTS;

        // This command has no parameters and no destination.
    }
    else if (strcmp(command, "forget") == 0)
    {
        Command = LOG_CMD_FORGET_PROCESS;

        // This command has only a process name (or pid) as a parameter.
        le_arg_AddPositionalCallback(ProcessIdArgHandler);
    }
    else
    {
        char errorMsg[100];
        snprintf(errorMsg, sizeof(errorMsg), "Invalid log command (%s)", command);
        ExitWithErrorMsg(errorMsg);
    }
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------------------------------
static void CommandArgHandler
(
    const char* command
)
//--------------------------------------------------------------------------------------------------
{
    if (strcmp(command, "get") == 0)
    {
        CommandHandler = HandleGet;

        // Get the node path from our command line arguments and accept an optional --format=X arg.
        le_arg_AddPositionalCallback(NodePathArgHandler);
        le_arg_SetStringCallback(FormatArgHandler, NULL, "format");
    }
    else if (strcmp(command, "set") == 0)
    {
        CommandHandler = HandleSet;

        // Get the node path and value from our command line arguments.
        le_arg_AddPositionalCallback(NodePathArgHandler);
        le_arg_AddPositionalCallback(NodeValueArgHandler);
    }
    else if (strcmp(command, "move") == 0)
    {
        CommandHandler = HandleCopy;

        DeleteAfterCopy = true;

        le_arg_AddPositionalCallback(NodePathArgHandler);
        le_arg_AddPositionalCallback(NodeDestPathArgHandler);
    }
    else if (strcmp(command, "copy") == 0)
    {
        CommandHandler = HandleCopy;

        DeleteAfterCopy = false;

        le_arg_AddPositionalCallback(NodePathArgHandler);
        le_arg_AddPositionalCallback(NodeDestPathArgHandler);
    }
    else if (strcmp(command, "import") == 0)
    {
        CommandHandler = HandleImport;

        // Expect a node path and a file path, with an optional --format= argument.
        le_arg_AddPositionalCallback(NodePathArgHandler);
        le_arg_AddPositionalCallback(FilePathArgHandler);
        le_arg_SetStringCallback(FormatArgHandler, NULL, "format");
    }
    else if (strcmp(command, "export") == 0)
    {
        CommandHandler = HandleExport;

        // Expect a node path and a file path, with an optional --format= argument.
        le_arg_AddPositionalCallback(NodePathArgHandler);
        le_arg_AddPositionalCallback(FilePathArgHandler);
        le_arg_SetStringCallback(FormatArgHandler, NULL, "format");
    }
    else if (strcmp(command, "delete") == 0)
    {
        CommandHandler = HandleDelete;

        // Need a node path from our command line arguments.
        le_arg_AddPositionalCallback(NodePathArgHandler);
    }
    else if (strcmp(command, "clear") == 0)
    {
        CommandHandler = HandleClear;

        // Need a node path from our command line arguments.
        le_arg_AddPositionalCallback(NodePathArgHandler);
    }
    else if (strcmp(command, "list") == 0)
    {
        CommandHandler = HandleList;

        // No additional command-line parameters for this command.
    }
    else if (strcmp(command, "rmtree") == 0)
    {
        CommandHandler = HandleDeleteTree;

        // The only parameter is the tree name.
        le_arg_AddPositionalCallback(TreeNameArgHandler);
    }
    else if (strcmp(command, "help") == 0)
    {
        PrintHelpAndExit();
    }
    else
    {
        fprintf(stderr,
                "Error, unrecognized command, '%s'.\n"
                "For more details please run:\n"
                "\t%s help\n\n",
                command,
                ProgramName);

        exit(EXIT_FAILURE);
    }
}