Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
cmake_minimum_required(VERSION 3.10)
project(ProcessDemo)
project(Exchange LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Find required packages
find_package(tinyxml2 REQUIRED)
find_package(Threads REQUIRED)

# Include common directory
include_directories(${CMAKE_SOURCE_DIR}/common)

Expand All @@ -14,28 +18,47 @@ set(IPC_SOURCES
common/ipc/SharedMemory_Consumer.cpp
)

# Common non-header sources (scheduler, workers, etc.)
set(COMMON_SOURCES
common/Scheduler/Scheduler.cpp
common/Scheduler/Worker/Worker.cpp
)

# Gateway network sources
set(GATEWAY_NETWORK_SOURCES
Gateway/Network/TcpEpollListener.cpp
)

# Process 1 executable (Gateway)
add_executable(Gateway Gateway/main.cpp ${IPC_SOURCES})
add_executable(Gateway Gateway/main.cpp Gateway/Gateway.cpp ${IPC_SOURCES} ${COMMON_SOURCES} ${GATEWAY_NETWORK_SOURCES})
target_include_directories(Gateway PRIVATE ${CMAKE_SOURCE_DIR}/common)
target_include_directories(Gateway PRIVATE ${CMAKE_SOURCE_DIR}/common/ipc)
target_include_directories(Gateway PRIVATE ${CMAKE_SOURCE_DIR}/common/Logger)
target_link_libraries(Gateway pthread)
target_include_directories(Gateway PRIVATE ${CMAKE_SOURCE_DIR}/common/xml)
target_include_directories(Gateway PRIVATE ${CMAKE_SOURCE_DIR}/common/Scheduler)
target_include_directories(Gateway PRIVATE ${CMAKE_SOURCE_DIR}/Gateway)
target_include_directories(Gateway PRIVATE ${CMAKE_SOURCE_DIR}/Gateway/Network)

target_link_libraries(Gateway PRIVATE tinyxml2 Threads::Threads)

# Process 2 executable
add_executable(process2 process2/main.cpp ${IPC_SOURCES})
add_executable(process2 process2/main.cpp ${IPC_SOURCES} ${COMMON_SOURCES})
target_include_directories(process2 PRIVATE ${CMAKE_SOURCE_DIR}/common)
target_include_directories(process2 PRIVATE ${CMAKE_SOURCE_DIR}/common/ipc)
target_include_directories(process2 PRIVATE ${CMAKE_SOURCE_DIR}/common/Logger)
target_link_libraries(process2 PRIVATE Threads::Threads)

# Test executable - IPC Queue Connection and Crash Recovery Test
add_executable(test_ipc_crash tests/test_ipc_crash.cpp ${IPC_SOURCES})
add_executable(test_ipc_crash tests/test_ipc_crash.cpp ${IPC_SOURCES} ${COMMON_SOURCES})
target_include_directories(test_ipc_crash PRIVATE ${CMAKE_SOURCE_DIR}/common)
target_include_directories(test_ipc_crash PRIVATE ${CMAKE_SOURCE_DIR}/common/ipc)
target_link_libraries(test_ipc_crash PRIVATE Threads::Threads)

# Test executable - Gateway Network and FIX Protocol Test
add_executable(test_gateway tests/test_gateway.cpp)
target_include_directories(test_gateway PRIVATE ${CMAKE_SOURCE_DIR}/common)
target_include_directories(test_gateway PRIVATE ${CMAKE_SOURCE_DIR}/common/Logger)
target_link_libraries(test_gateway PRIVATE Threads::Threads)

# Enable testing
enable_testing()
Expand Down
52 changes: 52 additions & 0 deletions Gateway/Config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma once

#include <cstddef>
#include "XMLReader.h"
#include "String.h"

namespace Exchange::Gateway {
class Config : public Core::XMLNode {
Core::String mPort;
Core::String mBlockingQueueSize;
Core::String mMaxFixEventSize;
Core::String mBacklogSize;

Config(const tinyxml2::XMLElement* element):XMLNode(element){
mPort = getChild("Port").get();
mBlockingQueueSize = getChild("BlockingQueue").getChild("Size").get();
mMaxFixEventSize = getChild("Fix").getChild("MaxEventSize").get();
mBacklogSize = getChild("Fix").getChild("BacklogSize").get();
}
public:
// Delete copy and move constructor to enforce singleton
Config(const Config&) = delete;
Config& operator=(const Config&) = delete;

// Lazy initialization
static void init(const tinyxml2::XMLElement* element) {
static Config instance(element);
getInstance() = &instance;
}

// Accessor
static Config& instance() {
Config* inst = getInstance();
if (!inst) {
ENG_THROW("Gateway::Config accessed before init()");
}
return *inst;
}

// Getters
size_t port() const {return std::stoul(mPort.toString());}
size_t blockingQueueSize() const {return std::stoul(mBlockingQueueSize.toString());}
size_t maxFixEventSize() const {return std::stoul(mMaxFixEventSize.toString());}
size_t backlogSize() const {return std::stoul(mBacklogSize.toString());}

private:
static Config*& getInstance() {
static Config* instance = nullptr;
return instance;
}
};
} // namespace Exchange::Gateway
268 changes: 0 additions & 268 deletions Gateway/Fix.h

This file was deleted.

Loading
Loading