197 lines
5.9 KiB
C++
197 lines
5.9 KiB
C++
|
|
|
|
#ifndef HSENSORINFO_H
|
|
#define HSENSORINFO_H
|
|
|
|
#include <HCatBuffer.h>
|
|
#include <HXml.h>
|
|
#include <memory>
|
|
|
|
|
|
class IProgramNode
|
|
{
|
|
public:
|
|
virtual ~IProgramNode() {}
|
|
|
|
virtual void ToXml(HXml &xml) = 0;
|
|
virtual bool FromXml(const HXml &xml) = 0;
|
|
virtual cat::HCatBuffer GetType() const = 0;
|
|
};
|
|
|
|
struct EffectInfo
|
|
{
|
|
int inSpeed; ///< 播放速度
|
|
int outSpeed; ///< 播放速度
|
|
int in; ///< 进入特效
|
|
int out; ///< 退出特效
|
|
int duration; ///< 播放时长, 0.1s
|
|
|
|
EffectInfo() : inSpeed(5), outSpeed(5), in(0), out(0), duration(50) {}
|
|
};
|
|
void to_xml(HXml &xml, const EffectInfo &node);
|
|
void from_xml(const HXml &xml, EffectInfo &node);
|
|
|
|
struct FileInfo {
|
|
cat::HCatBuffer name;
|
|
cat::HCatBuffer md5;
|
|
int size;
|
|
|
|
FileInfo() : size(0) {}
|
|
};
|
|
void to_xml(HXml &xml, const FileInfo &node);
|
|
void from_xml(const HXml &xml, FileInfo &node);
|
|
|
|
/**
|
|
* <text guid="##guid" singleLine="##singleLine" background="##background" calcMode="##calcMode">
|
|
* <style valign="##valign" align="##align" />
|
|
* <string>文本内容</string>
|
|
* <font name="##name" italic="##italic" bold="##bold" underline="##underline" size="##size" color="##color" />
|
|
* <effect inSpeed="##inSpeed" duration="##duration" in="##in" outSpeed="##outSpeed" out="##out" />
|
|
* </text>
|
|
*/
|
|
///< 文本节目
|
|
struct TextInfo : public IProgramNode
|
|
{
|
|
struct Style {
|
|
cat::HCatBuffer valign;
|
|
cat::HCatBuffer align;
|
|
Style() : valign("middle"), align("center") {}
|
|
};
|
|
struct Font {
|
|
cat::HCatBuffer name;
|
|
cat::HCatBuffer color;
|
|
bool italic;
|
|
bool bold;
|
|
bool underline;
|
|
int size;
|
|
Font() : color("#FF0000"), italic(false), bold(false), underline(false), size(16) {}
|
|
};
|
|
|
|
cat::HCatBuffer guid;
|
|
cat::HCatBuffer background; ///< 背景颜色
|
|
bool singleLine; ///< 是否单行显示
|
|
Style style; ///< 对齐方式
|
|
Font font; ///< 字体
|
|
EffectInfo effect; ///< 特效
|
|
cat::HCatBuffer text; ///< 文本
|
|
|
|
TextInfo() : guid("textGuid"), singleLine(false) {}
|
|
|
|
virtual void ToXml(HXml &xml) override { xml.NewChild(GetType()).ToXml(*this); }
|
|
virtual bool FromXml(const HXml &xml) override { return xml.get_to(*this); }
|
|
virtual cat::HCatBuffer GetType() const override { return "text"; }
|
|
};
|
|
void to_xml(HXml &xml, const TextInfo &node);
|
|
void from_xml(const HXml &xml, TextInfo &node);
|
|
|
|
|
|
/**
|
|
* <image guid="##guid" fit="##fit">
|
|
* <file name="name" />
|
|
* <effect inSpeed="##inSpeed" duration="##duration" in="##in" outSpeed="##outSpeed" out="##out"/>
|
|
* </image>
|
|
*/
|
|
///< 图片节目
|
|
struct PhotoInfo : public IProgramNode
|
|
{
|
|
cat::HCatBuffer guid;
|
|
cat::HCatBuffer fit; ///< 填充
|
|
EffectInfo effect; ///< 特效
|
|
FileInfo file; ///< 图片文件
|
|
|
|
PhotoInfo() : guid("photoGuid"), fit("stretch") {}
|
|
virtual void ToXml(HXml &xml) override { xml.NewChild(GetType()).ToXml(*this); }
|
|
virtual bool FromXml(const HXml &xml) override { return xml.get_to(*this); }
|
|
virtual cat::HCatBuffer GetType() const override { return "image"; }
|
|
};
|
|
void to_xml(HXml &xml, const PhotoInfo &node);
|
|
void from_xml(const HXml &xml, PhotoInfo &node);
|
|
|
|
/**
|
|
* <video guid="##guid" aspectRatio="##aspectRatio">
|
|
* <file name="##name" />
|
|
* <playParams duration="##duration"/>
|
|
* </video>
|
|
*/
|
|
///< 视频节目
|
|
struct VideoInfo : public IProgramNode
|
|
{
|
|
struct PlayParams {
|
|
int duration;
|
|
|
|
PlayParams() : duration(500) {}
|
|
};
|
|
|
|
cat::HCatBuffer guid;
|
|
bool aspectRatio;
|
|
FileInfo file;
|
|
PlayParams playParams;
|
|
|
|
VideoInfo() : guid("videoGuid"), aspectRatio(false) {}
|
|
virtual void ToXml(HXml &xml) override { xml.NewChild(GetType()).ToXml(*this); }
|
|
virtual bool FromXml(const HXml &xml) override { return xml.get_to(*this); }
|
|
virtual cat::HCatBuffer GetType() const override { return "video"; }
|
|
};
|
|
void to_xml(HXml &xml, const VideoInfo &node);
|
|
void from_xml(const HXml &xml, VideoInfo &node);
|
|
|
|
///< 节目资源信息
|
|
struct ResourcesInfo
|
|
{
|
|
std::list<std::shared_ptr<IProgramNode>> nodeList; ///< 节目列表
|
|
};
|
|
void to_xml(HXml &xml, const ResourcesInfo &node);
|
|
void from_xml(const HXml &xml, ResourcesInfo &node);
|
|
|
|
///< 区域节点信息
|
|
struct AreaNodeInfo
|
|
{
|
|
struct rectangle {
|
|
int x;
|
|
int y;
|
|
int width;
|
|
int height;
|
|
rectangle() : x(0), y(0), width(8), height(8) {}
|
|
};
|
|
|
|
cat::HCatBuffer guid; ///< 区域guid
|
|
int alpha; ///< 区域透明度
|
|
rectangle rect; ///< 区域位置
|
|
ResourcesInfo resource; ///< 区域资源
|
|
|
|
AreaNodeInfo() : guid("areaGuid"), alpha(255) {}
|
|
};
|
|
void to_xml(HXml &xml, const AreaNodeInfo &node);
|
|
void from_xml(const HXml &xml, AreaNodeInfo &node);
|
|
|
|
///< 节目节点信息
|
|
struct ProgramNodeInfo
|
|
{
|
|
cat::HCatBuffer guid; ///< 节目guid
|
|
std::vector<AreaNodeInfo> areaList; ///< 区域列表
|
|
|
|
ProgramNodeInfo() : guid("programGuid") {}
|
|
};
|
|
void to_xml(HXml &xml, const ProgramNodeInfo &node);
|
|
void from_xml(const HXml &xml, ProgramNodeInfo &node);
|
|
|
|
///< 屏幕节点信息
|
|
struct ScreenNodeInfo
|
|
{
|
|
int timeStamps; ///< 时间戳, 和设备节目不同时清空节目
|
|
std::vector<ProgramNodeInfo> programList; ///< 节目节点
|
|
std::list<std::shared_ptr<IProgramNode>> nodeList; ///< 缓存节目列表, 发送节目的时候清空, 避免外部使用者导致内存泄漏
|
|
|
|
ScreenNodeInfo() : timeStamps(0) {}
|
|
|
|
static bool MatchGet(const cat::HCatBuffer &item) { return item == "GetProgram"; }
|
|
static bool MatchSet(const cat::HCatBuffer &item) { return item == "AddProgram"; }
|
|
static cat::HCatBuffer GetMethod() { return "GetProgram"; }
|
|
static cat::HCatBuffer SetMethod() { return "AddProgram"; }
|
|
};
|
|
void to_xml(HXml &xml, const ScreenNodeInfo &node);
|
|
void from_xml(const HXml &xml, ScreenNodeInfo &node);
|
|
|
|
|
|
#endif // HPROGRAMINFO_H
|