[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
applications/HLA_Tutorial DisplayServiceExplana...
From: |
certi-cvs |
Subject: |
applications/HLA_Tutorial DisplayServiceExplana... |
Date: |
Thu, 01 Nov 2007 13:19:13 +0000 |
CVSROOT: /sources/certi
Module name: applications
Changes by: Eric NOULARD <erk> 07/11/01 13:19:13
Modified files:
HLA_Tutorial : DisplayServiceExplanation.cc CMakeLists.txt
Added files:
HLA_Tutorial : DisplayServiceMessages.hh
GenerateMessagesHeader.cmake
DisplayServiceMessages.hh.in
Log message:
Generate DisplayServiceMessages.hh header during CMake run
in order to avoid looking for sources during the program run.
Currently works for Unix.
On Windows platform we may use a Unix pre-generated file.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/DisplayServiceExplanation.cc?cvsroot=certi&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/CMakeLists.txt?cvsroot=certi&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/DisplayServiceMessages.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/GenerateMessagesHeader.cmake?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/DisplayServiceMessages.hh.in?cvsroot=certi&rev=1.1
Patches:
Index: DisplayServiceExplanation.cc
===================================================================
RCS file:
/sources/certi/applications/HLA_Tutorial/DisplayServiceExplanation.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- DisplayServiceExplanation.cc 24 Oct 2007 14:13:44 -0000 1.2
+++ DisplayServiceExplanation.cc 1 Nov 2007 13:19:12 -0000 1.3
@@ -1,8 +1,9 @@
#include "DisplayServiceExplanation.hh"
+#include "DisplayServiceMessages.hh"
/* constructor */
DisplayServiceExplanation::DisplayServiceExplanation(void) {
- system("clear");
+ system(DS_CLEAR_CONSOLE_COMMAND);
}
/* destructor */
@@ -20,118 +21,49 @@
/* public methods */
void
DisplayServiceExplanation::dispTutorialIntroduction(void) {
- std::cout << "\
-HLA Tutorial\n\n\
-This tutorial gives a brief introduction in the usage of the High Level \
-Architecture Interface Specification 1.3. HLA is a standard for distributed \
-computer simulation systems. The middleware implementing HLA is called Runtime
\
-Infrastructure (RTI).\n\
-The API is separated in so called RTI ambassador services and federate \
-ambassador services. The RTI ambassador services are provided by an \
-RTIambassador object and are handled like normal method invocations. In \
-contrast, federate ambassador services have to be implemented within the \
-federate and can be regarded as a callback mechanism.\n\
-Furthermore the services are divided in different management areas. This \
-tutorial shows and explains the correct usage of essential API calls of \
-the management areas Federation Management, Declaration Management and \
-Object Management.\
- " << std::endl;
+ std::cout << DS_MSG_TUTORIAL_INTRODUCTION << std::endl;
this->getKeyFromCmdLine();
}
void
DisplayServiceExplanation::dispFederationManagement(void) {
- system("clear");
- std::cout << "\
-Federation Management\n\n\
-Services of this management area coordinate federation-wide activities \
-such as creating or destroying federations and joining or resigning a \
-federation. Federation-wide save and restore activities and synchronization \
-operations are also supported. \
- " << std::endl;
-
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_FEDERATION_MANAGEMENT << std::endl;
this->getKeyFromCmdLine();
}
void
DisplayServiceExplanation::dispCreateFederationExecution(void) {
- system("clear");
- std::cout << "\
-Federation Management -> Create Federation Execution\n\n\
-The RTI ambassador service createFederationExecution is usally invoked by the \
-first federate. This service creates the federation specifed by a name and a \
-file holding the federation object model (FOM). \
- " << std::endl;
- std::cout << std::endl;
- std::cout << "Example (controllerFederate.cc):" << std::endl;
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_CREATE_FEDERATION_EXECUTION << std::endl;
std::cout << std::endl;
- system("LOCATION=`find ~/ -name controllerFederate.cc 2>/dev/null`; \
- LN=`cat -n $LOCATION | grep -i 'create federation execution' \
- | awk '{print $1}'`; \
- LN=`echo ${LN}+12 | bc`; \
- cat -n ${LOCATION} | head -n $LN | tail -n 12");
- system("echo $SRCLOC");
+ std::cout << DS_MSG_CREATE_FEDERATION_EXECUTION_SRC << std::endl;
this->getKeyFromCmdLine();
}
void
DisplayServiceExplanation::dispJoinFederationExecution(void) {
- system("clear");
- std::cout << "\
-Federation Management -> Join Federation Execution\n\n\
-The RTI ambassador service joinFederationExecution is used by a federate to \
-join an existing federation. Input parameters are his own name, the federation
\
-name of the federation it wants to join and a pointer to its federate \
-ambassador implementation. \
- " << std::endl;
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_JOIN_FEDERATION_EXECUTION << std::endl;
std::cout << std::endl;
- std::cout << "Example (controllerFederate.cc):" << std::endl;
- std::cout << std::endl;
- system("LOCATION=`find ~/ -name controllerFederate.cc 2>/dev/null`; \
- LN=`cat -n $LOCATION | grep -i 'join federation execution' \
- | awk '{print $1}'`; \
- LN=`echo ${LN}+10 | bc`; \
- cat -n ${LOCATION} | head -n $LN | tail -n 10");
+ std::cout << DS_MSG_JOIN_FEDERATION_EXECUTION_SRC << std::endl;
this->getKeyFromCmdLine();
}
void
DisplayServiceExplanation::dispResignFederationExecution(void) {
- system("clear");
- std::cout << "\
-Federation Management -> Resign Federation Execution\n\n\
-The RTI ambassador service resignFederationExecution is used by a federate \
-when leaving the federation. \
- " << std::endl;
- std::cout << std::endl;
- std::cout << "Example (controllerFederate.cc):" << std::endl;
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_RESIGN_FEDERATION_EXECUTION<< std::endl;
std::cout << std::endl;
- system("LOCATION=`find ~/ -name controllerFederate.cc 2>/dev/null`; \
- LN=`cat -n $LOCATION | grep -i 'resign federation execution' \
- | awk '{print $1}'`; \
- LN=`echo ${LN}+9 | bc`; \
- cat -n ${LOCATION} | head -n $LN | tail -n 9 ");
-
+ std::cout << DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC<< std::endl;
this->getKeyFromCmdLine();
}
void
DisplayServiceExplanation::dispDestroyFederationExecution(void) {
- system("clear");
- std::cout << "\
-Federation Management -> Destroy Federation Execution\n\n\
-The RTI ambassador service destroyFederationExecution is usally invoked \
-by the last federate. This service destroys the current federation \
-execution. \
- " << std::endl;
- std::cout << std::endl;
- std::cout << "Example (controllerFederate.cc):" << std::endl;
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_DESTROY_FEDERATION_EXECUTION << std::endl;
std::cout << std::endl;
- system("LOCATION=`find ~/ -name controllerFederate.cc 2>/dev/null`; \
- LN=`cat -n $LOCATION | grep -i 'destroy federation execution' \
- | awk '{print $1}'`; \
- LN=`echo ${LN}+10 | bc`; \
- cat -n ${LOCATION} | head -n $LN | tail -n 10");
-
+ std::cout << DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC<< std::endl;
this->getKeyFromCmdLine();
}
Index: CMakeLists.txt
===================================================================
RCS file: /sources/certi/applications/HLA_Tutorial/CMakeLists.txt,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- CMakeLists.txt 25 Oct 2007 12:32:54 -0000 1.3
+++ CMakeLists.txt 1 Nov 2007 13:19:13 -0000 1.4
@@ -41,7 +41,7 @@
SET(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
SET(PACKAGE_VERSION_MAJOR "0")
SET(PACKAGE_VERSION_MINOR "1")
-SET(PACKAGE_VERSION_PATCH "2")
+SET(PACKAGE_VERSION_PATCH "3")
SET(PACKAGE_VERSION
"${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
SET(PACKAGE_BUGREPORT "address@hidden")
MESSAGE(STATUS "Configuring ${PACKAGE_NAME} version ${PACKAGE_VERSION}")
@@ -71,7 +71,14 @@
INCLUDE(CPack)
#########################################################################
+# Here we will generate the DisplayServiceMessages.hh include file
+# from DisplayServiceMessages.hh.in file.
+#########################################################################
+INCLUDE(GenerateMessagesHeader.cmake)
+
+#########################################################################
# Go to subdirs
+# (or process library and executable in the current directory)
#########################################################################
###################################
Index: DisplayServiceMessages.hh
===================================================================
RCS file: DisplayServiceMessages.hh
diff -N DisplayServiceMessages.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DisplayServiceMessages.hh 1 Nov 2007 13:19:12 -0000 1.1
@@ -0,0 +1,116 @@
+#ifndef DISPLAY_SERVICE_MESSAGES_H
+#define DISPLAY_SERVICE_MESSAGES_H
+
+#define DS_MSG_TUTORIAL_INTRODUCTION "\
+HLA Tutorial\n\n\
+This tutorial gives a brief introduction in the usage of the High Level \
+Architecture Interface Specification 1.3. HLA is a standard for distributed \
+computer simulation systems. The middleware implementing HLA is called Runtime
\
+Infrastructure (RTI).\n\
+The API is separated in so called RTI ambassador services and federate \
+ambassador services. The RTI ambassador services are provided by an \
+RTIambassador object and are handled like normal method invocations. In \
+contrast, federate ambassador services have to be implemented within the \
+federate and can be regarded as a callback mechanism.\n\
+Furthermore the services are divided in different management areas. This \
+tutorial shows and explains the correct usage of essential API calls of \
+the management areas Federation Management, Declaration Management and \
+Object Management.\
+ "
+
+#define DS_MSG_FEDERATION_MANAGEMENT "\
+Federation Management\n\n\
+Services of this management area coordinate federation-wide activities \
+such as creating or destroying federations and joining or resigning a \
+federation. Federation-wide save and restore activities and synchronization \
+operations are also supported. \
+ "
+
+#define DS_MSG_CREATE_FEDERATION_EXECUTION "\
+Federation Management -> Create Federation Execution\n\n\
+The RTI ambassador service createFederationExecution is usally invoked by the \
+first federate. This service creates the federation specifed by a name and a \
+file holding the federation object model (FOM). \
+ "
+
+#define DS_MSG_CREATE_FEDERATION_EXECUTION_SRC "Example from file:
controllerFederate.cc\n244: /* create federation execution */\n\
+245- try {\n\
+246- rtiAmb.createFederationExecution(federationName.c_str(), \n\
+247- fedFile.c_str());\n\
+248- } catch ( RTI::FederationExecutionAlreadyExists ) {\n\
+249- cout << \"Federation already created by another federate.\" \n\
+250- << endl;\n\
+251- } catch ( RTI::Exception &e ) {\n\
+252- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+253- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
+254- } catch ( ... ) {\n\
+255- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+256- }\n\
+"
+
+#define DS_MSG_JOIN_FEDERATION_EXECUTION "\
+Federation Management -> Join Federation Execution\n\n\
+The RTI ambassador service joinFederationExecution is used by a federate to \
+join an existing federation. Input parameters are his own name, the federation
\
+name of the federation it wants to join and a pointer to its federate \
+ambassador implementation. \
+ "
+
+#define DS_MSG_JOIN_FEDERATION_EXECUTION_SRC "Example from file:
controllerFederate.cc\n260: /* join federation execution */\n\
+261- try {\n\
+262- rtiAmb.joinFederationExecution(federateName.c_str(),\n\
+263- federationName.c_str(),\n\
+264- &myFedAmb);\n\
+265- } catch ( RTI::Exception &e ) {\n\
+266- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+267- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
+268- } catch ( ... ) {\n\
+269- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+270- }\n\
+"
+
+#define DS_MSG_RESIGN_FEDERATION_EXECUTION "\
+Federation Management -> Resign Federation Execution\n\n\
+The RTI ambassador service resignFederationExecution is used by a federate \
+when leaving the federation. \
+ "
+
+#define DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC "Example from file:
controllerFederate.cc\n441: /* resign federation execution */\n\
+442- try {\n\
+443- rtiAmb.resignFederationExecution(\n\
+444- RTI::DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES);\n\
+445- } catch ( RTI::Exception &e ) {\n\
+446- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+447- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
+448- } catch ( ... ) {\n\
+449- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+450- }\n\
+451-\n\
+"
+
+#define DS_MSG_DESTROY_FEDERATION_EXECUTION "\
+Federation Management -> Destroy Federation Execution\n\n\
+The RTI ambassador service destroyFederationExecution is usally invoked \
+by the last federate. This service destroys the current federation \
+execution. \
+ "
+
+#define DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC "Example from file:
controllerFederate.cc\n454: /* destroy federation execution */\n\
+455- try {\n\
+456- rtiAmb.destroyFederationExecution(federationName.c_str());\n\
+457- } catch (RTI::FederatesCurrentlyJoined) {\n\
+458- cout << \"Federates currently joined.\" << endl;\n\
+459- } catch ( RTI::Exception &e ) {\n\
+460- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+461- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
+462- } catch ( ... ) {\n\
+463- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+464- }\n\
+"
+
+#ifdef _WIN32
+#define DS_CLEAR_CONSOLE_COMMAND "cls"
+#else
+#define DS_CLEAR_CONSOLE_COMMAND "clear"
+#endif
+#endif
Index: GenerateMessagesHeader.cmake
===================================================================
RCS file: GenerateMessagesHeader.cmake
diff -N GenerateMessagesHeader.cmake
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ GenerateMessagesHeader.cmake 1 Nov 2007 13:19:12 -0000 1.1
@@ -0,0 +1,50 @@
+#########################################################################
+# Here we will generate the DisplayServiceMessages.hh include file
+# from DisplayServiceMessages.hh.in file.
+#
+# The resulting file contains all messages displayed by the
+# display service.
+# This file is generated in order to ease it's update
+# (or even later translation)
+#
+# There is a 2 steps:
+# - first we run some scripts in order to extract some source line
+# of code
+# - then we generate the header file using CMake CONFIGURE_FILE
+# which basically does var replacement.
+#
+# This generation currently works only on Unix
+# on other platform we just use the provided header file
+# (which may not be up to date)
+#########################################################################
+
+# define a CMake MACRO whose purpose
+# is to grep FOR_NB_LINES lines in
+# the file SRC_FILE from the first line matching
+# FROM_STRING and put the result in VARNAME
+MACRO(GREP_SOURCE SRC_FILE FROM_STRING FOR_NB_LINES VARNAME)
+ # First we run some [not so ugly] scripts in order to get
+ # some numbered lines of code
+ EXECUTE_PROCESS(COMMAND grep -n -i -A ${FOR_NB_LINES} "${FROM_STRING}"
${SRC_FILE}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT_VARIABLE TMP
+ ERROR_VARIABLE DS_MSG_ERROR)
+ # replace end of line with proper escape sequence
+ # '\n' becomes
+ # '\n' for newline + '\' for continuation line
+ # [note that extra '\' are here for CMake escape sequence :=( ]
+ STRING(REPLACE "\n" "\\n\\\n" TMP2 "${TMP}")
+ # Add header line indicating source file name
+ SET(TMP "Example from file: ${SRC_FILE}\\n${TMP2}")
+ # now we should escape '"' for character string
+ STRING(REPLACE "\"" "\\\"" ${VARNAME} "${TMP}")
+ENDMACRO(GREP_SOURCE SRC_FILE FROM_STRING FOR_NB_LINES VARNAME)
+
+IF(UNIX)
+ GREP_SOURCE(controllerFederate.cc "create federation execution" 12
DS_MSG_CREATE_FEDERATION_EXECUTION_SRC)
+ GREP_SOURCE(controllerFederate.cc "join federation execution" 10
DS_MSG_JOIN_FEDERATION_EXECUTION_SRC)
+ GREP_SOURCE(controllerFederate.cc "resign federation execution" 10
DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC)
+ GREP_SOURCE(controllerFederate.cc "destroy federation execution" 10
DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC)
+ # Then we generate the header using var value replacement
+ CONFIGURE_FILE(DisplayServiceMessages.hh.in
${CMAKE_CURRENT_SOURCE_DIR}/DisplayServiceMessages.hh)
+ENDIF(UNIX)
\ No newline at end of file
Index: DisplayServiceMessages.hh.in
===================================================================
RCS file: DisplayServiceMessages.hh.in
diff -N DisplayServiceMessages.hh.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DisplayServiceMessages.hh.in 1 Nov 2007 13:19:12 -0000 1.1
@@ -0,0 +1,70 @@
+#ifndef DISPLAY_SERVICE_MESSAGES_H
+#define DISPLAY_SERVICE_MESSAGES_H
+
+#define DS_MSG_TUTORIAL_INTRODUCTION "\
+HLA Tutorial\n\n\
+This tutorial gives a brief introduction in the usage of the High Level \
+Architecture Interface Specification 1.3. HLA is a standard for distributed \
+computer simulation systems. The middleware implementing HLA is called Runtime
\
+Infrastructure (RTI).\n\
+The API is separated in so called RTI ambassador services and federate \
+ambassador services. The RTI ambassador services are provided by an \
+RTIambassador object and are handled like normal method invocations. In \
+contrast, federate ambassador services have to be implemented within the \
+federate and can be regarded as a callback mechanism.\n\
+Furthermore the services are divided in different management areas. This \
+tutorial shows and explains the correct usage of essential API calls of \
+the management areas Federation Management, Declaration Management and \
+Object Management.\
+ "
+
+#define DS_MSG_FEDERATION_MANAGEMENT "\
+Federation Management\n\n\
+Services of this management area coordinate federation-wide activities \
+such as creating or destroying federations and joining or resigning a \
+federation. Federation-wide save and restore activities and synchronization \
+operations are also supported. \
+ "
+
+#define DS_MSG_CREATE_FEDERATION_EXECUTION "\
+Federation Management -> Create Federation Execution\n\n\
+The RTI ambassador service createFederationExecution is usally invoked by the \
+first federate. This service creates the federation specifed by a name and a \
+file holding the federation object model (FOM). \
+ "
+
+#define DS_MSG_CREATE_FEDERATION_EXECUTION_SRC
"@DS_MSG_CREATE_FEDERATION_EXECUTION_SRC@"
+
+#define DS_MSG_JOIN_FEDERATION_EXECUTION "\
+Federation Management -> Join Federation Execution\n\n\
+The RTI ambassador service joinFederationExecution is used by a federate to \
+join an existing federation. Input parameters are his own name, the federation
\
+name of the federation it wants to join and a pointer to its federate \
+ambassador implementation. \
+ "
+
+#define DS_MSG_JOIN_FEDERATION_EXECUTION_SRC
"@DS_MSG_JOIN_FEDERATION_EXECUTION_SRC@"
+
+#define DS_MSG_RESIGN_FEDERATION_EXECUTION "\
+Federation Management -> Resign Federation Execution\n\n\
+The RTI ambassador service resignFederationExecution is used by a federate \
+when leaving the federation. \
+ "
+
+#define DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC
"@DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC@"
+
+#define DS_MSG_DESTROY_FEDERATION_EXECUTION "\
+Federation Management -> Destroy Federation Execution\n\n\
+The RTI ambassador service destroyFederationExecution is usally invoked \
+by the last federate. This service destroys the current federation \
+execution. \
+ "
+
+#define DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC
"@DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC@"
+
+#ifdef _WIN32
+#define DS_CLEAR_CONSOLE_COMMAND "cls"
+#else
+#define DS_CLEAR_CONSOLE_COMMAND "clear"
+#endif
+#endif
\ No newline at end of file