AppenderFactory
返回的指針是
SharedAppenderPtr
class
?
NullAppenderFactory
:
public
?
AppenderFactory
{
???
??????????
public
:
???????
SharedAppenderPtr
?
createObject
(
const
?
Properties
&
props
)
?????
??{
???????????
return
?
SharedAppenderPtr
(
new
?
log4cplus
::
NullAppender
(
props
));
??????? }
???????
tstring
?
getTypeName
() {
???????????
return
?
LOG4CPLUS_TEXT
(
"log4cplus::NullAppender"
);
??????? }
};
LayoutFactory
中返回的是
std::auto_ptr
指針
?
class
?
TTCCLayoutFactory
:
public
?
LayoutFactory
{
???
public
:
???????
std
::
auto_ptr
<
Layout
>
createObject
(
const
?
Properties
&
props
)
??????? {
???????????
std
::
auto_ptr
<
Layout
>
tmp
(
new
?
log4cplus
::
TTCCLayout
(
props
));
???????????
return
?
tmp
;
??????? }
???????
tstring
?
getTypeName
() {
???????????
return
?
LOG4CPLUS_TEXT
(
"log4cplus::TTCCLayout"
);
??????? }
??? };
這兩者之間有什么樣的區(qū)別聯(lián)系
?
通過
auto_ptr
可以知道對象實例在返回之后
,
需要將對象的生命周期交給外部的使用者
,
由使用者負責堆對象實例的析構(gòu)工作
.
分析成果
配置文件的定義實現(xiàn)
,
包含的基本類
,
以及這些類的實現(xiàn)
.
對于實現(xiàn)的動態(tài)配置的考慮
:
1.??????
通過生成
RegistryFactory
完成所有需要加載的對象的工廠方法的初始化
,
2.??????
分析配置文件來實現(xiàn)不同方法的調(diào)用的實現(xiàn)
3.??????
加載完成
Configure
文件之后
,
既實現(xiàn)的基本的數(shù)據(jù)的獲取和采集功能
.