
2009年2月25日
在分析ACE的原碼時(shí)發(fā)現(xiàn)有一種平時(shí)比較少見的調(diào)用方式,記得以前有人用C++描述Command時(shí)也用了這種方式,不過他們的代碼都包裝為模板,不方便理解.這里,我不用模板簡單的展示其特點(diǎn):
#include <iostream>
using namespace std;
class CA
{
public:
CA()
{
cc = 1;
};
int func1(int a, int x)
{
cout<<"func1"<<endl;
cc = a + x;
cout<<"cc is :"<< cc <<endl;
return cc;
}
int func2(int a, int y)
{
cout<<"func2"<<endl;
cc = cc + a * y;
cout<<"cc is:"<<cc<<endl;
return cc;
}
typedef int (CA::*FUNC)(int a, int y);
int Test1()
{
FUNC f;
f = &CA::func2;
return (this->*f) (10, 20);
}
int test2(FUNC func,int a, int b)
{
//ACE中是先做一些共同的復(fù)雜的事,然后調(diào)用不同的func部分:
return (this->*func)(a,b);
}
private:
int cc;
};
int main( void )
{
CA a;
a.Test1();
a.test2(&CA::func2,11,3);
return 0;
}
很酷!調(diào)用者可以把類的函數(shù)作為參數(shù)傳遞.
好再開下面,利用繼承的關(guān)系,我們還可以做到同樣效果:
#include <iostream>
using namespace std;
class CB
{
public:
virtual int func1(int a, int x)=0;
virtual int func2(int a, int x)=0;
typedef int (CB::*FUNC)(int a, int y);
int Test1()
{
FUNC f;
f = &CB::func2;
return (this->*f) (10, 20);
}
int test2(FUNC func,int a, int b)
{
return (this->*func)(a,b);
}
};
class CA:public CB
{
public:
CA()
{
cc = 1;
};
int func1(int a, int x)
{
cout<<"func1"<<endl;
cc = a + x;
cout<<"cc is :"<< cc <<endl;
return cc;
}
int func2(int a, int y)
{
cout<<"func2"<<endl;
cc = cc + a * y;
cout<<"cc is:"<<cc<<endl;
return cc;
}
private:
int cc;
};
int main( void )
{
CB *pB = new CA();
pB->Test1();
pB->test2(&CB::func2,11,3);
delete pB;
return 0;
}
上面的例子如果應(yīng)用到Command模式中,func1 和func2就可以分別是Execute 跟 UnDo的接口了.至于如何實(shí)現(xiàn),就是派生類的問題了.
(上述代碼均在MinGW中測試通過)
posted @
2009-02-25 17:32 名羽 閱讀(1697) |
評論 (3) |
編輯 收藏

