-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
65 lines (59 loc) · 1.68 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// DynamicRegistration.cpp
// Example how to dynamically use instances of objects (here Adapters) using some sort or
// registration concept
#include"pch.h"
#include "Exceptions.h"
#include "HttpInputAdapter.h"
#include "AdapterConfig.h"
#include "BusinesLogic.h"
#include "Registration.h"
int main()
{
//Register all adapters
Registration reg;
//The main business logic
BusinesLogic bl;
try
{
bl.CreateAdapters(reg);
bl.StartAdapters();
//Do something with a specific adapter
auto httpAdpt = bl.AdapterInstance<HttpInputAdapter>();
httpAdpt->ProcessMessage("A new message");
//Throw example exception when attempting to process an empty message
httpAdpt->ProcessMessage("");
//do what the business logig does
//
//...
//
//end
return 0;
}
catch (ConfigurationLoadException const& e) {
std::cerr << "A Configuration Load Exception happened: " << e.SourceFile() << " " << e.what() << std::endl;
}
catch (FileNotFoundException const& e) {
std::cerr << "File not found: " << e.FilePath() << " " << e.what() << std::endl;
}
catch (AccessDeniedException const& e)
{
if (e.LogLevel() == LogLevels::Error)
{
std::cerr << "An std:exception happened: " << e.what() << std::endl;
}
}
catch (InvalidMessageException const& e) {
std::cerr << "Invalid Message Exception happened: " << e.SourceFile() << " " << e.what() << std::endl;
}
catch (BaseException const& e) {
std::cerr << "An exception happened: " << e.SourceFile() << " " << e.what() << std::endl;
}
catch (std::exception const& e) {
std::cerr << "An std:exception happened: " << e.what() << std::endl;
}
catch (...)
{
std::cerr << "An unknown exception happened: " << std::endl;
}
return 1;
}