updated filestructure and gitignore. uploading exam progress

This commit is contained in:
Christopher Sanden
2025-11-05 20:09:06 +01:00
parent 080cb0e79e
commit 17915675ab
86 changed files with 11835 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# "ON" = build Option 1, "OFF" = build Option 2.
option(BUILD_ASSIGNMENT_04_OPTION_1 "Build Assignment Option 1 (Standard)" OFF)
add_executable(Assignment-04
main.cpp
)
if(BUILD_ASSIGNMENT_04_OPTION_1)
target_sources(Assignment-04
PRIVATE
option1.cpp
option1.h
)
target_compile_definitions(Assignment-04 PRIVATE "ASSIGNMENT_04_OPTION=1")
else()
target_sources(Assignment-04
PRIVATE
option2.cpp
option2.h
)
target_compile_definitions(Assignment-04 PRIVATE "ASSIGNMENT_04_OPTION=2")
endif()
target_link_libraries(Assignment-04
PRIVATE
SharedLib
)
add_custom_command(TARGET Assignment-04 POST_BUILD
# Add a custom command here if needed
COMMAND ${CMAKE_COMMAND} -E echo "Assignment-04 post-build step"
)

View File

@@ -0,0 +1,53 @@
/*
Dear Student,
Remember to follow the coding standards and best practices discussed
in the portfolio assignment document.
Good luck with your portfolio!
NB: Do not delete the code below that prints the assignment and option info!
---------------------------------------------------------------------
*** HOW TO SWITCH BETWEEN OPTION 1 AND OPTION 2 ***
---------------------------------------------------------------------
You CANNOT switch options by changing this file.
1. Go to the 'CMakeLists.txt' file for this assignment.
2. Find the line:
option(BUILD_ASSIGNMENT_OPTION_1 "..." ON)
3. Change 'ON' (for Option 1) to 'OFF' (for Option 2).
*** VERY IMPORTANT: After changing the option ***
Your project will NOT update until you re-run the CMake configuration.
To force an update (e.g., in Visual Studio):
- Right-click the 'CMakeLists.txt' file and select 'Configure Cache'.
- OR, simply delete the 'out' / 'build' folder and rebuild the project.
---------------------------------------------------------------------
*/
#include <iostream>
#include <string_view>
static constexpr std::string_view AssignmentName = "Category 4: Graphs & Dijkstra's Algorithm";
#if ASSIGNMENT_04_OPTION == 1
static constexpr std::string_view AssignmentOption = "Option 1 (Standard): Data Center Network Monitor.";
#include "option1.h"
#elif ASSIGNMENT_04_OPTION == 2
static constexpr std::string_view AssignmentOption = "Option 2 (Advanced): Inter-city Logistics Router.";
#include "option2.h"
#endif
int main(int argc, char* argv[])
{
int appStatus = 0;
std::cout << AssignmentName << std::endl;
std::cout << AssignmentOption << std::endl;
// Create only core or common code in main.cpp
// Use the option header files to implement the specific assignment option logic
appStatus = RunApp();
return appStatus;
}

View File

@@ -0,0 +1,6 @@
#include "option1.h"
#include <iostream>
int RunApp() {
return 0;
}

View File

@@ -0,0 +1,9 @@
#pragma once
#ifndef OPTION1_H
#define OPTION1_H
int RunApp();
#endif // OPTION1_H

View File

@@ -0,0 +1,47 @@
#include <iostream>
#include "option1.h"
#include "SharedLib.h"
static constexpr std::string_view AssignmentOption = "Option 1 (Standard): Data Center Network Monitor.";
/**
* @brief Callback function to process one node.
*/
static bool NodeReadCallback(const int aIndex, const int aTotalCount, const std::string& aNode)
{
std::cout << "Loading Node " << (aIndex + 1) << " of " << aTotalCount << ": " << aNode << "\n";
// Return true to continue reading
return true;
}
/**
* @brief Callback function to process one edge.
*/
static bool EdgeReadCallback(const int aIndex, const int aTotalCount, const std::string& aFromNode, const std::string& aToNode, float aWeight)
{
std::cout << " Loading Edge " << (aIndex + 1) << " of " << aTotalCount << ": "
<< aFromNode << " -> " << aToNode << " (Weight: " << aWeight << ")\n";
// Return true to continue reading
return true;
}
int RunApp()
{
std::cout << AssignmentOption << std::endl;
// Path to the graph data file
std::string filename = "F:\\IKT203\\VisualStudio\\DATA\\city_graph.txt";
std::cout << "Reading graph from file: " << filename << "\n\n";
// Call the utility function with both callbacks
readGraphFromFile(filename, NodeReadCallback, EdgeReadCallback);
std::cout << "\nFinished reading graph." << std::endl;
return 0;
}

View File

@@ -0,0 +1,9 @@
#pragma once
#ifndef OPTION2_H
#define OPTION2_H
int RunApp();
#endif // OPTION2_H