2008年12月2日
前兩個(gè)月,公司對我們部門動大手術(shù)了。把軟件研發(fā)部分成了3大塊,分別是:系統(tǒng)工程與架構(gòu)部,開發(fā)部,測試部。由于以前在團(tuán)隊(duì)里基本所有架構(gòu)方面的事都有我參與,所以,這次上頭有意問我有沒做架構(gòu)方面工作的想法。我理想當(dāng)然答應(yīng)這份差事。于是,被提到系統(tǒng)架構(gòu)師的崗位上。這段時(shí)間,經(jīng)過公司培訓(xùn),才發(fā)現(xiàn)做系統(tǒng)架構(gòu)師其實(shí)真不簡單,負(fù)的責(zé)任比我原來想的大多了。另外,自己技術(shù)方面的素養(yǎng)也必須盡快提高,覺得自己應(yīng)在以下方面多下功夫:
1.領(lǐng)域內(nèi)的知識面的擴(kuò)展。
2.軟件構(gòu)建的基礎(chǔ)知識的鞏固。
3.行業(yè)內(nèi)新的設(shè)計(jì)思想及技術(shù)的認(rèn)知。
4.公司產(chǎn)品的發(fā)展方向及價(jià)值觀也需關(guān)心。
總的說來,為適應(yīng)新的工作,我需要:多學(xué),多問,多研究,多動手,多關(guān)心,多參與。
posted @
2008-12-02 13:45 名羽 閱讀(257) |
評論 (1) |
編輯 收藏
在概要設(shè)計(jì)時(shí),發(fā)現(xiàn)參與討論的人對什么是模塊,模塊的劃分根據(jù)是什么的認(rèn)識有很大的差異。
我也不敢亂下定論,還是看看書本是怎么說的:
---------------------------------------------------
1 .參考一下《軟件架構(gòu)藝術(shù)》一書,
Stephen T. Albin 在里面描述:
Modules are discrete units of software (binary and source).
Binary modules are instantiated at run time and these instantiations are
commonly called components and connectors. A given module may contain the specifications for
several component types and connector types. The component (instances) may be of
a fixed number in some situations. For example, a Web server executable, when
launched, results in a single Web server component instance. The Web server module is the binary code that exists as a set of
program files. The Web server component is a running
instance of the Web server.
I have seen some confusion over the use of the terms module, component, and connector. A module is a discrete unit
of design that is composed of a hidden set of elements and a set of shared
elements. Modules have high internal cohesion and low external coupling. Modules
may represent the physical packaging of the application's binary code, which can
be described further by component types and connector types. Components and
connectors describe the physical instantiation of a system. The term component is often used to mean a component type or module. A
module refers to a unit of software that can be designed,
implemented, and compiled into a deliverable executable system or subsystem; it
is a unit of execution. A component is a runtime entity,
the definition of which exists in a module. A classic modular architecture is a
client-server system. The client and the server are two modules. The server
exports some elements such as a set of publicly visible relational database
tables and views. The client knows about this publicly visible schema. The
client and server are unaware of the internal composition of the other.
那么按紅色部分來說,如果說一個(gè)dll或一個(gè)Exe里由多少個(gè)模塊組成這將是的笑話了。
2 .參考Mary shaw的《軟件體系結(jié)》:
模塊式軟件被劃分成獨(dú)立命名的,并可被獨(dú)立訪問的成分。模塊劃分,粒度可大可小。劃分依據(jù)是對應(yīng)用邏輯結(jié)構(gòu)的理解。這個(gè)定義,似乎有沒有《軟件架構(gòu)藝術(shù)》那么嚴(yán)格。沒有定義具體什么為“被獨(dú)立訪問”的成分。
3. 《Documenting_Software_Architectures》
A module tends to refer first and foremost to a
design-time entity. Parnas's foundational work in module design (1972) used
information hiding as the criterion for allocating responsibility to a module.
Information that was likely to change over the lifetime of a system, such as the
choice of data structures or algorithms, was assigned to a module, which had an
interface through which its facilities were accessed.
其說,模塊是設(shè)計(jì)時(shí)的實(shí)體,特點(diǎn)是信息隱藏和能通過模塊的接口訪問。在介紹模塊視圖時(shí)他說:
A module is a code unit that implements a set of responsibilities.
A module can
be a class, a collection of classes, a layer, or any decomposition of the code
unit. Every module has a collection of properties assigned to it. These
properties are intended to express the important information associated with the
module, as well as constraints on the module. Sample properties are
responsibilities, visibility information, and author. Modules have relations to
one another. Example relations are
is part of or
inherits from.
---------------------------------------------------
不同的作者有不同的看法,但綜合一下,我認(rèn)為模塊因該是一個(gè)獨(dú)立設(shè)計(jì)的單元,并為其他模塊提供訪問接口。也就是說,他是一個(gè)架構(gòu)中的設(shè)計(jì)元素,但不限制他的存在模式,也就是他是提供了可訪問接口而且實(shí)現(xiàn)某一功能的一個(gè)實(shí)體,可以是一個(gè)類或一組類或可執(zhí)行程序等。
posted @
2008-12-02 11:21 名羽 閱讀(329) |
評論 (0) |
編輯 收藏

2008年2月4日
今天是年二十八,一年又要過去了。明天就可以放假休息了。下班前抽空做下年度總結(jié)。今年我主要集中精力在h323上,更確切的說是在OPenh323上。雖說我不算聰明,但這一年的研究還是有點(diǎn)收獲的,主要在以下方面:
1 對現(xiàn)有opneh323不支持的h.264的加入。
雖然不是很按標(biāo)準(zhǔn),用的是常規(guī)視頻能力來加入的,但也算是在視頻的清晰度上有所提高。
2 根據(jù)需要自己建立多條對應(yīng)的h323邏輯通道來傳送自己的數(shù)據(jù)。邏輯通道可以是rtp也可以是TCP。
3 用h323協(xié)商邏輯通道的方式來建立自定義的RTP通道。現(xiàn)在這種方式用在GIPS的RTP上效果還真不錯!
posted @
2008-02-04 15:29 名羽 閱讀(397) |
評論 (0) |
編輯 收藏

