93 lines
2.1 KiB
C
93 lines
2.1 KiB
C
|
|
/*
|
|||
|
|
* @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_ */
|