⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notifier__ext_8h-source.html

📁 pwlib开发文档
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>notifier_ext.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center><hr><h1>notifier_ext.h</h1><a href="notifier__ext_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span>00002 <span class="comment"> * notifier_ext.h</span>00003 <span class="comment"> *</span>00004 <span class="comment"> * Smart Notifiers and Notifier Lists</span>00005 <span class="comment"> *</span>00006 <span class="comment"> * Portable Windows Library</span>00007 <span class="comment"> *</span>00008 <span class="comment"> * Copyright (c) 2004 Reitek S.p.A.</span>00009 <span class="comment"> *</span>00010 <span class="comment"> * The contents of this file are subject to the Mozilla Public License</span>00011 <span class="comment"> * Version 1.0 (the "License"); you may not use this file except in</span>00012 <span class="comment"> * compliance with the License. You may obtain a copy of the License at</span>00013 <span class="comment"> * http://www.mozilla.org/MPL/</span>00014 <span class="comment"> *</span>00015 <span class="comment"> * Software distributed under the License is distributed on an "AS IS"</span>00016 <span class="comment"> * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See</span>00017 <span class="comment"> * the License for the specific language governing rights and limitations</span>00018 <span class="comment"> * under the License.</span>00019 <span class="comment"> *</span>00020 <span class="comment"> * The Original Code is Portable Windows Library.</span>00021 <span class="comment"> *</span>00022 <span class="comment"> * The Initial Developer of the Original Code is Post Increment</span>00023 <span class="comment"> *</span>00024 <span class="comment"> * Contributor(s): ______________________________________.</span>00025 <span class="comment"> *</span>00026 <span class="comment"> * $Log: notifier_ext.h,v $</span>00027 <span class="comment"> * Revision 1.4  2004/05/17 11:02:39  csoutheren</span>00028 <span class="comment"> * Added extra documentation</span>00029 <span class="comment"> *</span>00030 <span class="comment"> * Revision 1.3  2004/05/09 07:23:48  rjongbloed</span>00031 <span class="comment"> * More work on XMPP, thanks Federico Pinna and Reitek S.p.A.</span>00032 <span class="comment"> *</span>00033 <span class="comment"> * Revision 1.2  2004/04/26 01:34:58  rjongbloed</span>00034 <span class="comment"> * Change nofier list to be able to used in containers, thanks Federico Pinna, Reitek S.p.A.</span>00035 <span class="comment"> *</span>00036 <span class="comment"> * Revision 1.1  2004/04/22 12:31:00  rjongbloed</span>00037 <span class="comment"> * Added PNotifier extensions and XMPP (Jabber) support,</span>00038 <span class="comment"> *   thanks to Federico Pinna and Reitek S.p.A.</span>00039 <span class="comment"> *</span>00040 <span class="comment"> *</span>00041 <span class="comment"> */</span>00042 00043 <span class="preprocessor">#ifndef _PNOTIFIER_EXT</span>00044 <span class="preprocessor"></span><span class="preprocessor">#define _PNOTIFIER_EXT</span>00045 <span class="preprocessor"></span>00046 <span class="preprocessor">#ifdef P_USE_PRAGMA</span>00047 <span class="preprocessor"></span><span class="preprocessor">#pragma interface</span>00048 <span class="preprocessor"></span><span class="preprocessor">#endif</span>00049 <span class="preprocessor"></span><a name="l00058"></a><a class="code" href="classPSmartNotifieeRegistrar.html">00058</a> <span class="keyword">class </span><a class="code" href="classPSmartNotifieeRegistrar.html">PSmartNotifieeRegistrar</a>00059 {00060   <span class="keyword">public</span>:<a name="l00061"></a><a class="code" href="classPSmartNotifieeRegistrar.html#a0">00061</a>     <a class="code" href="classPSmartNotifieeRegistrar.html#a0">PSmartNotifieeRegistrar</a>() : <a class="code" href="classPSmartNotifieeRegistrar.html#n0">m_ID</a>(P_MAX_INDEX) {}<a name="l00062"></a><a class="code" href="classPSmartNotifieeRegistrar.html#a1">00062</a>     <a class="code" href="classPSmartNotifieeRegistrar.html#a1">~PSmartNotifieeRegistrar</a>() { <a class="code" href="classPSmartNotifieeRegistrar.html#d1">UnregisterNotifiee</a>(<a class="code" href="classPSmartNotifieeRegistrar.html#n0">m_ID</a>); }00063 <a name="l00064"></a><a class="code" href="classPSmartNotifieeRegistrar.html#a2">00064</a>     <span class="keywordtype">void</span>        <a class="code" href="classPSmartNotifieeRegistrar.html#a2">Init</a>(<span class="keywordtype">void</span> * obj)        { <span class="keywordflow">if</span> (<a class="code" href="classPSmartNotifieeRegistrar.html#n0">m_ID</a> == P_MAX_INDEX) <a class="code" href="classPSmartNotifieeRegistrar.html#n0">m_ID</a> = <a class="code" href="classPSmartNotifieeRegistrar.html#d0">RegisterNotifiee</a>(obj); }<a name="l00065"></a><a class="code" href="classPSmartNotifieeRegistrar.html#a3">00065</a>     <span class="keywordtype">unsigned</span>    <a class="code" href="classPSmartNotifieeRegistrar.html#a3">GetID</a>()<span class="keyword"> const           </span>{ <span class="keywordflow">return</span> <a class="code" href="classPSmartNotifieeRegistrar.html#n0">m_ID</a>; }00066 00067     <span class="keyword">static</span> <span class="keywordtype">unsigned</span>    <a class="code" href="classPSmartNotifieeRegistrar.html#d0">RegisterNotifiee</a>(<span class="keywordtype">void</span> * obj);00068     <span class="keyword">static</span> BOOL        <a class="code" href="classPSmartNotifieeRegistrar.html#d1">UnregisterNotifiee</a>(<span class="keywordtype">unsigned</span> id);00069     <span class="keyword">static</span> BOOL        <a class="code" href="classPSmartNotifieeRegistrar.html#d1">UnregisterNotifiee</a>(<span class="keywordtype">void</span> * obj);00070     <span class="keyword">static</span> <span class="keywordtype">void</span> *      <a class="code" href="classPSmartNotifieeRegistrar.html#d3">GetNotifiee</a>(<span class="keywordtype">unsigned</span> id);00071 00072   <span class="keyword">protected</span>:<a name="l00073"></a><a class="code" href="classPSmartNotifieeRegistrar.html#n0">00073</a>     <span class="keywordtype">unsigned</span> <a class="code" href="classPSmartNotifieeRegistrar.html#n0">m_ID</a>;00074 };00075 <a name="l00076"></a><a class="code" href="classPSmartNotifierFunction.html">00076</a> <span class="keyword">class </span><a class="code" href="classPSmartNotifierFunction.html">PSmartNotifierFunction</a> : <span class="keyword">public</span> <a class="code" href="classPNotifierFunction.html">PNotifierFunction</a>00077 {00078     <a class="code" href="object_8h.html#a27">PCLASSINFO</a>(<a class="code" href="classPSmartNotifierFunction.html">PSmartNotifierFunction</a>, <a class="code" href="classPNotifierFunction.html">PNotifierFunction</a>);00079 00080   <span class="keyword">protected</span>:<a name="l00081"></a><a class="code" href="classPSmartNotifierFunction.html#n0">00081</a>     <span class="keywordtype">unsigned</span>    <a class="code" href="classPSmartNotifierFunction.html#n0">m_NotifieeID</a>;00082 00083   <span class="keyword">public</span>:<a name="l00084"></a><a class="code" href="classPSmartNotifierFunction.html#a0">00084</a>     <a class="code" href="classPSmartNotifierFunction.html#a0">PSmartNotifierFunction</a>(<span class="keywordtype">unsigned</span> id) : <a class="code" href="classPNotifierFunction.html">PNotifierFunction</a>(&amp;id), <a class="code" href="classPSmartNotifierFunction.html#n0">m_NotifieeID</a>(id) { }<a name="l00085"></a><a class="code" href="classPSmartNotifierFunction.html#a1">00085</a>     <span class="keywordtype">unsigned</span> <a class="code" href="classPSmartNotifierFunction.html#a1">GetNotifieeID</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classPSmartNotifierFunction.html#n0">m_NotifieeID</a>; }<a name="l00086"></a><a class="code" href="classPSmartNotifierFunction.html#a2">00086</a>     <span class="keywordtype">void</span> * <a class="code" href="classPSmartNotifierFunction.html#a2">GetNotifiee</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classPSmartNotifieeRegistrar.html#d3">PSmartNotifieeRegistrar::GetNotifiee</a>(<a class="code" href="classPSmartNotifierFunction.html#n0">m_NotifieeID</a>); }<a name="l00087"></a><a class="code" href="classPSmartNotifierFunction.html#a3">00087</a>     BOOL <a class="code" href="classPSmartNotifierFunction.html#a3">IsValid</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classPSmartNotifierFunction.html#a2">GetNotifiee</a>() != 0; }00088 };00089 <a name="l00090"></a><a class="code" href="notifier__ext_8h.html#a0">00090</a> <span class="preprocessor">#define PDECLARE_SMART_NOTIFIEE \</span>00091 <span class="preprocessor">    PSmartNotifieeRegistrar   m_Registrar; \</span>00092 <span class="preprocessor"></span><a name="l00093"></a><a class="code" href="notifier__ext_8h.html#a1">00093</a> <span class="preprocessor"></span><span class="preprocessor">#define PCREATE_SMART_NOTIFIEE m_Registrar.Init(this)</span>00094 <span class="preprocessor"></span><a name="l00095"></a><a class="code" href="notifier__ext_8h.html#a2">00095</a> <span class="preprocessor">#define PDECLARE_SMART_NOTIFIER(notifier, notifiee, func) \</span>00096 <span class="preprocessor">  class func##_PSmartNotifier : public PSmartNotifierFunction { \</span>00097 <span class="preprocessor">    public: \</span>00098 <span class="preprocessor">      func##_PSmartNotifier(unsigned id) : PSmartNotifierFunction(id) { } \</span>00099 <span class="preprocessor">      virtual void Call(PObject &amp; note, INT extra) const \</span>00100 <span class="preprocessor">      { \</span>00101 <span class="preprocessor">          void * obj = GetNotifiee(); \</span>00102 <span class="preprocessor">          if (obj) \</span>00103 <span class="preprocessor">            ((notifiee*)obj)-&gt;func((notifier &amp;)note, extra); \</span>00104 <span class="preprocessor">          else \</span>00105 <span class="preprocessor">                  PTRACE(2, "Invalid notifiee"); \</span>00106 <span class="preprocessor">      } \</span>00107 <span class="preprocessor">  }; \</span>00108 <span class="preprocessor">  friend class func##_PSmartNotifier; \</span>00109 <span class="preprocessor">  virtual void func(notifier &amp; note, INT extra)</span>00110 <span class="preprocessor"></span><a name="l00111"></a><a class="code" href="notifier__ext_8h.html#a3">00111</a> <span class="preprocessor">#define PCREATE_SMART_NOTIFIER(func) PNotifier(new func##_PSmartNotifier(m_Registrar.GetID()))</span>00112 <span class="preprocessor"></span>00113 <a name="l00114"></a><a class="code" href="classPNotifierList.html">00114</a> <span class="keyword">class </span><a class="code" href="classPNotifierList.html">PNotifierList</a> : <span class="keyword">public</span> <a class="code" href="classPObject.html">PObject</a>00115 {00116   <a class="code" href="object_8h.html#a27">PCLASSINFO</a>(<a class="code" href="classPNotifierList.html">PNotifierList</a>, <a class="code" href="classPObject.html">PObject</a>);00117   <span class="keyword">private</span>:00118     <a class="code" href="lists_8h.html#a0">PLIST</a>(_PNotifierList, <a class="code" href="classPNotifier.html">PNotifier</a>);00119 00120     _PNotifierList      m_TheList;00121 00122     <span class="comment">// Removes smart pointers to deleted objects</span>00123     <span class="keywordtype">void</span>   Cleanup();00124 00125   <span class="keyword">public</span>:<a name="l00126"></a><a class="code" href="classPNotifierList.html#a0">00126</a>     PINDEX <a class="code" href="classPNotifierList.html#a0">GetSize</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_TheList.GetSize(); }00127 <a name="l00128"></a><a class="code" href="classPNotifierList.html#a1">00128</a>     <span class="keywordtype">void</span>        <a class="code" href="classPNotifierList.html#a1">Add</a>(<a class="code" href="classPNotifier.html">PNotifier</a> * handler)        { m_TheList.Append(handler); }<a name="l00129"></a><a class="code" href="classPNotifierList.html#a2">00129</a>     <span class="keywordtype">void</span>        <a class="code" href="classPNotifierList.html#a2">Remove</a>(<a class="code" href="classPNotifier.html">PNotifier</a> * handler)     { m_TheList.Remove(handler); }00130     BOOL        <a class="code" href="classPNotifierList.html#a3">RemoveTarget</a>(<a class="code" href="classPObject.html">PObject</a> * obj);00131     BOOL        <a class="code" href="classPNotifierList.html#a4">Fire</a>(<a class="code" href="classPObject.html">PObject</a>&amp; obj, INT val = 0);00132 00133     <span class="comment">// Moves all the notifiers in "that" to "this"</span>00134     <span class="keywordtype">void</span>  <a class="code" href="classPNotifierList.html#a5">Move</a>(<a class="code" href="classPNotifierList.html">PNotifierList</a>&amp; that);00135 };00136 00137 00138 <span class="preprocessor">#endif  // _PNOTIFIER_EXT</span>00139 <span class="preprocessor"></span>00140 <span class="comment">// End of File ///////////////////////////////////////////////////////////////</span>00141 00142 00143 </pre></div><hr><address style="align: right;"><small>Generated on Wed Sep 29 22:44:11 2004 for PWLib by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -