add:添加一个协议架子。
This commit is contained in:
parent
cf12e52e10
commit
ecce50d58f
@ -18,4 +18,5 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}
|
||||
add_subdirectory(util)
|
||||
add_subdirectory(server-core)
|
||||
add_subdirectory(server)
|
||||
add_subdirectory(gui)
|
||||
add_subdirectory(gui)
|
||||
add_subdirectory(protocol)
|
@ -14,8 +14,10 @@ design/basepanel.h
|
||||
design/basepanel.cxx
|
||||
mainpanel.h
|
||||
mainpanel.cxx
|
||||
modeDirCtrl.h
|
||||
modeDirCtrl.cxx
|
||||
)
|
||||
|
||||
add_executable(gtransm ${PSOURCES})
|
||||
target_link_libraries(gtransm PRIVATE wx::base wx::core)
|
||||
target_link_libraries(gtransm PRIVATE wx::base wx::core protocol)
|
||||
set_target_properties(gtransm PROPERTIES WIN32_EXECUTABLE TRUE)
|
@ -13,7 +13,7 @@ void CBasePanel::Init()
|
||||
edPort_ = new wxTextCtrl(this, wxID_ANY, _(""));
|
||||
btnConnect_ = new wxButton(this, wxID_ANY, _("Connect"));
|
||||
btnDisconnect_ = new wxButton(this, wxID_ANY, _("DisConnect"));
|
||||
dirctrl_ = new wxGenericDirCtrl(this);
|
||||
dirctrl_ = new CModeDirCtrl(this);
|
||||
rbtLocal_ = new wxRadioButton(this, wxID_ANY, _("Local"));
|
||||
rbtRemote_ = new wxRadioButton(this, wxID_ANY, _("Remote"));
|
||||
lbState_ = new wxStaticText(this, wxID_ANY, _("State"));
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define BASEMAIN_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/dirctrl.h>
|
||||
#include "../modeDirCtrl.h"
|
||||
|
||||
constexpr int g_BaseBorder = 3;
|
||||
|
||||
@ -20,7 +20,7 @@ public:
|
||||
wxTextCtrl* edPort_{};
|
||||
wxButton* btnConnect_{};
|
||||
wxButton* btnDisconnect_{};
|
||||
wxGenericDirCtrl* dirctrl_{};
|
||||
CModeDirCtrl* dirctrl_{};
|
||||
wxRadioButton* rbtLocal_{};
|
||||
wxRadioButton* rbtRemote_{};
|
||||
wxStaticText* lbState_{};
|
||||
|
9
gui/modeDirCtrl.cxx
Normal file
9
gui/modeDirCtrl.cxx
Normal file
@ -0,0 +1,9 @@
|
||||
#include "modeDirCtrl.h"
|
||||
|
||||
CModeDirCtrl::CModeDirCtrl(wxWindow* parent, wxWindowID id) : wxGenericDirCtrl(parent, id)
|
||||
{
|
||||
}
|
||||
|
||||
CModeDirCtrl::~CModeDirCtrl()
|
||||
{
|
||||
}
|
13
gui/modeDirCtrl.h
Normal file
13
gui/modeDirCtrl.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef MODEDIRCTRL_H
|
||||
#define MODEDIRCTRL_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/dirctrl.h>
|
||||
|
||||
class CModeDirCtrl : public wxGenericDirCtrl {
|
||||
public:
|
||||
CModeDirCtrl(wxWindow *parent, wxWindowID id = wxID_ANY);
|
||||
~CModeDirCtrl();
|
||||
};
|
||||
|
||||
#endif // MODEDIRCTRL_H
|
19
protocol/CMakeLists.txt
Normal file
19
protocol/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(protocol LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(PSOURCES
|
||||
filebase.h
|
||||
filebase.cxx
|
||||
communicate.h
|
||||
communicate.cxx
|
||||
fileimp/localfile.h
|
||||
fileimp/localfile.cxx
|
||||
fileimp/remotefile.h
|
||||
fileimp/remotefile.cxx
|
||||
)
|
||||
|
||||
add_library(protocol STATIC ${PSOURCES})
|
||||
target_include_directories(protocol PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
0
protocol/communicate.cxx
Normal file
0
protocol/communicate.cxx
Normal file
4
protocol/communicate.h
Normal file
4
protocol/communicate.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef COMMUNICATE_H
|
||||
#define COMMUNICATE_H
|
||||
|
||||
#endif // COMMUNICATE_H
|
27
protocol/filebase.cxx
Normal file
27
protocol/filebase.cxx
Normal file
@ -0,0 +1,27 @@
|
||||
#include "filebase.h"
|
||||
#include "fileimp/localfile.h"
|
||||
#include "fileimp/remotefile.h"
|
||||
|
||||
CFileBase::CFileBase()
|
||||
{
|
||||
}
|
||||
|
||||
CFileBase::~CFileBase()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<CFileBase> CFileBase::Instance(FileOperType type)
|
||||
{
|
||||
std::shared_ptr<CFileBase> ret = nullptr;
|
||||
switch (type) {
|
||||
case TYPE_LOCAL:
|
||||
ret = std::make_shared<CLocalFile>();
|
||||
break;
|
||||
case TYPE_REMOTE:
|
||||
ret = std::make_shared<CRemoteFile>();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
24
protocol/filebase.h
Normal file
24
protocol/filebase.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef FILEBASE_H
|
||||
#define FILEBASE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
enum FileOperType {
|
||||
TYPE_LOCAL,
|
||||
TYPE_REMOTE
|
||||
};
|
||||
|
||||
class CFileBase
|
||||
{
|
||||
public:
|
||||
CFileBase();
|
||||
virtual ~CFileBase();
|
||||
|
||||
public:
|
||||
virtual bool Open(const char* filename) = 0;
|
||||
|
||||
public:
|
||||
static std::shared_ptr<CFileBase> Instance(FileOperType type);
|
||||
};
|
||||
|
||||
#endif // FILEBASE_H
|
14
protocol/fileimp/localfile.cxx
Normal file
14
protocol/fileimp/localfile.cxx
Normal file
@ -0,0 +1,14 @@
|
||||
#include "localfile.h"
|
||||
|
||||
CLocalFile::CLocalFile()
|
||||
{
|
||||
}
|
||||
|
||||
CLocalFile::~CLocalFile()
|
||||
{
|
||||
}
|
||||
|
||||
bool CLocalFile::Open(const char* filename)
|
||||
{
|
||||
return false;
|
||||
}
|
16
protocol/fileimp/localfile.h
Normal file
16
protocol/fileimp/localfile.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef LOCALFILE_H
|
||||
#define LOCALFILE_H
|
||||
|
||||
#include "../filebase.h"
|
||||
|
||||
class CLocalFile : public CFileBase
|
||||
{
|
||||
public:
|
||||
CLocalFile();
|
||||
~CLocalFile();
|
||||
|
||||
public:
|
||||
bool Open(const char* filename) override;
|
||||
};
|
||||
|
||||
#endif // LOCALFILE_H
|
14
protocol/fileimp/remotefile.cxx
Normal file
14
protocol/fileimp/remotefile.cxx
Normal file
@ -0,0 +1,14 @@
|
||||
#include "remotefile.h"
|
||||
|
||||
CRemoteFile::CRemoteFile()
|
||||
{
|
||||
}
|
||||
|
||||
CRemoteFile::~CRemoteFile()
|
||||
{
|
||||
}
|
||||
|
||||
bool CRemoteFile::Open(const char* filename)
|
||||
{
|
||||
return false;
|
||||
}
|
16
protocol/fileimp/remotefile.h
Normal file
16
protocol/fileimp/remotefile.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef REMOTE_H
|
||||
#define REMOTE_H
|
||||
|
||||
#include "../filebase.h"
|
||||
|
||||
class CRemoteFile : public CFileBase
|
||||
{
|
||||
public:
|
||||
CRemoteFile();
|
||||
~CRemoteFile();
|
||||
|
||||
public:
|
||||
bool Open(const char* filename) override;
|
||||
};
|
||||
|
||||
#endif // REMOTE_H
|
Loading…
x
Reference in New Issue
Block a user