D Bus学习(九):利用XML定义D Bus之Singal收发例子
在前面我们学习了使用Glib的高程捆绑方式的method的收发,现在学习singal的收发,xml例子如下
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/com/wei/MyObject">
<interface name="com.wei.MyObject.Sample">
<method name="Test">
<arg name="x" type="u" direction="in" />
<arg name="d_ret" type="d" direction="out" />
</method >
<signal name="Hello">
<arg name="w_dialog" type="s" />
</signal>
</interface >
</node >
在前面我们已经学习了方法Test的处理,现在增加一个信号Hello,为了是的处理方式更为简洁,这个信号只带来一个叫做w_dialog的字符串。同样我们使用dbus-binding-tool工具分别生成了server的头文件wei_server2.h和client的头文件wei_client2.h。(操作方式,请参阅上两次学习)。
Server的编写
查看wei_server2.h,和之前只有method的相比,只有稍稍的改动,在对象的info中,增加了Hello的说明。如下:
... ...
const DBusGObjectInfo dbus_glib_com_wei_object_info = {
0,
dbus_glib_com_wei_methods,
1,
"com.wei.MyObject.Sample\0Test\0S\0x\0I\0u\0d_ret\0O\0F\0N\0d\0\0\0",
"com.wei.MyObject.Sample\0Hello\0\0"
,
"\0"
};
我们需要对象中增加相关的代码,头文件com_wei_myobject2.h如下:
#ifndef WEI_COM_WEI_MYOBJECT2_H
#define WEI_COM_WEI_MYOBJECT2_H
typedef struct ComWeiMyObject2 ComWeiMyObject2;
typedef struct ComWeiMyObject2Class ComWeiMyObject2Class;
struct ComWeiMyObject2
{
GObject parent;
};
struct ComWeiMyObject2Class
{
GObjectClass parent;
};
#define COM_WEI_MYOBJECT2_TYPE (com_wei_myobject2_get_type())
GType com_wei_myobject2_get_type(void);
gboolean com_wei_test(ComWeiMyObject2 * obj ,
相关文档:
XML序列化与反序列化 整理文档
XML序列化与反序列化
// OBJECT -> XML
public static void SaveXml(string filePath, object obj) { SaveXml(filePath, obj, obj.GetType()); }
public static void SaveXml(string filePath, object obj, System.Type ty ......
FusionCharts 的 XML标签属性有一下四种数据类型
* Boolean - 布尔类型,只能为1或者0。例如:<graph showNames=’1′ >
* Number - 数字类型,只能为数字。例如:<graph yAxisMaxValue=’200′ >
* String - 字符串类型,只能为字符串。例如: <graph caption=’My Chart&r ......
一、测试用的em.xml
<?xml version="1.0" encoding="GB2312"?>
<EW cmd="login" mod="Login" version="6.0">
<Source uns="" type="user"/>
<Username>zhangzhiyun@hp</Username>
<Password>111111</Password> ......
实例说明会更清楚些,假设有如下XML文件:
File: message_hutaow.xml
<?xml version="1.0" encoding="UTF-8"?>
<hutaow:Message version="1.0" xmlns:hutaow="http://wangtao.cublog.cn">
<hutaow:Head>
<hutaow:Date>20080502</hutaow:Date>
<hutaow:Source>
......
文章导航 SQL Server 2005 学习笔记系列文章导航
在SQl 2005 For XMl 简单查询(Raw,Auto,Path模式)(1) 里我们说了关于Path,Raw和Auto模式的用法,其实里面不仅仅 是这些简单的操作,还有一些其它的特性,比如说Type或OpenXml方法,sp_xml_preparedocument存储过程 等这些增加的东东,我们来一 ......