Skip to content

Commit f6d29e4

Browse files
author
Gin
committed
more comments on program notification
1 parent 272dc77 commit f6d29e4

File tree

3 files changed

+77
-7
lines changed

3 files changed

+77
-7
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,7 +2410,7 @@ if (MSVC)
24102410
# target_compile_options(SerialPrograms PRIVATE /arch:AVX2 /DPA_Arch_x64_AVX2)
24112411
# target_compile_options(SerialPrograms PRIVATE /arch:AVX512 /DPA_Arch_x64_AVX512)
24122412
# target_compile_options(SerialPrograms PRIVATE /arch:AVX512 /DPA_Arch_x64_AVX512GF)
2413-
else()
2413+
else() # macOS and Linux
24142414
if (APPLE)
24152415
# Get root path where Homebrew installs libraries. Example root path: "/opt/homebrew/",
24162416
# where you can find libraries in "/opt/homebrew/lib/" and headers in "/opt/homebrew/include/".
@@ -2421,7 +2421,7 @@ else()
24212421
# Get ONNX Runtime paths
24222422
target_include_directories(SerialPrograms PRIVATE ${HOMEBREW_PREFIX}/include/onnxruntime)
24232423
target_link_libraries(SerialPrograms PRIVATE ${HOMEBREW_PREFIX}/lib/libonnxruntime.dylib)
2424-
else()
2424+
else() # Linux
24252425
# Instructions took from https://github.com/microsoft/onnxruntime/discussions/6489
24262426
# Step 1: Download the file
24272427
file(DOWNLOAD

SerialPrograms/Source/CommonFramework/Notifications/ProgramNotifications.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void send_raw_notification(
8989
const std::vector<std::pair<std::string, std::string>>& messages,
9090
const ImageAttachment& image
9191
){
92-
std::shared_ptr<PendingFileSend> file(new PendingFileSend(logger, image));
92+
std::shared_ptr<PendingFileSend> file = std::make_shared<PendingFileSend>(logger, image);
9393
bool hasFile = !file->filepath().empty();
9494

9595
JsonObject embed;
@@ -147,7 +147,7 @@ void send_raw_notification(
147147
const std::vector<std::pair<std::string, std::string>>& messages,
148148
const std::string& filepath
149149
){
150-
std::shared_ptr<PendingFileSend> file(new PendingFileSend(filepath, true));
150+
std::shared_ptr<PendingFileSend> file = std::make_shared<PendingFileSend>(filepath, true);
151151
bool hasFile = !file->filepath().empty();
152152

153153
JsonObject embed;

SerialPrograms/Source/CommonFramework/Notifications/ProgramNotifications.h

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ class ProgramEnvironment;
2121

2222

2323

24-
// Raw Notification
24+
// Send raw Discord notification according to the notification settings.
25+
// Can control the message sidebar color, message title, and message body.
26+
// messages: vector<pair<string, string>>, the sections of the Discord message.
27+
// The first string in the pair is the section title (will shown as bold) while the second
28+
// string is the section content.
29+
// e.g. {{"Message:", {"This is a message."}}} will shown as (in Markdown):
30+
// **Message**
31+
// This is a message.
32+
// The function will add an additional section "Powered By".
33+
// filepath: send the file as a message attachment.
2534
void send_raw_program_notification_with_file(
2635
Logger& logger, EventNotificationOption& settings,
2736
Color color,
@@ -30,6 +39,20 @@ void send_raw_program_notification_with_file(
3039
const std::vector<std::pair<std::string, std::string>>& messages,
3140
const std::string& filepath
3241
);
42+
43+
// Send raw Discord notification according to the notification settings.
44+
// Can control the message sidebar color, message title, and message body.
45+
// messages: vector<pair<string, string>>, the sections of the Discord message.
46+
// The first string in the pair is the section title (will shown as bold) while the second
47+
// string is the section content.
48+
// e.g. {{"Message:", {"This is a message."}}} will shown as (in Markdown):
49+
// **Message**
50+
// This is a message.
51+
// The function will add an additional section "Powered By".
52+
// image: if not empty, send the screenshot image as part of the message according to the
53+
// notification settings.
54+
// keep_file: if true, the sent image will be saved to the screenshot dir on disk. Otherwise, it
55+
// will be saved to the program TEMP_FOLDER.
3356
void send_raw_program_notification(
3457
Logger& logger, EventNotificationOption& settings,
3558
Color color,
@@ -41,7 +64,19 @@ void send_raw_program_notification(
4164

4265

4366

44-
// Program notification with stats.
67+
// Send custom Discord notification according to the notification settings.
68+
// Can control the message sidebar color, message title, and message body.
69+
// messages: vector<pair<string, string>>, the sections of the Discord message.
70+
// The first string in the pair is the section title (will shown as bold) while the second
71+
// string is the section content.
72+
// e.g. {{"Message:", {"This is a message."}}} will shown as (in Markdown):
73+
// **Message**
74+
// This is a message.
75+
// The function will add additional sections: "Current Session", "Historical Stats"
76+
// and "Powered By".
77+
// current_stats_addendum: add additional message at the end of the "Current Session" section
78+
// where it shows the current program stats message generated by StatsTracker.
79+
// filepath: send the file as a message attachment.
4580
void send_program_notification_with_file(
4681
ProgramEnvironment& env, EventNotificationOption& settings,
4782
Color color,
@@ -50,6 +85,23 @@ void send_program_notification_with_file(
5085
const std::string& current_stats_addendum,
5186
const std::string& filepath
5287
);
88+
89+
// Send custom Discord notification according to the notification settings.
90+
// Can control the message sidebar color, message title, and message body.
91+
// messages: vector<pair<string, string>>, the sections of the Discord message.
92+
// The first string in the pair is the section title (will shown as bold) while the second
93+
// string is the section content.
94+
// e.g. {{"Message:", {"This is a message."}}} will shown as (in Markdown):
95+
// **Message**
96+
// This is a message.
97+
// The function will add additional sections: "Current Session", "Historical Stats"
98+
// and "Powered By".
99+
// current_stats_addendum: add additional message at the end of the "Current Session" section
100+
// where it shows the current program stats message generated by StatsTracker.
101+
// image: if not empty, send the screenshot image as part of the message according to the
102+
// notification settings.
103+
// keep_file: if true, the sent image will be saved to the screenshot dir on disk. Otherwise, it
104+
// will be saved to the program TEMP_FOLDER.
53105
bool send_program_notification(
54106
ProgramEnvironment& env, EventNotificationOption& settings,
55107
Color color,
@@ -61,24 +113,42 @@ bool send_program_notification(
61113

62114

63115

64-
// Other common program notification types.
116+
// Send Discord notification of the current program status according to the notification settings.
117+
// Can send additional message and screenshot image.
118+
// keep_file: if true, the sent image will be saved to the screenshot dir on disk. Otherwise, it
119+
// will be saved to the program TEMP_FOLDER.
65120
void send_program_status_notification(
66121
ProgramEnvironment& env, EventNotificationOption& settings,
67122
const std::string& message = "",
68123
const ImageViewRGB32& image = ImageViewRGB32(), bool keep_file = false
69124
);
70125

126+
// Send Discord notification that the program has finished according to the notification settings.
127+
// Can send additional message and screenshot image.
128+
// keep_file: if true, the sent image will be saved to the screenshot dir on disk. Otherwise, it
129+
// will be saved to the program TEMP_FOLDER.
71130
void send_program_finished_notification(
72131
ProgramEnvironment& env, EventNotificationOption& settings,
73132
const std::string& message = "",
74133
const ImageViewRGB32& image = ImageViewRGB32(), bool keep_file = false
75134
);
76135

136+
// Send Discord notification that the program has encountered a recoverable error according to the
137+
// notification settings.
138+
// Can send additional message and screenshot image.
139+
// keep_file: if true, the sent image will be saved to the screenshot dir on disk. Otherwise, it
140+
// will be saved to the program TEMP_FOLDER.
77141
void send_program_recoverable_error_notification(
78142
ProgramEnvironment& env, EventNotificationOption& settings,
79143
const std::string& message,
80144
const ImageViewRGB32& image = ImageViewRGB32(), bool keep_file = false
81145
);
146+
147+
// Send Discord notification that the program has a fatal error according to the notification
148+
// settings.
149+
// Can send additional message and screenshot image.
150+
// keep_file: if true, the sent image will be saved to the screenshot dir on disk. Otherwise, it
151+
// will be saved to the program TEMP_FOLDER.
82152
void send_program_fatal_error_notification(
83153
ProgramEnvironment& env, EventNotificationOption& settings,
84154
const std::string& message,

0 commit comments

Comments
 (0)