Skip to content

Commit d511ab3

Browse files
Added tests
1 parent f872002 commit d511ab3

32 files changed

+642
-207
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ Thumbs.db
7474
### Added by ThirtySomething
7575
CMakeLists.txt.user
7676
build*
77+
.vscode

CMakeLists.txt

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ******************************************************************************
1+
# *******************************************************************************
22
# Copyright (C) 1999 Jim Wanner and the SourceMonitor team.
33
#
44
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,26 +18,31 @@
1818
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1919
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2020
# DEALINGS IN THE SOFTWARE.
21-
# ******************************************************************************
21+
# *******************************************************************************
2222

2323
cmake_minimum_required(VERSION 3.5)
2424

2525
project(SourceMonitorOS LANGUAGES CXX VERSION 0.0.1 DESCRIPTION "SourceMonitor OpenSource")
2626

27-
# ******************************************************************************
27+
# *******************************************************************************
2828
# Settings for smcore
29-
# ******************************************************************************
29+
# *******************************************************************************
3030
add_subdirectory(smcore)
3131

32-
# ******************************************************************************
32+
# *******************************************************************************
3333
# Settings for smcli
34-
# ******************************************************************************
34+
# *******************************************************************************
3535
add_subdirectory(smcli)
3636
target_include_directories(smcli PRIVATE smcore)
3737

38-
# ******************************************************************************
38+
# *******************************************************************************
3939
# Settings for smgui
40-
# ******************************************************************************
40+
# *******************************************************************************
4141
add_subdirectory(smgui)
4242
target_include_directories(smgui PRIVATE smcore)
4343

44+
# *******************************************************************************
45+
# Settings for smtest
46+
# *******************************************************************************
47+
add_subdirectory(smtest)
48+
target_include_directories(smtest PRIVATE smcore)

LICENSE

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
MIT License
22

3-
Copyright (c) 2022 by Jim Wanner and the SourceMonitor Team
3+
Copyright (C) 1999 by Jim Wanner and the SourceMonitor team
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a
6+
copy of this software and associated documentation files (the "Software"),
7+
to deal in the Software without restriction, including without limitation
8+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
9+
and/or sell copies of the Software, and to permit persons to whom the
10+
Software is furnished to do so, subject to the following conditions:
1111

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
12+
The above copyright notice and this permission notice shall be included
13+
in all copies or substantial portions of the Software.
1414

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21+
DEALINGS IN THE SOFTWARE.

documentation/history.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
# History of SourceMonitorOS
22

3-
2022-11-12: Start SourceMonitorOS from scratch, initial setup with smgui, smcore and smcli.
3+
2022-11-23
4+
5+
* Added documentation for settings.
6+
* Added missing translation feature to smcore.
7+
* Added subproject for tests, smtest.
8+
* Improved CMakeLists.txt with details for translation.
9+
* Enable all compile warnings in CMakeLists.txt files.
10+
* Uniform header for CMakeLists.txt and source files.
11+
12+
2022-11-20
13+
14+
* Added basic settings object.
15+
16+
2022-11-12
17+
18+
* Start SourceMonitorOS from scratch, initial setup with smgui, smcore and smcli.

