采用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());
});