Skip to content

Commit 48b0d35

Browse files
U-LL_MAIN\AXK08U-LL_MAIN\AXK08
U-LL_MAIN\AXK08
authored and
U-LL_MAIN\AXK08
committed
More code added
1 parent 73108ad commit 48b0d35

File tree

9 files changed

+219
-150
lines changed

9 files changed

+219
-150
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/.vs
1+
/.vs

CMakeLists.txt

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
cmake_minimum_required(VERSION 3.7)
2-
3-
project (sdk-dslink-cpp-poc)
4-
5-
set(CMAKE_CXX_STANDARD 11)
6-
7-
set (Boost_DEBUG ON)
8-
9-
set (Boost_NO_SYSTEM_PATHS ON)
10-
set (Boost_USE_STATIC_LIBS OFF)
11-
set (Boost_USE_MULTITHREAD ON)
12-
set (Boost_USE_STATIC_RUNTIME OFF)
13-
14-
15-
find_package(OpenSSL REQUIRED)
16-
# include_directories(${OPENSSL_INCLUDE_DIR})
17-
set(EXTRA_LIBS ${EXTRA_LIBS} ${OPENSSL_LIBRARIES})
18-
19-
find_package(Boost 1.6 REQUIRED system)
20-
include_directories(${Boost_INCLUDE_DIRS})
21-
set(EXTRA_LIBS ${EXTRA_LIBS} ${Boost_LIBRARIES})
22-
23-
set (SOURCE_FILES
24-
message.cpp
25-
connection.cpp)
26-
add_executable(xyz ${SOURCE_FILES})
27-
target_link_libraries(xyz ${EXTRA_LIBS})
28-
29-
# target_compile_features(client PRIVATE cxx_range_for)
1+
cmake_minimum_required(VERSION 3.7)
2+
3+
project (sdk-dslink-cpp-poc)
4+
5+
set(CMAKE_CXX_STANDARD 11)
6+
7+
set (Boost_DEBUG ON)
8+
9+
set (Boost_NO_SYSTEM_PATHS ON)
10+
set (Boost_USE_STATIC_LIBS OFF)
11+
set (Boost_USE_MULTITHREAD ON)
12+
set (Boost_USE_STATIC_RUNTIME OFF)
13+
14+
find_package(OpenSSL REQUIRED)
15+
# include_directories(${OPENSSL_INCLUDE_DIR})
16+
set(EXTRA_LIBS ${EXTRA_LIBS} ${OPENSSL_LIBRARIES})
17+
18+
find_package(Boost 1.6 REQUIRED system)
19+
include_directories(${Boost_INCLUDE_DIRS})
20+
set(EXTRA_LIBS ${EXTRA_LIBS} ${Boost_LIBRARIES})
21+
22+
set (SOURCE_FILES
23+
message.cpp
24+
connection.cpp
25+
main.cpp)
26+
27+
add_executable(main ${SOURCE_FILES})
28+
target_link_libraries(main ${EXTRA_LIBS})
29+
30+
# target_compile_features(client PRIVATE cxx_range_for)

