#!/bin/bash if [ -z "$1" ] ; then echo "GenMOOSApp: usage: $0 [app-name] [prefix]" exit 0 fi if [ -z "$2" ] ; then echo "GenMOOSApp: usage: $0 [app-name] [prefix]" exit 0 fi mkdir $2$1 cd $2$1 cat >> CMakeLists.txt <> ${1}.h <> ${1}Main.cpp < #include "${1}.h" using namespace std; int main(int argc, char *argv[]) { // default parameters file string sMissionFile = "${1}.moos"; //under what name shoud the application register with the MOOSDB? string sMOOSName = "${2}${1}"; switch(argc) { case 3: //command line says don't register with default name sMOOSName = argv[2]; case 2: //command line says don't use default config file sMissionFile = argv[1]; } //make an application ${1} ${1}App; //run it ${1}App.Run(sMOOSName.c_str(), sMissionFile.c_str()); return(0); } EOF cat >> $2${1}.moos <> ${1}.cpp < #include #include "MBUtils.h" #include "${1}.h" using namespace std; //--------------------------------------------------------- // Constructor ${1}::${1}() { } //--------------------------------------------------------- // Destructor ${1}::~${1}() { } //--------------------------------------------------------- // Procedure: OnNewMail bool ${1}::OnNewMail(MOOSMSG_LIST &NewMail) { MOOSMSG_LIST::iterator p; for(p=NewMail.begin(); p!=NewMail.end(); p++) { CMOOSMsg &msg = *p; } return(true); } //--------------------------------------------------------- // Procedure: OnConnectToServer bool ${1}::OnConnectToServer() { RegisterVariables(); return(true); } //--------------------------------------------------------- // Procedure: Iterate() bool ${1}::Iterate() { // happens AppTick times per second return(true); } //--------------------------------------------------------- // Procedure: OnStartUp() // happens before connection is open bool ${1}::OnStartUp() { list sParams; if(m_MissionReader.GetConfiguration(GetAppName(), sParams)) { list::iterator p; for(p=sParams.begin(); p!=sParams.end(); p++) { string original_line = *p; string line = *p; string param = stripBlankEnds(toupper(biteString(line, '='))); string value = stripBlankEnds(line); if(param == "FOO") { //handled } else if(param == "BAR") { //handled } } } RegisterVariables(); return(true); } //--------------------------------------------------------- // Procedure: RegisterVariables void ${1}::RegisterVariables() { // Register("FOOBAR", 0); } EOF echo "$2${1} generated"