-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84f7120
commit 36b2fad
Showing
26 changed files
with
404 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
cmake_minimum_required (VERSION 3.28) | ||
|
||
project ("Application") | ||
|
||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD 23) | ||
|
||
set(CMAKE_C_EXTENSIONS OFF) | ||
set(CMAKE_C_STANDARD_REQUIRED ON) | ||
# set(CMAKE_CXX_EXTENSIONS OFF) | ||
# set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
add_compile_options( | ||
/std:c++latest | ||
/experimental:module | ||
/DWIN32 | ||
/D_WINDOWS | ||
/W4 | ||
/GR | ||
/EHsc | ||
$<$<CONFIG:DEBUG>:/Od> | ||
$<$<CONFIG:RELEASE>:/O2> | ||
) | ||
|
||
add_compile_definitions( | ||
$<$<CONFIG:DEBUG>:DEBUG> | ||
) | ||
|
||
add_library(alarm) | ||
target_sources(alarm | ||
PUBLIC | ||
FILE_SET CXX_MODULES FILES | ||
${CMAKE_SOURCE_DIR}/src/alarm.ixx | ||
) | ||
|
||
target_include_directories(alarm PRIVATE | ||
${CMAKE_SOURCE_DIR}/src | ||
${CMAKE_SOURCE_DIR}/include | ||
) | ||
|
||
add_library(handler) | ||
target_sources(handler | ||
PUBLIC | ||
FILE_SET CXX_MODULES FILES | ||
${CMAKE_SOURCE_DIR}/src/handler.ixx | ||
) | ||
|
||
target_include_directories(handler PRIVATE | ||
${CMAKE_SOURCE_DIR}/src | ||
${CMAKE_SOURCE_DIR}/include | ||
) | ||
|
||
target_link_libraries(handler PRIVATE alarm) | ||
|
||
add_executable(Application | ||
${CMAKE_SOURCE_DIR}/src/alarm.cpp | ||
${CMAKE_SOURCE_DIR}/src/handler.cpp | ||
${CMAKE_SOURCE_DIR}/src/main.cpp | ||
) | ||
|
||
target_include_directories(Application PRIVATE | ||
${CMAKE_SOURCE_DIR}/src | ||
${CMAKE_SOURCE_DIR}/include | ||
) | ||
|
||
target_link_libraries(Application PRIVATE handler) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"version": 3, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 21, | ||
"patch": 0 | ||
}, | ||
"configurePresets": [ | ||
{ | ||
"name": "base", | ||
"hidden": true, | ||
"generator": "Ninja", | ||
"binaryDir": "${sourceDir}/build/${presetName}", | ||
"cacheVariables": { | ||
"CMAKE_BUILD_TYPE": "Debug" | ||
}, | ||
"warnings": { | ||
"uninitialized": true, | ||
"dev": true, | ||
"deprecated": true | ||
}, | ||
"vendor": { | ||
"microsoft.com/VisualStudioSettings/CMake/1.0": { | ||
"intelliSenseMode": "linux-gcc-arm" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "debug", | ||
"displayName": "Debug", | ||
"inherits": "base" | ||
}, | ||
{ | ||
"name": "release", | ||
"displayName": "Release", | ||
"inherits": "base", | ||
"environment": { | ||
"CMAKE_BUILD_TYPE": "Release" | ||
} | ||
} | ||
], | ||
"buildPresets": [ | ||
{ | ||
"name": "build-base", | ||
"hidden": true, | ||
"configurePreset": "debug", | ||
"nativeToolOptions": [ | ||
] | ||
}, | ||
{ | ||
"name": "debug", | ||
"inherits": "build-base" | ||
}, | ||
{ | ||
"name": "release", | ||
"inherits": "build-base", | ||
"configurePreset": "release" | ||
}, | ||
{ | ||
"name": "clang-tidy", | ||
"inherits": "debug", | ||
"targets": [ "clang-tidy" ] | ||
}, | ||
{ | ||
"name": "test", | ||
"inherits": "debug", | ||
"targets": [ "test" ], | ||
"nativeToolOptions": [ | ||
"ARGS=--output-on-failure" | ||
] | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// alarm.cpp | ||
// See project README.md for disclaimer and additional information. | ||
// Feabhas Ltd | ||
|
||
module; | ||
|
||
#include <iostream> | ||
|
||
module Alarms; | ||
|
||
namespace Alarms | ||
{ | ||
Alarm::Alarm(Type type, bool status) | ||
: type{type}, status{status} | ||
{} | ||
|
||
void Alarm::reset() { | ||
status = false; | ||
} | ||
|
||
std::ostream& operator<< (std::ostream& out, const Alarm& alarm) | ||
{ | ||
out << "Alarm " << int(alarm.type) << ": " << (alarm.status ? "on" : "off"); | ||
return out; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module; | ||
#include <iosfwd> | ||
|
||
export module Alarms; | ||
|
||
export namespace Alarms | ||
{ | ||
class Alarm | ||
{ | ||
public: | ||
enum class Type {warning, error, critical}; | ||
Alarm() = default; | ||
Alarm(Type type, bool status); | ||
void reset(); | ||
friend std::ostream& operator<< (std::ostream& out, const Alarm& alarm); | ||
private: | ||
Type type {}; | ||
bool status {}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// handler.cpp | ||
// See project README.md for disclaimer and additional information. | ||
// Feabhas Ltd | ||
|
||
module Handler; | ||
|
||
namespace Handler { | ||
void cancel (Alarms::Alarm& alarm) { | ||
alarm.reset(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export module Handler; | ||
|
||
export import Alarms; | ||
|
||
export namespace Handler { | ||
void cancel(typename Alarms::Alarm& alarm); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// main.cpp | ||
// See project README.md for disclaimer and additional information. | ||
// Feabhas Ltd | ||
|
||
#include <iostream> | ||
import Handler; | ||
|
||
using Alarms::Alarm; | ||
|
||
int main() | ||
{ | ||
Alarm a1 {Alarm::Type::critical, true}; | ||
Handler::cancel(a1); | ||
std::cout << a1 << '\n'; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ import :Base; | |
|
||
export namespace Alarms | ||
{ | ||
extern const char* type_names[]; | ||
const char* type_names[]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Greet; | ||
|
||
const char* greeting() { | ||
return "Hello module"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export module Greet; | ||
export const char* greeting(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
#include <iostream> | ||
|
||
import Greet; | ||
|
||
int main() | ||
{ | ||
std::cout << greeting() << '\n'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export module Evening; | ||
|
||
export namespace evening{ | ||
const char* greeting(); | ||
} | ||
|
||
module :private; | ||
|
||
const char *message = "Good evening"; | ||
|
||
namespace evening { | ||
const char* greeting() { | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
#include <iostream> | ||
|
||
import Morning; | ||
import Evening; | ||
|
||
int main() | ||
{ | ||
std::cout << morning::greeting() << '\n'; | ||
std::cout << evening::greeting() << '\n'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export module Morning; | ||
|
||
export namespace morning { | ||
const char* greeting(); | ||
} | ||
|
||
module :private; | ||
|
||
const char *message = "Good morning"; | ||
|
||
namespace morning { | ||
const char* greeting() { | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
alarm.ixx | ||
constraints.ixx | ||
templates.ixx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// alarm.cpp | ||
// See project README.md for disclaimer and additional information. | ||
// Feabhas Ltd | ||
|
||
module; | ||
|
||
#include <iostream> | ||
|
||
module Alarms; | ||
|
||
namespace Alarms | ||
{ | ||
Alarm::Alarm(Type type, bool status) | ||
: type{type}, status{status} | ||
{} | ||
|
||
void Alarm::reset() | ||
{ | ||
status = false; | ||
} | ||
|
||
std::ostream& operator<< (std::ostream& out, const Alarm& alarm) | ||
{ | ||
out << "Alarm " << int(alarm.type) << ": " << (alarm.status ? "on" : "off"); | ||
return out; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module; | ||
#include <iosfwd> | ||
|
||
export module Alarms; | ||
|
||
export namespace Alarms | ||
{ | ||
class Alarm | ||
{ | ||
public: | ||
enum class Type {unknown, warning, error, critical}; | ||
Alarm() = default; | ||
Alarm(Type type, bool status); | ||
void reset(); | ||
friend std::ostream& operator<< (std::ostream& out, const Alarm& alarm); | ||
private: | ||
Type type {}; | ||
bool status {}; | ||
}; | ||
} |
Oops, something went wrong.