diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c40c64..6c14a86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ set(LIB_PATH "${CMAKE_SOURCE_DIR}/../library") include_directories(${LIB_PATH}/include) add_executable(SharedMemory ${SOURCES} ${HEADERS} main/main.cpp) + target_link_libraries(SharedMemory ${LIB_PATH}/lib/liblibrary.a) diff --git a/main/main.cpp b/main/main.cpp index fdf836c..4ea5b9f 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -3,6 +3,8 @@ #include "../src/SharedMemory.h" #include #include +#include +#include int main(int argc, char** argv) @@ -19,16 +21,33 @@ int main(int argc, char** argv) while(eingabe != "exit") { std::cout << "cmd# "; std::cin >> eingabe; - //if verschieden information ausgaben - if(eingabe == "info") - { - std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl; - std::cout << "memory ID: " << shmget(impl.sharedMemoryKey, 0, 0) << std::endl; - std::cout << "Max memory Size: " << Max_Memory_Size << std::endl; - std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl; - //Memory that is used now - //outprint of all memory - } + //if verschieden information ausgaben + if(eingabe == "info") + { + std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl; + std::cout << "memory ID: " << shmget(impl.sharedMemoryKey, 0, 0) << std::endl; + std::cout << "Max memory Size: " << Max_Memory_Size << std::endl; + std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl; + //Memory that is used now + //outprint of all memory + } + + //Test for write and read + if(eingabe == "write") { + //write a bitMap for example 2 (width) * 2 (high) * 3 (color) in Schared Memory + char bitMap[12] = {0}; + for(int i = 0; i < sizeof(bitMap); i++) + bitMap[i] = 'y'; + writeSharedMemory(bitMap, sizeof(bitMap),1); + } + + if(eingabe == "read") { + char content[12] = {0}; + std::cout << "key "<< impl.sharedMemoryKey << std::endl; + getSharedMemory(content, sizeof(content), 1); + + std::cout << content << std::endl; + } } return 0; } \ No newline at end of file