用static封装类的API函数

采用static封装类的API函数

#ifndef SRC_UTIL_FILE_H_
#define SRC_UTIL_FILE_H_

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "util.h"
#include <functional>
using namespace std;

#if defined(__linux__)
#include <limits.h>
#endif

#if defined(_WIN32)
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif // !PATH_MAX

#endif // defined(_WIN32)

namespace toolkit {

class File {
public:
    //创建路径
    static bool create_path(const char *file, unsigned int mod);
    //新建文件,目录文件夹自动生成
    static FILE *create_file(const char *file, const char *mode);
    //判断是否为目录
    static bool is_dir(const char *path) ;
    //判断是否为常规文件
    static bool is_file(const char *path) ;
    //判断是否是特殊目录(. or ..)
    static bool is_special_dir(const char *path);
    //删除目录或文件
    static int delete_file(const char *path) ;

private:
    File();
    ~File();
};

} /* namespace toolkit */
#endif /* SRC_UTIL_FILE_H_ */


#ifndef ADD_CAMERA_H_
#define ADD_CAMERA_H_

#include <stdio.h>
#include <stdlib.h>
#include <string>


using namespace std;

class Camera {

public:
	static void addStream();

	static void delStream();

private:
    Camera();
    ~Camera();
private:
	static mediakit::HttpRequester::Ptr requesterGet; //只能在全局下进行定义
};


#endif //ADD_CAMERA_H_
class HttpRequester : public HttpClientImp
{
   public:
      typedef std::shared_ptr<HttpRequester> Ptr;
};

//编译不过,不支持这么定义
mediakit::HttpRequester::Ptr requesterGet = new HttpRequester();

//编译通过
mediakit::HttpRequester::Ptr Camera::requesterGet(new HttpRequester());

//编译通过
mediakit::HttpRequester::Ptr Camera::requesterGet = std::make_shared<HttpRequester>();


//编译不通过,因为token是函数里面了,需要拿到全局里进行
static onceToken token([]()
{
    mediakit::HttpRequester::Ptr Camera::requesterGet(new HttpRequester());
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值