CMakeSettings.json

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
1-
{
2-
// See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
3-
"configurations": [
4-
// {
5-
// "name": "x86-Debug",
6-
// "generator": "Visual Studio 15 2017",
7-
// "configurationType": "Debug",
8-
// "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
9-
// "cmakeCommandArgs": "",
10-
// "buildCommandArgs": "-m -v:minimal",
11-
// "ctestCommandArgs": "",
12-
// "variables": [
13-
// {
14-
// "name": "CMAKE_TOOLCHAIN_FILE",
15-
// "value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
16-
// }
17-
// ]
18-
19-
// },
20-
// {
21-
// "name": "x86-Release",
22-
// "generator": "Visual Studio 15 2017",
23-
// "configurationType": "Release",
24-
// "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
25-
// "cmakeCommandArgs": "",
26-
// "buildCommandArgs": "-m -v:minimal",
27-
// "ctestCommandArgs": "",
28-
// "variables": [
29-
// {
30-
// "name": "CMAKE_TOOLCHAIN_FILE",
31-
// "value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
32-
// }
33-
// ]
34-
35-
// },
36-
{
37-
"name": "x64-Debug",
38-
"generator": "Visual Studio 15 2017 Win64",
39-
"configurationType": "Debug",
40-
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
41-
"cmakeCommandArgs": "",
42-
"buildCommandArgs": "-m -v:minimal",
43-
"ctestCommandArgs": "",
44-
"variables": [
45-
{
46-
"name": "CMAKE_TOOLCHAIN_FILE",
47-
"value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
48-
}
49-
]
50-
51-
},
52-
{
53-
"name": "x64-Release",
54-
"generator": "Visual Studio 15 2017 Win64",
55-
"configurationType": "Release",
56-
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
57-
"cmakeCommandArgs": "",
58-
"buildCommandArgs": "-m -v:minimal",
59-
"ctestCommandArgs": "",
60-
"variables": [
61-
{
62-
"name": "CMAKE_TOOLCHAIN_FILE",
63-
"value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
64-
}
65-
]
66-
67-
}
68-
]
1+
{
2+
// See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
3+
"configurations": [
4+
// {
5+
// "name": "x86-Debug",
6+
// "generator": "Visual Studio 15 2017",
7+
// "configurationType": "Debug",
8+
// "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
9+
// "cmakeCommandArgs": "",
10+
// "buildCommandArgs": "-m -v:minimal",
11+
// "ctestCommandArgs": "",
12+
// "variables": [
13+
// {
14+
// "name": "CMAKE_TOOLCHAIN_FILE",
15+
// "value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
16+
// }
17+
// ]
18+
19+
// },
20+
// {
21+
// "name": "x86-Release",
22+
// "generator": "Visual Studio 15 2017",
23+
// "configurationType": "Release",
24+
// "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
25+
// "cmakeCommandArgs": "",
26+
// "buildCommandArgs": "-m -v:minimal",
27+
// "ctestCommandArgs": "",
28+
// "variables": [
29+
// {
30+
// "name": "CMAKE_TOOLCHAIN_FILE",
31+
// "value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
32+
// }
33+
// ]
34+
35+
// },
36+
{
37+
"name": "x64-Debug",
38+
"generator": "Visual Studio 15 2017 Win64",
39+
"configurationType": "Debug",
40+
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
41+
"cmakeCommandArgs": "",
42+
"buildCommandArgs": "-m -v:minimal",
43+
"ctestCommandArgs": "",
44+
"variables": [
45+
{
46+
"name": "CMAKE_TOOLCHAIN_FILE",
47+
"value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
48+
}
49+
]
50+
51+
},
52+
{
53+
"name": "x64-Release",
54+
"generator": "Visual Studio 15 2017 Win64",
55+
"configurationType": "Release",
56+
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
57+
"cmakeCommandArgs": "",
58+
"buildCommandArgs": "-m -v:minimal",
59+
"ctestCommandArgs": "",
60+
"variables": [
61+
{
62+
"name": "CMAKE_TOOLCHAIN_FILE",
63+
"value": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
64+
}
65+
]
66+
67+
}
68+
]
6969
}

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
## Windows 10 Setup
2-
3-
1. install visual studio 2017
4-
1. clone `https://github.com/Microsoft/vcpkg.git`
5-
into C:\vcpkg
6-
1. run `.\bootstrap-vcpkg.bat` in vcpkg folder
7-
1. install packages
8-
```
9-
.\vcpkg install boost:x64-windows
10-
.\vcpkg install boost::x64-windows-static
11-
12-
.\vcpkg install openssl:x64-windows
13-
.\vcpkg install openssl:x64-windows-static
14-
```
15-
1. run `.\vcpkg integrate install`
16-
1. In visual studio, use `file-open-folder..` instead of creating project
17-
18-
1+
## Windows 10 Setup
2+
3+
1. install visual studio 2017
4+
1. clone `https://github.com/Microsoft/vcpkg.git`
5+
into C:\vcpkg
6+
1. run `.\bootstrap-vcpkg.bat` in vcpkg folder
7+
1. install packages
8+
```
9+
.\vcpkg install boost:x64-windows
10+
.\vcpkg install boost::x64-windows-static
11+
12+
.\vcpkg install openssl:x64-windows
13+
.\vcpkg install openssl:x64-windows-static
14+
```
15+
1. run `.\vcpkg integrate install`
16+
1. In visual studio, use `file-open-folder..` instead of creating project
17+
18+

connection.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
#include "connection.h"
2-
3-
bool Connection::send(boost::asio::const_buffer buffer)
4-
{
5-
return false;
6-
}
7-
8-
int main() {
9-
Connection conn;
10-
11-
return 0;
12-
}
1+
#include "connection.h"
2+
3+
bool Connection::send(boost::asio::const_buffer buffer)
4+
{
5+
return true;
6+
}
7+

connection.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//#pragma once
2-
3-
#include <boost/asio.hpp>
4-
5-
class Connection {
6-
bool send(boost::asio::const_buffer);
7-
};
8-
1+
#pragma once
2+
3+
#include <boost/asio.hpp>
4+
5+
class Connection {
6+
bool send(boost::asio::const_buffer);
7+
};
8+

main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "connection.h"
2+
#include "message.h"
3+
4+
int main() {
5+
MessageFactory mf = MessageFactory();
6+
Message* sub_msg_hdl = mf.create_message(MSGTYPE_SUBSCRIBE);
7+
sub_msg_hdl->do_something();
8+
9+
return 0;
10+
}

message.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "message.h"
2+
3+
Message* Message::create_message(MessageType message_type)
4+
{
5+
if (message_type == MSGTYPE_SUBSCRIBE) {
6+
return new SubscribeMessage();
7+
}
8+
else {
9+
return NULL;
10+
}
11+
}
12+
13+
Message::~Message()
14+
{
15+
cout << "~Message" << endl;
16+
}

message.h

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,61 @@
1-
#pragma once
2-
3-
enum MessageType {
4-
5-
};
6-
7-
class Message {
8-
};
9-
10-
class MessageHeader {
11-
};
12-
13-
class MessageFactory {
14-
};
1+
#pragma once
2+
3+
#include <cstdio>
4+
#include <cstddef>
5+
#include <iostream>
6+
7+
using namespace std;
8+
9+
enum MessageType {
10+
MSGTYPE_SUBSCRIBE = 0,
11+
MSGTYPE_OBSERVE = 1,
12+
MSGTYPE_LIST = 2,
13+
MSGTYPE_INVOKE = 3,
14+
MSGTYPE_SET = 4
15+
};
16+
17+
class SubscribeMessage;
18+
19+
class Message {
20+
private:
21+
22+
public:
23+
static Message* create_message(MessageType message_type);
24+
virtual void do_something() = 0;
25+
26+
virtual ~Message();
27+
};
28+
29+
class SubscribeMessage : public Message {
30+
void do_something()
31+
{
32+
cout << "Subscribe::do_something" << endl;
33+
}
34+
};
35+
36+
37+
class MessageHeader {
38+
};
39+
40+
class MessageFactory {
41+
public:
42+
MessageFactory(const MessageFactory&) {}
43+
MessageFactory &operator=(const MessageFactory&) {}
44+
45+
Message *pMessage;
46+
47+
//public:
48+
MessageFactory() { pMessage = NULL; }
49+
~MessageFactory() {
50+
if (pMessage) {
51+
cout << "~MessageFactory" << endl;
52+
delete pMessage;
53+
pMessage = NULL;
54+
}
55+
}
56+
57+
Message *create_message(MessageType message_type) {
58+
pMessage = Message::create_message(message_type);
59+
return pMessage;
60+
}
61+
};

0 commit comments

Comments
 (0)