- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Command/CommandDispatcherEntryTest.cpp

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00010
    00011 #include "CommandDispatcherEntry.h"
    00012
    00014
    00015 using namespace Mers::Executives::DeductiveController::Command;
    00016 using Mers::Utils::Lang::String;
    00017 using std::cout;
    00018 using std::endl;
    00019
    00021
    00022 void printFunction(std::ostream &out, const String &fName,
    00023         std::vector< const String * > &fParams)
    00024 {
    00025         out << "Function " << fName << "(";
    00026         for( unsigned int i = 0; i < fParams.size(); ++i ) {
    00027                 if( i != 0 )
    00028                         out << ", ";
    00029                 out << *(fParams[i]);
    00030         }
    00031         out << ")";
    00032 }
    00033
    00035
    00036 int main( int argc, const char * argv[] )
    00037 {
    00038         CommandDispatcherEntry cde( "foo", 3, "bar" );
    00039
    00040         cde.addToParameter( "rope" );
    00041         cde.addToParameter( 0u );
    00042         cde.addToParameter( 0u );
    00043         cde.addToParameter( "tire" );
    00044         cde.addToParameter( 2u );
    00045         cde.addToParameter( 1u );
    00046         cde.addToParameter( "tree" );
    00047
    00048         cout << "Conversion rule: " << cde << endl;
    00049
    00050         String p0("porch");
    00051         String p1("15");
    00052         String p2("wire");
    00053         std::vector< const String * > initialParams;
    00054         initialParams.push_back( &p0 );
    00055         initialParams.push_back( &p1 );
    00056         initialParams.push_back( &p2 );
    00057
    00058         std::vector< const String * > finalParams;
    00059         cde.convertParameters( initialParams, finalParams );
    00060
    00061         printFunction( cout, cde.getFromFunctionName(), initialParams );
    00062
    00063         cout << endl << " mapped to ";
    00064
    00065         printFunction( cout, cde.getToFunctionName(), finalParams );
    00066
    00067         cout << endl;
    00068
    00069         CommandDispatcherEntry cde2( "foo", 0, "bar" );
    00070
    00071         cde2.addToParameter( "rope" );
    00072         cde2.addToParameter( "tire" );
    00073         cde2.addToParameter( "tree" );
    00074
    00075         cout << "Conversion rule: " << cde2 << endl;
    00076
    00077         initialParams.clear();
    00078         cde2.convertParameters( initialParams, finalParams );
    00079
    00080         printFunction( cout, cde2.getFromFunctionName(), initialParams );
    00081
    00082         cout << endl << " mapped to ";
    00083
    00084         printFunction( cout, cde2.getToFunctionName(), finalParams );
    00085
    00086         cout << endl;
    00087
    00088         CommandDispatcherEntry cde3( "pop15", 0, "po.15.wide" );
    00089
    00090         cout << "Conversion rule: " << cde3 << endl;
    00091
    00092         initialParams.clear();
    00093         cde3.convertParameters( initialParams, finalParams );
    00094
    00095         printFunction( cout, cde3.getFromFunctionName(), initialParams );
    00096
    00097         cout << endl << " mapped to ";
    00098
    00099         printFunction( cout, cde3.getToFunctionName(), finalParams );
    00100
    00101         cout << endl;
    00102 }