
2009年2月25日
在分析ACE的原碼時發現有一種平時比較少見的調用方式,記得以前有人用C++描述Command時也用了這種方式,不過他們的代碼都包裝為模板,不方便理解.這里,我不用模板簡單的展示其特點:
#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中是先做一些共同的復雜的事,然后調用不同的func部分:
return (this->*func)(a,b);
}
private:
int cc;
};
int main( void )
{
CA a;
a.Test1();
a.test2(&CA::func2,11,3);
return 0;
}
很酷!調用者可以把類的函數作為參數傳遞.
好再開下面,利用繼承的關系,我們還可以做到同樣效果:
#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;
}
上面的例子如果應用到Command模式中,func1 和func2就可以分別是Execute 跟 UnDo的接口了.至于如何實現,就是派生類的問題了.
(上述代碼均在MinGW中測試通過)
posted @
2009-02-25 17:32 名羽 閱讀(1685) |
評論 (3) |
編輯 收藏

2008年12月2日
前兩個月,公司對我們部門動大手術了。把軟件研發部分成了3大塊,分別是:系統工程與架構部,開發部,測試部。由于以前在團隊里基本所有架構方面的事都有我參與,所以,這次上頭有意問我有沒做架構方面工作的想法。我理想當然答應這份差事。于是,被提到系統架構師的崗位上。這段時間,經過公司培訓,才發現做系統架構師其實真不簡單,負的責任比我原來想的大多了。另外,自己技術方面的素養也必須盡快提高,覺得自己應在以下方面多下功夫:
1.領域內的知識面的擴展。
2.軟件構建的基礎知識的鞏固。
3.行業內新的設計思想及技術的認知。
4.公司產品的發展方向及價值觀也需關心。
總的說來,為適應新的工作,我需要:多學,多問,多研究,多動手,多關心,多參與。
posted @
2008-12-02 13:45 名羽 閱讀(252) |
評論 (1) |
編輯 收藏
在概要設計時,發現參與討論的人對什么是模塊,模塊的劃分根據是什么的認識有很大的差異。
我也不敢亂下定論,還是看看書本是怎么說的:
---------------------------------------------------
1 .參考一下《軟件架構藝術》一書,
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.
那么按紅色部分來說,如果說一個dll或一個Exe里由多少個模塊組成這將是的笑話了。
2 .參考Mary shaw的《軟件體系結》:
模塊式軟件被劃分成獨立命名的,并可被獨立訪問的成分。模塊劃分,粒度可大可小。劃分依據是對應用邏輯結構的理解。這個定義,似乎有沒有《軟件架構藝術》那么嚴格。沒有定義具體什么為“被獨立訪問”的成分。
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.
其說,模塊是設計時的實體,特點是信息隱藏和能通過模塊的接口訪問。在介紹模塊視圖時他說:
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.
---------------------------------------------------
不同的作者有不同的看法,但綜合一下,我認為模塊因該是一個獨立設計的單元,并為其他模塊提供訪問接口。也就是說,他是一個架構中的設計元素,但不限制他的存在模式,也就是他是提供了可訪問接口而且實現某一功能的一個實體,可以是一個類或一組類或可執行程序等。
posted @
2008-12-02 11:21 名羽 閱讀(321) |
評論 (0) |
編輯 收藏

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

2007年10月22日
H323和SIP果然難于共存。Openh323原有的開發者也將分為兩大塊:
OPAL VOIP: 保留Opal現有H323功能,但重點明顯是要向兼容SIP方向發展;其網站介紹為:
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基礎上繼續完善ITU的H323系列的協議,其介紹為:
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)估計暫時還會保持一致。
分家后期郵件列表也將分開:
https://lists.sourceforge.net/lists/listinfo/opalvoip-devel
http://lists.packetizer.com/mailman/listinfo/h323plus
網站地址分別:
http://www.h323plus.org/
http://www.opalvoip.org/
對于我們可能會更關心OpenH323的主要開發者 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 名羽 閱讀(2914) |
評論 (4) |
編輯 收藏

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

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

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