documentation/readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ To get an information about the history of SourceMonitorOS, please see [here][fi
99
## Available descriptions
1010

1111
- [Licsense][doc_license]
12+
- [Settings][doc_settings]
1213

1314
[doc_license]: ./smcore/license.md
15+
[doc_settings]: ./smcore/settings.md
1416
[file_history]: ./history.md
1517
[markdown_github]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
1618
[qt_help]: https://doc.qt.io/qt-6.2/qthelp-framework.html

documentation/smcore/license.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ This is a static function to get the license text to display. Actually this is a
66

77
This is a functionality of `smcore` and located in `smcore/license.*`.
88

9-
### API
9+
### Public API
1010

1111
```c++
1212
namespace smos
1313
{
1414
namespace smcore
1515
{
16-
class SMLicense
16+
class SMCORE_EXPORT SMLicense
1717
{
1818
public:
1919
/**
@@ -22,6 +22,7 @@ namespace smos
2222
* @return QString
2323
*/
2424
static QString getLicense(void);
25+
}
2526
}
2627
}
2728
```

documentation/smcore/settings.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# The settings object
2+
3+
There is a need to have persistent settings somewhere. For this is this object. Because of the plattform independency the settings are stored in an [INI file][wiki_ini_file]. This kind of format is supported by [Qts settings object][qt_qsettings].
4+
5+
## Implementation
6+
7+
This is a functionality of `smcore` and located in `smcore/settings.*`.
8+
9+
## Internals
10+
11+
- Section names will be always in uppercase letters.
12+
- Key names will be always in lowercase letters.
13+
- For both the class will take care about.
14+
15+
### Public API
16+
17+
```c++
18+
namespace smos
19+
{
20+
namespace smcore
21+
{
22+
class SMCORE_EXPORT SMSettings
23+
{
24+
public:
25+
/**
26+
* @brief Default constructor
27+
*
28+
* @param settingsfile Name of settings file
29+
*/
30+
SMSettings(QString settingsfile);
31+
/**
32+
* @brief Default destructor
33+
*
34+
*/
35+
~SMSettings(void);
36+
/**
37+
* @brief Load settings from INI file
38+
*/
39+
void settingsLoad(void);
40+
/**
41+
* @brief Save settings to INI file
42+
*/
43+
void settingsSave(void);
44+
/**
45+
* @brief Get the absolute path to the logfile
46+
*
47+
* @return QString The absolute path to the logfile
48+
*/
49+
QString logfileNameGet(void);
50+
/**
51+
* @brief Set the name (and path) of the logfile
52+
*
53+
* @param logfileName Name (and path) of the logfile to use
54+
*/
55+
void logfileNameSet(QString logfileName);
56+
}
57+
}
58+
}
59+
```
60+
61+
### Usage
62+
63+
```c++
64+
#include <settings.h>
65+
66+
smos::smcore::SMSettings settings = smos::smcore::SMSettings("smos_core.ini");
67+
68+
QString logfileOld = settings.logfileNameGet();
69+
settings.logfileNameSet("logfilenew.log");
70+
```
71+
72+
## Possible issues
73+
74+
This object could be a [singleton][wiki_singleton]. But the intention is to create an instance at the top most level and then [inject][wiki_dependency_injection] it into the core.
75+
76+
[qt_qsettings]: https://doc.qt.io/qt-6.2/qsettings.html
77+
[wiki_dependency_injection]: https://en.wikipedia.org/wiki/Dependency_injection
78+
[wiki_ini_file]: https://en.wikipedia.org/wiki/INI_file
79+
[wiki_singleton]: https://en.wikipedia.org/wiki/Singleton_pattern

readme.md

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ _A journey of a thousand miles begins with a single step. - Laotse_
1717
- License: [MIT][licensemit]
1818
- Framework: [QT][qt] in verison 6.2 LTS
1919

20+
## Required skills
21+
22+
To support the project there is a need of at least one of the listed skills.
23+
24+
[![My Skills](https://skillicons.dev/icons?i=cpp,cmake,git,github,githubactions,md,qt)](https://skillicons.dev)
25+
2026
## Project folder organization
2127

2228
Allthough there are CMake files existing up to know you need to run them using QT Creator.
@@ -25,6 +31,7 @@ Allthough there are CMake files existing up to know you need to run them using Q
2531
- In the folder [smcli][folder_smcli] you can find the command line client of SourceMonitorOS
2632
- In the folder [smcore][folder_smcore] you can find the core functionality of SourceMonitorOS
2733
- In the folder [smgui][folder_smgui] you can find the UI of SourceMonitorOS
34+
- In the folder [smtest][folder_smtest] you can find the tests of at least the [smcore][folder_smcore].
2835

2936
[campwoodsw]: https://www.campwoodsw.com/sourcemonitor.html
3037
[cmake]: https://www.cmake.org
@@ -33,6 +40,7 @@ Allthough there are CMake files existing up to know you need to run them using Q
3340
[folder_smcli]: ./smcli/readme.md
3441
[folder_smcore]: ./smcore/readme.md
3542
[folder_smgui]: ./smgui/readme.md
43+
[folder_smtest]: ./smtest/readme.md^
3644
[licensemit]: https://opensource.org/licenses/MIT
3745
[qt]: https://www.qt.io/
3846
[wannerjim]: https://campwoodsw.com/emcomp/about-us/

smcli/.gitignore

-73
This file was deleted.

smcli/CMakeLists.txt

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ******************************************************************************
1+
# *******************************************************************************
22
# Copyright (C) 1999 Jim Wanner and the SourceMonitor team.
33
#
44
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
1818
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1919
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2020
# DEALINGS IN THE SOFTWARE.
21-
# ******************************************************************************
21+
# *******************************************************************************
2222

2323
cmake_minimum_required(VERSION 3.5)
2424

@@ -36,20 +36,27 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
3636
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core LinguistTools)
3737
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools)
3838

39-
set(TS_FILES smcli_en_150.ts)
39+
set(SMCLI_TS_FILES
40+
smcli_en_150.ts
41+
)
4042

4143
add_executable(smcli
4244
main.cpp
43-
${TS_FILES}
45+
${SMCLI_TS_FILES}
4446
${SMCORE_INCLUDE}
4547
)
48+
49+
target_compile_options(smcli PRIVATE
50+
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
51+
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
52+
)
53+
4654
target_link_libraries(smcli Qt${QT_VERSION_MAJOR}::Core smcore)
4755

4856
if(COMMAND qt_create_translation)
49-
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
50-
else()
51-
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
57+
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${SMCLI_TS_FILES})
5258
endif()
5359

54-
install(TARGETS smcli
55-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
60+
install(TARGETS smcli LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
61+
62+
qt_finalize_executable(smcli)

smcli/main.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//***************************************************************************
1+
//******************************************************************************
22
// Copyright (C) 1999 Jim Wanner and the SourceMonitor team.
33
//
44
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
1818
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1919
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2020
// DEALINGS IN THE SOFTWARE.
21-
//***************************************************************************
21+
//******************************************************************************
2222

2323
#include <QCoreApplication>
2424
#include <QLocale>
@@ -42,7 +42,5 @@ int main(int argc, char *argv[])
4242
}
4343
}
4444

45-
QString license = smos::smcore::SMLicense::getLicense();
46-
4745
return a.exec();
4846
}

0 commit comments

Comments
 (0)