From bc22a1cd6988ecbcd0698a396eb9efb8769bc87a Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Thu, 5 Oct 2023 08:47:15 +0200 Subject: [PATCH] Added TP_INSA Cmake project. Boilerplate for the TP. --- CMakeLists.txt | 6 ++++++ README.md | 6 +++--- tp/include/figure.h | 12 ++++++++++++ tp/include/polygone.h | 17 +++++++++++++++++ tp/src/main.cpp | 8 ++++++++ tp/src/polygone.cpp | 18 ++++++++++++++++++ 6 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tp/include/figure.h create mode 100644 tp/include/polygone.h create mode 100644 tp/src/main.cpp create mode 100644 tp/src/polygone.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dc8ff8..3fe2942 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.22) # Global Variables set(EXERCICE_TARGET exercice_insa) set(TD_TARGET td_insa) +set(TP_TARGET tp_insa) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -19,6 +20,11 @@ file(GLOB SOURCES_TD "${PROJECT_SOURCE_DIR}/td/td${TD}/src/*.cpp") add_executable(${TD_TARGET} ${SOURCES_TD}) target_include_directories(${TD_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/td/td${ETAPE}/include/") +#TP +file(GLOB SOURCES_TP "${PROJECT_SOURCE_DIR}/tp/src/*.cpp") +add_executable(${TP_TARGET} ${SOURCES_TP}) +target_include_directories(${TP_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/tp/include") + # Adding compilation option depending on the OS if(MSVC) target_compile_options(${EXERCICE_TARGET} PUBLIC /W3 /WX /DEBUG ) diff --git a/README.md b/README.md index 2ccaf95..c6df14d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ cd build ``` cmake -DETAPE=2 -DTD=1 .. ``` -_Dans cet exemple, l'étape 2 et le td 1 seront construits._ +_Dans cet exemple, l'étape 2 et le td 1 seront construits. Le tp lui n'a pas besoin de nombre particulier._ ### Lancer la compilation @@ -23,7 +23,7 @@ Il suffit ensuite de construire l'executable dans le dossier désiré ``` cmake --build . --target ``` ->`` étant soit `td_insa` ou `exercice_insa` +>`` étant soit `td_insa`, `exercice_insa` ou `tp_insa` ## Conseil pour compiler et executer efficacement @@ -43,7 +43,7 @@ _Pour Powershell sur Windows_ run.bat ``` _Pour CMD sur Windows_ ->`` étant soit `td_insa` ou `exercice_insa` +>`` étant soit `td_insa`, `exercice_insa` ou `tp_insa` ## Test des allocations entre la bibliothèque standard et mon implémentation diff --git a/tp/include/figure.h b/tp/include/figure.h new file mode 100644 index 0000000..805de01 --- /dev/null +++ b/tp/include/figure.h @@ -0,0 +1,12 @@ +#ifndef HEADER_FIGURE +#define HEADER_FIGURE + +#include + +class Figure { + public: + virtual int perimetre()=0; + virtual std::string afficherCaracteristiques()=0; +}; + +#endif // HEADER_FIGURE \ No newline at end of file diff --git a/tp/include/polygone.h b/tp/include/polygone.h new file mode 100644 index 0000000..5bdca7b --- /dev/null +++ b/tp/include/polygone.h @@ -0,0 +1,17 @@ +#ifndef HEADER_POLYGONE +#define HEADER_POLYGONE + +#include "figure.h" +#include + +class Polygone : public Figure +{ + public: + Polygone(u_int64_t nb_cotes); + virtual std::string afficherCaracteristiques() override; + virtual int perimetre() override; + private: + u_int64_t _nbcotes; +}; + +#endif // HEADER_POLYGONE \ No newline at end of file diff --git a/tp/src/main.cpp b/tp/src/main.cpp new file mode 100644 index 0000000..8a477f9 --- /dev/null +++ b/tp/src/main.cpp @@ -0,0 +1,8 @@ +#include "../include/polygone.h" +#include + +int main(void) +{ + Polygone coolPoly(5); + std::cout << coolPoly.afficherCaracteristiques() << std::endl; +} \ No newline at end of file diff --git a/tp/src/polygone.cpp b/tp/src/polygone.cpp new file mode 100644 index 0000000..47256ef --- /dev/null +++ b/tp/src/polygone.cpp @@ -0,0 +1,18 @@ +#include "../include/polygone.h" +#include +#include + +Polygone::Polygone(u_int64_t nb_cotes) + : _nbcotes(nb_cotes) +{ +} + +std::string Polygone::afficherCaracteristiques() +{ + return std::string("Nombre de cotes : " + std::to_string(_nbcotes)); +} + +int Polygone::perimetre() +{ + return 0; +} \ No newline at end of file