logplus/Workflow/WFCrystal/SysUtility/utils/include/Turtle.h
2026-01-16 17:18:41 +08:00

93 lines
2.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @file Turtle.h
* @brief 跨平台所需要包含的头文件。通过包含此头文件使用者不用关心所在的开发平台是linux还是windows
* 可以统一获取跨平台的API,自动包含跨平台所需的的头文件和内置类型。
* 1.使用者只需包含Turtle.h自动包含TurtleHeader.h,TurtleType.h
* 2.本文件提供跨平台API有2种使用方式通过全局函数获取API,通过单例模式获取一个API类的对象
*
* Example1:
* #include "Turtle.h"
* void Func(){
* GetTurtleAPI()->Sleep(1000);
* //可调用任意的API
* }
*
* Example2:
* #include "Turtle.h"
* void Func(){
* std::auto_ptr<TurtleAPI> turtle = Turtle::Instance()->GetTurtleAPI();
* turtle->Sleep(1000);
* //可调用任意的API
* }
*
*
* @date 2014-04-15
* @author Bronco
*/
#ifndef TURTLE_H_
#define TURTLE_H_
#include "TurtleHeader.h"
#include "TurtleType.h"
#include "TurtleAPI.h"
#include "Turtle_globle.h"
#if defined(__linux__)
#include <tr1/memory>
#include "uTurtleAPI.h"
#elif defined(_WINDOWS)
#include <memory>
#include "wTurtleAPI.h"
#endif
namespace pai {
namespace turtle {
/**
* @brief 获取跨平台系统API的全局接口
* Example
* void Func(){
* GetTurtleAPI()->Sleep(1000);
* //可调用任意的API
* }
*/
PAI_TURTLE_EXPORT std::tr1::shared_ptr<TurtleAPI> GetTurtleAPI();
/**
* @class Turtle
* @brief 单例模式的系统API类通过这个类用户可以获取跨平台的系统API对象进而调用接口。
* Example:
* #include "Turtle.h"
* void Func(){
* std::auto_ptr<TurtleAPI> turtle = Turtle::Instance()->GetTurtleAPI();
* turtle->Sleep(1000);
* //可调用任意的API
* }
*
*/
class PAI_TURTLE_EXPORT Turtle{
public:
/**
* @brief Turtle单例全局初始化一次
*/
static Turtle* Instance();
/**
* @brief 获取跨平台系统API接口类对象
*/
std::tr1::shared_ptr<TurtleAPI> GetTurtleAPI();
private:
static Turtle* _instance;
Turtle(){};
~Turtle(){};
Turtle(const Turtle &);
Turtle& operator=(const Turtle &);
};
}/*namespace turtle*/
}/*namespace pai*/
#endif /* TURTLE_H_ */