2007年10月22日
H323和SIP果然難于共存。Openh323原有的開發(fā)者也將分為兩大塊:
OPAL VOIP: 保留Opal現(xiàn)有H323功能,但重點(diǎn)明顯是要向兼容SIP方向發(fā)展;其網(wǎng)站介紹為:
OPAL implements the commonly
used protocols used to send voice, video and fax data over IP networks.
Originally part of the OpenH323 project, OpalVoip has grown to include SIP and
IAX2.
h323plus:在原有OpenH323基礎(chǔ)上繼續(xù)完善ITU的H323系列的協(xié)議,其介紹為:
The H.323 Plus project intends to do much more than simply provide a new
home for open source H.323 developers. Developers have told us they intend to
work to provide significant new enhancements to the very successful H.323
systems deployed worldwide. For example, NAT/FW
traversal, instant messaging, presence, and many other enhancements are
already in progress or being planned. Further, the open source community has
expressed interest to us to enable more collaborative features to H.323,
including such things as application sharing, whiteboarding, and other
capabilities.(可惜,這些功能OPAL將不能用到了)
至于底層的pwlib(即ptlib)估計(jì)暫時(shí)還會保持一致。
分家后期郵件列表也將分開:
https://lists.sourceforge.net/lists/listinfo/opalvoip-devel
http://lists.packetizer.com/mailman/listinfo/h323plus
網(wǎng)站地址分別:
http://www.h323plus.org/
http://www.opalvoip.org/
對于我們可能會更關(guān)心OpenH323的主要開發(fā)者 Simon 的以下言論:
The following projects are currently
planned to be supported within H323plus.
OpenMCU (including remote conference
controls) OpenAM (upgraded to support
VoiceMail support to GnuGk) MyPhone OhPhone
The Library is almost drop-in
replacable with the existing OpenH323 and contains numerous enhancements
including video plugins (compatible with
Opal) and large amount of new work
not currently supported in Opal.
Some of the new work now available in
h323plus H.230 Conference Controls (incl
tunneling GCC (T.124))
H.239
Application Sharing
H.249
Extended user inputs
H.341
SNMP support
H.350
LDAP WhitePages
H.460
Numerous custom Extensibility features
Text Messaging (working doc ITU),
Follow Me,
PDI (Personal Data Interchange)
H.460.9 RealTime QoS Measurements
Video Plugins (fully compatible with
Opal)
H.235 Plugins (for external Biometric
and smartcard authenticators) QoS Capability negotiation Conference Controls
capability advertisement.
New work planned/proposed
H.460.presence
H.460.18/19 Nat Traversal
Video on Demand project (using
H.239/H.249)
We can also provide full consulting
service support for existing openH323 based projects as well as provide
assistance in migration of these projects to h323plus.
posted @
2007-10-22 09:58 名羽 閱讀(2934) |
評論 (4) |
編輯 收藏

2007年9月29日
研究h323 端點(diǎn)間通過多通道發(fā)送數(shù)據(jù),例如MCU可以向EP用多通道來發(fā)送音視頻。這段時(shí)間我從音頻上作了測試,可以把多路音頻通過多個(gè)通道發(fā)送給EP讓EP直接在聲卡上混音,效果不錯。但(MCU-〉EP)音頻使用多通道這只是一種在網(wǎng)絡(luò)帶寬非常好的情況下的方案,因?yàn)槿绻玫氖荊.711(單路64kbit/s)就不可能在帶寬有限的公網(wǎng)上使用了。
posted @
2007-09-29 08:57 名羽 閱讀(649) |
評論 (0) |
編輯 收藏

2007年5月11日
上頭頭腦發(fā)熱.急于讓我們在原來的視頻會議基礎(chǔ)上完成數(shù)據(jù)會議T120的大部分功能.我們被避著以很多非標(biāo)準(zhǔn)的自定協(xié)議代替T120標(biāo)準(zhǔn)中規(guī)定的東西.而且新的架構(gòu)的改動都沒有詳細(xì)分析就開始著手寫代碼了.也就是說我們開始生產(chǎn)垃圾!
鄙視領(lǐng)導(dǎo)者的短淺眼光!
posted @
2007-05-11 10:35 名羽 閱讀(532) |
評論 (2) |
編輯 收藏

2007年3月30日
目前對Openh323的源代碼已有較多的了解,開始對部分協(xié)議進(jìn)行擴(kuò)展例如H245會議管理部分,4CIF的加入.另外現(xiàn)有的協(xié)議棧代碼中沒有實(shí)現(xiàn)T120通道的數(shù)字會議,目前正對該部分進(jìn)行補(bǔ)充.
posted @
2007-03-30 15:02 名羽 閱讀(699) |
評論 (3) |
編輯 收藏