Commit d9a7b185 authored by Mohcine Chraibi's avatar Mohcine Chraibi

Formatting Code

The goal of this commit is always to make  diffs unambiguous by
2. Untabifying all files
1. Indent all files by using 4 spaces

Please adapt you editor so that it uses NO tabs  and only 4 spaces for indenting
parent 7c16ba28
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# -DCMAKE_CXX_COMPILER:STRING=clang++ -DCMAKE_C_COMPILER:STRING=clang . # -DCMAKE_CXX_COMPILER:STRING=clang++ -DCMAKE_C_COMPILER:STRING=clang .
# -DCMAKE_BUILD_TYPE:STRING=Debug (default Release) # -DCMAKE_BUILD_TYPE:STRING=Debug (default Release)
# -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON (default OFF) # -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON (default OFF)
# -DBUILD_TESTING=ON (default OFF)
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
...@@ -16,12 +17,11 @@ set(JPSCORE_VERSION ...@@ -16,12 +17,11 @@ set(JPSCORE_VERSION
${JPSCORE_MAJOR_VERSION}.${JPSCORE_MINOR_VERSION}.${JPSCORE_PATCH_VERSION}) ${JPSCORE_MAJOR_VERSION}.${JPSCORE_MINOR_VERSION}.${JPSCORE_PATCH_VERSION})
message( STATUS "JPSCORE_VERSION: " ${JPSCORE_VERSION} ) message( STATUS "JPSCORE_VERSION: " ${JPSCORE_VERSION} )
# # configure_file ( if(NOT BUILD_TESTING)
# # "${CMAKE_SOURCE_DIR}/Config.h.in" set(BUILD_TESTING OFF)
# # "${CMAKE_BINARY_DIR}/Config.h" endif(NOT BUILD_TESTING)
# # )
# #include_directories ("${CMAKE_BINARY_DIR}")
message( STATUS "BUILD_TESTING: " ${BUILD_TESTING} )
if(NOT DEFINED PROCESSOR_COUNT) if(NOT DEFINED PROCESSOR_COUNT)
# Unknown: # Unknown:
set(PROCESSOR_COUNT 0) set(PROCESSOR_COUNT 0)
...@@ -33,15 +33,6 @@ if(NOT DEFINED PROCESSOR_COUNT) ...@@ -33,15 +33,6 @@ if(NOT DEFINED PROCESSOR_COUNT)
list(LENGTH procs PROCESSOR_COUNT) list(LENGTH procs PROCESSOR_COUNT)
endif(EXISTS "${cpuinfo_file}") endif(EXISTS "${cpuinfo_file}")
# Mac:
# if(APPLE)
# find_program(cmd_sys_pro "system_profiler")
# if(cmd_sys_pro)
# execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info)
# string(REGEX REPLACE "^.*Total Number Of Cores: ([0-9]+).*$" "\\1"
# PROCESSOR_COUNT "${info}")
# endif(cmd_sys_pro)
# endif(APPLE)
# Windows: # Windows:
if(WIN32) if(WIN32)
...@@ -50,8 +41,6 @@ if(NOT DEFINED PROCESSOR_COUNT) ...@@ -50,8 +41,6 @@ if(NOT DEFINED PROCESSOR_COUNT)
endif(NOT DEFINED PROCESSOR_COUNT) endif(NOT DEFINED PROCESSOR_COUNT)
if(PROCESSOR_COUNT) if(PROCESSOR_COUNT)
# add 1 should be magic! http://www.kitware.com/blog/home/post/63
#math(EXPR PROCESSOR_COUNT "${PROCESSOR_COUNT} + 1")
message( STATUS "PROCESSOR_COUNT: " ${PROCESSOR_COUNT}) message( STATUS "PROCESSOR_COUNT: " ${PROCESSOR_COUNT})
set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}") set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}")
endif(PROCESSOR_COUNT) endif(PROCESSOR_COUNT)
...@@ -104,8 +93,7 @@ FIND_PACKAGE(CGAL QUIET) ...@@ -104,8 +93,7 @@ FIND_PACKAGE(CGAL QUIET)
if(CGAL_FOUND) if(CGAL_FOUND)
include (${CGAL_USE_FILE}) include (${CGAL_USE_FILE})
INCLUDE_DIRECTORIES(${CGAL_CORE_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${CGAL_CORE_INCLUDE_DIR})
add_definitions(-D_CGAL=1) add_definitions(-D_CGAL=1)
target_link_libraries (jpscore ${CGAL_CORE_LIBRARY})
message (SEND_ERROR "${CGAL_FOUND}") message (SEND_ERROR "${CGAL_FOUND}")
message (FATAL_ERROR "${CGAL_CORE_INCLUDE_DIR}") message (FATAL_ERROR "${CGAL_CORE_INCLUDE_DIR}")
message (SEND_ERROR " Erreur: ${CGAL_FOUND}") message (SEND_ERROR " Erreur: ${CGAL_FOUND}")
...@@ -115,7 +103,10 @@ else(CGAL_FOUND) ...@@ -115,7 +103,10 @@ else(CGAL_FOUND)
endif(CGAL_FOUND) endif(CGAL_FOUND)
# test files: all cpp-files in Utest # test files: all cpp-files in Utest
file(GLOB test_files "${CMAKE_TEST_DIR}/*.cpp") if(BUILD_TESTING)
file(GLOB test_files "${CMAKE_TEST_DIR}/*.cpp")
endif(BUILD_TESTING)
set ( source_files set ( source_files
main.cpp main.cpp
Simulation.cpp Simulation.cpp
...@@ -269,7 +260,7 @@ set ( header_files ...@@ -269,7 +260,7 @@ set ( header_files
add_library ( core SHARED ${source_files} ) add_library ( core SHARED ${source_files} )
#add_library(core OBJECT ${source_files} ${header_files})
#Target #Target
add_executable( add_executable(
jpscore main.cpp jpscore main.cpp
...@@ -303,33 +294,33 @@ else(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE MATCHES Debug) ...@@ -303,33 +294,33 @@ else(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE MATCHES Debug)
endif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE MATCHES Debug) endif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE MATCHES Debug)
# ----------------------------- cTest ------------------------------------------ # ----------------------------- cTest ------------------------------------------
enable_testing() #adds another build target, which is test for Makefile generators if(BUILD_TESTING)
include(CTest) #adding Dart support enable_testing() #adds another build target, which is test for Makefile generators
include(CTest) #adding Dart support
#test if code compiles and runs default setting. Takes about 30 seconds
add_test (jpscore_compile ${CMAKE_CTEST_COMMAND} #test if code compiles and runs default setting. Takes about 30 seconds
--build-and-test "${CMAKE_SOURCE_DIR}" "${EXECUTABLE_OUTPUT_PATH}" #"${CMAKE_BINARY_DIR}" add_test (jpscore_compile ${CMAKE_CTEST_COMMAND}
--build-generator ${CMAKE_GENERATOR} --build-and-test "${CMAKE_SOURCE_DIR}" "${EXECUTABLE_OUTPUT_PATH}" #"${CMAKE_BINARY_DIR}"
--build-makeprogram ${CMAKE_MAKE_PROGRAM} -j${PROCESSOR_COUNT} --build-generator ${CMAKE_GENERATOR}
--build-two-config --build-makeprogram ${CMAKE_MAKE_PROGRAM} -j${PROCESSOR_COUNT}
--build-exe-dir ${EXECUTABLE_OUTPUT_PATH} # todo wo soll der exe hin?: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} --build-two-config
--build-project JPScore --build-exe-dir ${EXECUTABLE_OUTPUT_PATH} # todo wo soll der exe hin?: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
--test-command jpscore --ini=${CMAKE_SOURCE_DIR}/inputfiles/Default/ini.xml --build-project JPScore
) --test-command jpscore --ini=${CMAKE_SOURCE_DIR}/inputfiles/Default/ini.xml
)
foreach (test_src ${test_files}) foreach (test_src ${test_files})
GET_FILENAME_COMPONENT(test ${test_src} NAME_WE) GET_FILENAME_COMPONENT(test ${test_src} NAME_WE)
add_executable( ${test} ${test_src}) add_executable( ${test} ${test_src})
target_link_libraries (${test} core) target_link_libraries (${test} core)
add_test(NAME ${test} COMMAND ${test}) add_test(NAME ${test} COMMAND ${test})
endforeach(test_src ${test_files}) endforeach(test_src ${test_files})
find_package(PythonInterp)
find_package(PythonInterp) if(PYTHONINTERP_FOUND)
if(PYTHONINTERP_FOUND) message(STATUS "Found Python: " ${PYTHON_EXECUTABLE})
message(STATUS "Found Python: " ${PYTHON_EXECUTABLE}) message(STATUS "run: " ${CMAKE_SOURCE_DIR}/Utest/testflow.py)
message(STATUS "run: " ${CMAKE_SOURCE_DIR}/Utest/testflow.py) set (test_parameters "${CMAKE_SOURCE_DIR}")
set (test_parameters "${CMAKE_SOURCE_DIR}") add_test(NAME flow COMMAND "${CMAKE_TEST_DIR}/testflow.py" "${test_parameters}")
add_test(NAME flow COMMAND "${CMAKE_TEST_DIR}/testflow.py" "${test_parameters}") endif(PYTHONINTERP_FOUND)
#add_test(testtime "${CMAKE_SOURCE_DIR}/Utest/run.py") endif(BUILD_TESTING)
endif(PYTHONINTERP_FOUND)
This diff is collapsed.
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
*/ */
#ifndef _IODISPATCHER_H #ifndef _IODISPATCHER_H
#define _IODISPATCHER_H #define _IODISPATCHER_H
#include "OutputHandler.h" #include "OutputHandler.h"
#include "../geometry/Building.h" #include "../geometry/Building.h"
...@@ -38,35 +38,35 @@ ...@@ -38,35 +38,35 @@
extern OutputHandler* Log; extern OutputHandler* Log;
class IODispatcher { class IODispatcher {
private: private:
std::vector<OutputHandler* > pHandlers; std::vector<OutputHandler* > pHandlers;
std::string WritePed(Pedestrian* ped); std::string WritePed(Pedestrian* ped);
public: public:
IODispatcher(); IODispatcher();
IODispatcher(const IODispatcher& orig); IODispatcher(const IODispatcher& orig);
virtual ~IODispatcher(); virtual ~IODispatcher();
void AddIO(OutputHandler* ioh); void AddIO(OutputHandler* ioh);
const std::vector<OutputHandler*>& GetIOHandlers(); const std::vector<OutputHandler*>& GetIOHandlers();
void Write(const std::string& str); void Write(const std::string& str);
virtual void WriteHeader(int nPeds, double fps, Building* building, int seed); virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
virtual void WriteGeometry(Building* building); virtual void WriteGeometry(Building* building);
virtual void WriteFrame(int frameNr, Building* building); virtual void WriteFrame(int frameNr, Building* building);
virtual void WriteFooter(); virtual void WriteFooter();
int AreaLevel(std::string caption); int AreaLevel(std::string caption);
template<typename A> template<typename A>
bool IsElementInVector(const std::vector<A> &vec, A& el) { bool IsElementInVector(const std::vector<A> &vec, A& el) {
typename std::vector<A>::const_iterator it; typename std::vector<A>::const_iterator it;
it = std::find (vec.begin(), vec.end(), el); it = std::find (vec.begin(), vec.end(), el);
if(it==vec.end()){ if(it==vec.end()){
return false; return false;
}else{ }else{
return true; return true;
} }
} }
}; };
...@@ -74,54 +74,54 @@ public: ...@@ -74,54 +74,54 @@ public:
class TrajectoriesFLAT:public IODispatcher { class TrajectoriesFLAT:public IODispatcher {
public: public:
TrajectoriesFLAT(); TrajectoriesFLAT();
virtual ~TrajectoriesFLAT(){}; virtual ~TrajectoriesFLAT(){};
virtual void WriteHeader(int nPeds, double fps, Building* building, int seed); virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
virtual void WriteGeometry(Building* building); virtual void WriteGeometry(Building* building);
virtual void WriteFrame(int frameNr, Building* building); virtual void WriteFrame(int frameNr, Building* building);
virtual void WriteFooter(); virtual void WriteFooter();
}; };
class TrajectoriesVTK:public IODispatcher { class TrajectoriesVTK:public IODispatcher {
public: public:
TrajectoriesVTK(); TrajectoriesVTK();
virtual ~TrajectoriesVTK(){}; virtual ~TrajectoriesVTK(){};
virtual void WriteHeader(int nPeds, double fps, Building* building, int seed); virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
virtual void WriteGeometry(Building* building); virtual void WriteGeometry(Building* building);
virtual void WriteFrame(int frameNr, Building* building); virtual void WriteFrame(int frameNr, Building* building);
virtual void WriteFooter(); virtual void WriteFooter();
}; };
class TrajectoriesXML_MESH:public IODispatcher { class TrajectoriesXML_MESH:public IODispatcher {
public: public:
TrajectoriesXML_MESH(){}; TrajectoriesXML_MESH(){};
virtual ~TrajectoriesXML_MESH(){}; virtual ~TrajectoriesXML_MESH(){};
//virtual void WriteHeader(int nPeds, double fps, Building* building, int seed); //virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
//virtual void WriteFrame(int frameNr, Building* building); //virtual void WriteFrame(int frameNr, Building* building);
//virtual void WriteFooter(); //virtual void WriteFooter();
virtual void WriteGeometry(Building* building); virtual void WriteGeometry(Building* building);
}; };
class TrajectoriesJPSV06: public IODispatcher { class TrajectoriesJPSV06: public IODispatcher {
public: public:
TrajectoriesJPSV06(){}; TrajectoriesJPSV06(){};
virtual ~TrajectoriesJPSV06(){}; virtual ~TrajectoriesJPSV06(){};
virtual void WriteHeader(int nPeds, double fps, Building* building, int seed); virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
virtual void WriteGeometry(Building* building); virtual void WriteGeometry(Building* building);
virtual void WriteFrame(int frameNr, Building* building); virtual void WriteFrame(int frameNr, Building* building);
virtual void WriteFooter(); virtual void WriteFooter();
}; };
#endif /* _IODISPATCHER_H */ #endif /* _IODISPATCHER_H */
...@@ -35,35 +35,35 @@ using namespace std; ...@@ -35,35 +35,35 @@ using namespace std;
void OutputHandler::Write(string str) { void OutputHandler::Write(string str) {
if (this != NULL) if (this != NULL)
cout << str << endl; cout << str << endl;
} }
void OutputHandler::Write(const char* message,...) { void OutputHandler::Write(const char* message,...) {
char msg[CLENGTH]; char msg[CLENGTH];
va_list ap; va_list ap;
va_start (ap, message); va_start (ap, message);
vsprintf (msg,message ,ap); vsprintf (msg,message ,ap);
va_end (ap); va_end (ap);
string str(msg); string str(msg);
if(str.find("ERROR")==string::npos) { if(str.find("ERROR")==string::npos) {
cout<<msg<<endl; cout<<msg<<endl;
cout.flush(); cout.flush();
} }
else { else {
cerr<<msg<<endl; cerr<<msg<<endl;
cerr.flush(); cerr.flush();
} }
//cout << "\033[1;30mbold red text\033[0m\n"; //cout << "\033[1;30mbold red text\033[0m\n";
//cout << "\033[1;31"<<msg<<"\033[0m\n"; //cout << "\033[1;31"<<msg<<"\033[0m\n";
//cout << "\033[1;31 bla bla \033[0m\n"; //cout << "\033[1;31 bla bla \033[0m\n";
} }
void STDIOHandler::Write(string str) { void STDIOHandler::Write(string str) {
if (this != NULL) if (this != NULL)
cout << str << endl; cout << str << endl;
} }
FileHandler::FileHandler(const char *fn) { FileHandler::FileHandler(const char *fn) {
...@@ -88,13 +88,13 @@ void FileHandler::Write(string str) { ...@@ -88,13 +88,13 @@ void FileHandler::Write(string str) {
} }
void FileHandler::Write(const char* string,...) { void FileHandler::Write(const char* string,...) {
char msg[CLENGTH]; char msg[CLENGTH];
va_list ap; va_list ap;
va_start (ap, string); va_start (ap, string);
vsprintf (msg,string ,ap); vsprintf (msg,string ,ap);
va_end (ap); va_end (ap);
pfp<<msg<<endl; pfp<<msg<<endl;
pfp.flush(); pfp.flush();
} }
TraVisToHandler::TraVisToHandler(string host, int port) { TraVisToHandler::TraVisToHandler(string host, int port) {
...@@ -105,7 +105,7 @@ TraVisToHandler::TraVisToHandler(string host, int port) { ...@@ -105,7 +105,7 @@ TraVisToHandler::TraVisToHandler(string host, int port) {
} }
TraVisToHandler::~TraVisToHandler(){ TraVisToHandler::~TraVisToHandler(){
delete client; delete client;
} }
void TraVisToHandler::Write(string str) { void TraVisToHandler::Write(string str) {
......
...@@ -37,39 +37,39 @@ ...@@ -37,39 +37,39 @@
#include "../general/Macros.h" #include "../general/Macros.h"
class OutputHandler { class OutputHandler {
public: public:
virtual void Write(std::string str); virtual void Write(std::string str);
virtual void Write(const char *string, ...); virtual void Write(const char *string, ...);
virtual ~OutputHandler(){}; virtual ~OutputHandler(){};
}; };
class STDIOHandler : public OutputHandler { class STDIOHandler : public OutputHandler {
public: public:
void Write(std::string str); void Write(std::string str);
}; };
class FileHandler : public OutputHandler { class FileHandler : public OutputHandler {
private: private:
std::ofstream pfp; std::ofstream pfp;
public: public:
FileHandler(const char *fn); FileHandler(const char *fn);
virtual ~FileHandler(); virtual ~FileHandler();
void Write(std::string str); void Write(std::string str);
void Write(const char *string,...); void Write(const char *string,...);
}; };
class TraVisToHandler : public OutputHandler { class TraVisToHandler : public OutputHandler {
private: private:
TraVisToClient* client; TraVisToClient* client;
public: public:
TraVisToHandler(std::string host, int port); TraVisToHandler(std::string host, int port);
virtual ~TraVisToHandler(); virtual ~TraVisToHandler();
void Write(std::string str); void Write(std::string str);
//Some tags are broken //Some tags are broken
std::vector<std::string> brokentags; std::vector<std::string> brokentags;
}; };
......
...@@ -418,8 +418,8 @@ TraVisToClient::shutdownAndCloseSocket(socket_t sock) { ...@@ -418,8 +418,8 @@ TraVisToClient::shutdownAndCloseSocket(socket_t sock) {
//FIXME: //FIXME:
//if (SOCKET_ERROR == closesocket(tcpSocket)) { //if (SOCKET_ERROR == closesocket(tcpSocket)) {
// derror("closesocket() failed"); // derror("closesocket() failed");
// status = false; // status = false;
//} //}
dtrace("leaving shutdownAndCloseSocket()"); dtrace("leaving shutdownAndCloseSocket()");
......
...@@ -91,58 +91,58 @@ typedef int socket_t; ...@@ -91,58 +91,58 @@ typedef int socket_t;
#define HOST "localhost" #define HOST "localhost"
class TraVisToClient { class TraVisToClient {
public: public:
/// create a client with specific parameters /// create a client with specific parameters
TraVisToClient(std::string hostname = HOST, unsigned short port = PORT); TraVisToClient(std::string hostname = HOST, unsigned short port = PORT);
/// Destructor /// Destructor
virtual ~TraVisToClient(); virtual ~TraVisToClient();
/// send datablock to the server /// send datablock to the server
/// this functions is still blocking unfortunately, so it may /// this functions is still blocking unfortunately, so it may
/// influence the execution time of your program /// influence the execution time of your program
void sendData(const char* data); void sendData(const char* data);
/// close the client (end the connection) /// close the client (end the connection)
void close(); void close();
/// send a datagram using the unreliable /// send a datagram using the unreliable
/// udp protokoll /// udp protokoll
void sendDatagram(char *datagram); void sendDatagram(char *datagram);
private: private:
void createConnection(); void createConnection();
unsigned long lookupHostAddress(const char *hostName); unsigned long lookupHostAddress(const char *hostName);
socket_t createClientSocket(const char *serverName, unsigned short portNumber); socket_t createClientSocket(const char *serverName, unsigned short portNumber);
socket_t createServerSocket(unsigned short portNumber); socket_t createServerSocket(unsigned short portNumber);
bool shutdownAndCloseSocket(socket_t sock); bool shutdownAndCloseSocket(socket_t sock);
bool sendMessage(socket_t sock, const void *msg, int msgSize); bool sendMessage(socket_t sock, const void *msg, int msgSize);
bool receiveMessage(socket_t sock, void *msg, int msgSize); bool receiveMessage(socket_t sock, void *msg, int msgSize);
void _printErrorMessage(void); void _printErrorMessage(void);
#ifdef _WIN32 #ifdef _WIN32
bool _startWin32SocketSession(void); bool _startWin32SocketSession(void);
void _stopWin32SocketSession(void); void _stopWin32SocketSession(void);
#else #else
#define closesocket close #define closesocket close
#endif #endif
private: private:
bool _isConnected; bool _isConnected;
socket_t _tcpSocket; socket_t _tcpSocket;
std::string _hostname; std::string _hostname;
unsigned short _port; unsigned short _port;
std::vector<const char *> _msgQueue; std::vector<const char *> _msgQueue;
}; };
......
This diff is collapsed.
...@@ -51,81 +51,81 @@ ...@@ -51,81 +51,81 @@
extern OutputHandler* Log; extern OutputHandler* Log;
class Simulation { class Simulation {
private: private:
///Number of pedestrians in the simulation ///Number of pedestrians in the simulation