Skip to content

Commit

Permalink
step1: modify MYFRAME_USE_CV
Browse files Browse the repository at this point in the history
  • Loading branch information
lkpworkspace committed Oct 22, 2023
1 parent ece1828 commit 7aaf595
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 38 deletions.
36 changes: 25 additions & 11 deletions myframe/cmd_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,42 @@ Author: 李柯鹏 <likepeng0418@163.com>
#include "myframe/cmd_channel.h"
#include "myframe/platform.h"

#ifdef MYFRAME_USE_CV
#include "myframe/platform/cmd_channel_generic.h"
#else
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
#include "myframe/platform/cmd_channel_linux.h"
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
#ifdef MYFRAME_USE_CV
#include "myframe/platform/cmd_channel_generic.h"
#else
#include "myframe/platform/cmd_channel_linux.h"
#endif
#elif defined(MYFRAME_OS_WINDOWS)
#ifdef MYFRAME_USE_CV
#include "myframe/platform/cmd_channel_generic.h"
#else
#include "myframe/platform/cmd_channel_generic.h"
#error "Windows support conditional variables only,"
" set MYFRAME_USE_CV to enable"
#endif
#else
#error "Unsupported platform"
#endif

namespace myframe {

std::shared_ptr<CmdChannel> CmdChannel::Create(
std::shared_ptr<Poller> poller) {
#ifdef MYFRAME_USE_CV
return std::make_shared<CmdChannelGeneric>(poller);
#else
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
return std::make_shared<CmdChannelLinux>(poller);
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
#ifdef MYFRAME_USE_CV
return std::make_shared<CmdChannelGeneric>(poller);
#else
return std::make_shared<CmdChannelLinux>(poller);
#endif
#elif defined(MYFRAME_OS_WINDOWS)
#ifdef MYFRAME_USE_CV
return std::make_shared<CmdChannelGeneric>(poller);
#else
#error "Windows support conditional variables only,"
" set MYFRAME_USE_CV to enable"
#endif
#else
#error "Unsupported platform"
#endif
}

Expand Down
17 changes: 11 additions & 6 deletions myframe/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ Author: 李柯鹏 <likepeng0418@163.com>

namespace myframe {

#ifdef MYFRAME_USE_CV
const ev_handle_t Event::DEFAULT_EV_HANDLE{nullptr};
#else
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
// do nothing
#else
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
#ifdef MYFRAME_USE_CV
const ev_handle_t Event::DEFAULT_EV_HANDLE{nullptr};
#endif
#elif defined(MYFRAME_OS_WINDOWS)
#ifdef MYFRAME_USE_CV
const ev_handle_t Event::DEFAULT_EV_HANDLE{nullptr};
#else
#error "Windows support conditional variables only,"
" set MYFRAME_USE_CV to enable"
#endif
#else
#error "Unsupported platform"
#endif

} // namespace myframe
34 changes: 24 additions & 10 deletions myframe/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ Author: 李柯鹏 <likepeng0418@163.com>

namespace myframe {

#ifdef MYFRAME_USE_CV
typedef void* ev_handle_t;
#else
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
typedef int ev_handle_t;
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
#ifdef MYFRAME_USE_CV
typedef void* ev_handle_t;
#else
typedef int ev_handle_t;
#endif
#elif defined(MYFRAME_OS_WINDOWS)
#ifdef MYFRAME_USE_CV
typedef void* ev_handle_t;
#else
#error "Windows support conditional variables only,"
" set MYFRAME_USE_CV to enable"
#endif
#else
#error "Unsupported platform"
#endif

class MYFRAME_EXPORT Event : public std::enable_shared_from_this<Event> {
Expand All @@ -45,14 +52,21 @@ class MYFRAME_EXPORT Event : public std::enable_shared_from_this<Event> {
/* 事件名称 */
virtual std::string GetName() const = 0;

#ifdef MYFRAME_USE_CV
static const ev_handle_t DEFAULT_EV_HANDLE;
#else
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
static const ev_handle_t DEFAULT_EV_HANDLE{-1};
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
#ifdef MYFRAME_USE_CV
static const ev_handle_t DEFAULT_EV_HANDLE;
#else
static const ev_handle_t DEFAULT_EV_HANDLE{-1};
#endif
#elif defined(MYFRAME_OS_WINDOWS)
#ifdef MYFRAME_USE_CV
static const ev_handle_t DEFAULT_EV_HANDLE;
#else
#error "Windows support conditional variables only,"
" set MYFRAME_USE_CV to enable"
#endif
#else
#error "Unsupported platform"
#endif
};

Expand Down
36 changes: 25 additions & 11 deletions myframe/poller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,41 @@ Author: 李柯鹏 <likepeng0418@163.com>
#include "myframe/poller.h"
#include "myframe/platform.h"

#ifdef MYFRAME_USE_CV
#include "myframe/platform/poller_generic.h"
#else
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
#include "myframe/platform/poller_linux.h"
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
#ifdef MYFRAME_USE_CV
#include "myframe/platform/poller_generic.h"
#else
#include "myframe/platform/poller_linux.h"
#endif
#elif defined(MYFRAME_OS_WINDOWS)
#ifdef MYFRAME_USE_CV
#include "myframe/platform/poller_generic.h"
#else
#include "myframe/platform/poller_generic.h"
#error "Windows support conditional variables only,"
" set MYFRAME_USE_CV to enable"
#endif
#else
#error "Unsupported platform"
#endif

namespace myframe {

std::shared_ptr<Poller> Poller::Create() {
#ifdef MYFRAME_USE_CV
return std::make_shared<PollerGeneric>();
#else
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
return std::make_shared<PollerLinux>();
#if defined(MYFRAME_OS_LINUX) || defined(MYFRAME_OS_ANDROID)
#ifdef MYFRAME_USE_CV
return std::make_shared<PollerGeneric>();
#else
return std::make_shared<PollerLinux>();
#endif
#elif defined(MYFRAME_OS_WINDOWS)
#ifdef MYFRAME_USE_CV
return std::make_shared<PollerGeneric>();
#else
#error "Windows support conditional variables only,"
" set MYFRAME_USE_CV to enable"
#endif
#else
#error "Unsupported platform"
#endif
}

Expand Down

0 comments on commit 7aaf595

Please sign in to comment.