+++ /dev/null
-<html>\r
-<head>\r
-<title>The Code Project Open License (COPL)</title>\r
-<Style>\r
-BODY, P, TD { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt }\r
-H1,H2,H3,H4,H5 { color: #ff9900; font-weight: bold; }\r
-H1 { font-size: 14pt;color:black }\r
-H2 { font-size: 13pt; }\r
-H3 { font-size: 12pt; }\r
-H4 { font-size: 10pt; color: black; }\r
-PRE { BACKGROUND-COLOR: #FBEDBB; FONT-FAMILY: "Courier New", Courier, mono; WHITE-SPACE: pre; }\r
-CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }\r
-.SpacedList li { padding: 5px 0px 5px 0px;}\r
-</style>\r
-</head>\r
-<body bgcolor="#FFFFFF" color=#000000>\r
-\r
-<h1>The Code Project Open License (CPOL) 1.02</h1>\r
-<br />\r
-\r
-<center>\r
-<div style="text-align: left; border: 2px solid #000000; width: 660; background-color: #FFFFD9; padding: 20px;">\r
-\r
-<h2>Preamble</h2>\r
-<p>\r
- This License governs Your use of the Work. This License is intended to allow developers\r
- to use the Source Code and Executable Files provided as part of the Work in any\r
- application in any form.\r
-</p>\r
-<p>\r
- The main points subject to the terms of the License are:</p>\r
-<ul>\r
- <li>Source Code and Executable Files can be used in commercial applications;</li>\r
- <li>Source Code and Executable Files can be redistributed; and</li>\r
- <li>Source Code can be modified to create derivative works.</li>\r
- <li>No claim of suitability, guarantee, or any warranty whatsoever is provided. The software is\r
- provided "as-is".</li>\r
- <li>The Article accompanying the Work may not be distributed or republished without the \r
- Author's consent</li>\r
-</ul>\r
-\r
-<p>\r
- This License is entered between You, the individual or other entity reading or otherwise\r
- making use of the Work licensed pursuant to this License and the individual or other\r
- entity which offers the Work under the terms of this License ("Author").</p>\r
-\r
- <h2>License</h2>\r
- <p>\r
- THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CODE PROJECT OPEN\r
- LICENSE ("LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE\r
- LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT\r
- LAW IS PROHIBITED.</p>\r
- <p>\r
- BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HEREIN, YOU ACCEPT AND AGREE TO BE\r
- BOUND BY THE TERMS OF THIS LICENSE. THE AUTHOR GRANTS YOU THE RIGHTS CONTAINED HEREIN\r
- IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. IF YOU DO NOT\r
- AGREE TO ACCEPT AND BE BOUND BY THE TERMS OF THIS LICENSE, YOU CANNOT MAKE ANY\r
- USE OF THE WORK.</p>\r
- \r
-<ol class="SpacedList">\r
- <li><strong>Definitions.</strong>\r
- \r
- <ol class="SpacedList" style="list-style-type: lower-alpha;">\r
- <li><strong>"Articles"</strong> means, collectively, all articles written by Author\r
- which describes how the Source Code and Executable Files for the Work may be used\r
- by a user.</li>\r
- <li><b>"Author"</b> means the individual or entity that offers the Work under the terms\r
- of this License.<strong></strong></li>\r
- <li><strong>"Derivative Work"</strong> means a work based upon the Work or upon the\r
- Work and other pre-existing works.</li>\r
- <li><b>"Executable Files"</b> refer to the executables, binary files, configuration\r
- and any required data files included in the Work.</li>\r
- <li>"<b>Publisher</b>" means the provider of the website, magazine, CD-ROM, DVD or other\r
- medium from or by which the Work is obtained by You.</li>\r
- <li><b>"Source Code"</b> refers to the collection of source code and configuration files\r
- used to create the Executable Files.</li>\r
- <li><b>"Standard Version"</b> refers to such a Work if it has not been modified, or\r
- has been modified in accordance with the consent of the Author, such consent being\r
- in the full discretion of the Author. </li>\r
- <li><b>"Work"</b> refers to the collection of files distributed by the Publisher, including\r
- the Source Code, Executable Files, binaries, data files, documentation, whitepapers\r
- and the Articles. </li>\r
- <li><b>"You"</b> is you, an individual or entity wishing to use the Work and exercise\r
- your rights under this License.\r
- </li>\r
- </ol>\r
- </li>\r
- \r
- <li><strong>Fair Use/Fair Use Rights.</strong> Nothing in this License is intended to\r
- reduce, limit, or restrict any rights arising from fair use, fair dealing, first\r
- sale or other limitations on the exclusive rights of the copyright owner under copyright\r
- law or other applicable laws.\r
- </li>\r
- \r
- <li><strong>License Grant.</strong> Subject to the terms and conditions of this License,\r
- the Author hereby grants You a worldwide, royalty-free, non-exclusive, perpetual\r
- (for the duration of the applicable copyright) license to exercise the rights in\r
- the Work as stated below:\r
- \r
- <ol class="SpacedList" style="list-style-type: lower-alpha;">\r
- <li>You may use the standard version of the Source Code or Executable Files in Your\r
- own applications. </li>\r
- <li>You may apply bug fixes, portability fixes and other modifications obtained from\r
- the Public Domain or from the Author. A Work modified in such a way shall still\r
- be considered the standard version and will be subject to this License.</li>\r
- <li>You may otherwise modify Your copy of this Work (excluding the Articles) in any\r
- way to create a Derivative Work, provided that You insert a prominent notice in\r
- each changed file stating how, when and where You changed that file.</li>\r
- <li>You may distribute the standard version of the Executable Files and Source Code\r
- or Derivative Work in aggregate with other (possibly commercial) programs as part\r
- of a larger (possibly commercial) software distribution. </li>\r
- <li>The Articles discussing the Work published in any form by the author may not be\r
- distributed or republished without the Author's consent. The author retains\r
- copyright to any such Articles. You may use the Executable Files and Source Code\r
- pursuant to this License but you may not repost or republish or otherwise distribute\r
- or make available the Articles, without the prior written consent of the Author.</li>\r
- </ol>\r
- \r
- Any subroutines or modules supplied by You and linked into the Source Code or Executable\r
- Files this Work shall not be considered part of this Work and will not be subject\r
- to the terms of this License.\r
- </li>\r
- \r
- <li><strong>Patent License.</strong> Subject to the terms and conditions of this License, \r
- each Author hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, \r
- irrevocable (except as stated in this section) patent license to make, have made, use, import, \r
- and otherwise transfer the Work.</li>\r
- \r
- <li><strong>Restrictions.</strong> The license granted in Section 3 above is expressly\r
- made subject to and limited by the following restrictions:\r
- \r
- <ol class="SpacedList" style="list-style-type: lower-alpha;">\r
- <li>You agree not to remove any of the original copyright, patent, trademark, and \r
- attribution notices and associated disclaimers that may appear in the Source Code \r
- or Executable Files. </li>\r
- <li>You agree not to advertise or in any way imply that this Work is a product of Your\r
- own. </li>\r
- <li>The name of the Author may not be used to endorse or promote products derived from\r
- the Work without the prior written consent of the Author.</li>\r
- <li>You agree not to sell, lease, or rent any part of the Work. This does not restrict\r
- you from including the Work or any part of the Work inside a larger software \r
- distribution that itself is being sold. The Work by itself, though, cannot be sold, \r
- leased or rented.</li>\r
- <li>You may distribute the Executable Files and Source Code only under the terms of\r
- this License, and You must include a copy of, or the Uniform Resource Identifier\r
- for, this License with every copy of the Executable Files or Source Code You distribute\r
- and ensure that anyone receiving such Executable Files and Source Code agrees that\r
- the terms of this License apply to such Executable Files and/or Source Code. You\r
- may not offer or impose any terms on the Work that alter or restrict the terms of\r
- this License or the recipients' exercise of the rights granted hereunder. You\r
- may not sublicense the Work. You must keep intact all notices that refer to this\r
- License and to the disclaimer of warranties. You may not distribute the Executable\r
- Files or Source Code with any technological measures that control access or use\r
- of the Work in a manner inconsistent with the terms of this License. </li>\r
- <li>You agree not to use the Work for illegal, immoral or improper purposes, or on pages\r
- containing illegal, immoral or improper material. The Work is subject to applicable\r
- export laws. You agree to comply with all such laws and regulations that may apply\r
- to the Work after Your receipt of the Work.\r
- </li>\r
- </ol>\r
- </li>\r
- \r
- <li><strong>Representations, Warranties and Disclaimer.</strong> THIS WORK IS PROVIDED\r
- "AS IS", "WHERE IS" AND "AS AVAILABLE", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES\r
- OR CONDITIONS OR GUARANTEES. YOU, THE USER, ASSUME ALL RISK IN ITS USE, INCLUDING\r
- COPYRIGHT INFRINGEMENT, PATENT INFRINGEMENT, SUITABILITY, ETC. AUTHOR EXPRESSLY\r
- DISCLAIMS ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES OR CONDITIONS, INCLUDING\r
- WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF MERCHANTABILITY, MERCHANTABLE QUALITY\r
- OR FITNESS FOR A PARTICULAR PURPOSE, OR ANY WARRANTY OF TITLE OR NON-INFRINGEMENT,\r
- OR THAT THE WORK (OR ANY PORTION THEREOF) IS CORRECT, USEFUL, BUG-FREE OR FREE OF\r
- VIRUSES. YOU MUST PASS THIS DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE WORK OR DERIVATIVE\r
- WORKS.\r
- </li>\r
- \r
- <li><b>Indemnity. </b>You agree to defend, indemnify and hold harmless the Author and\r
- the Publisher from and against any claims, suits, losses, damages, liabilities,\r
- costs, and expenses (including reasonable legal or attorneys\92 fees) resulting from\r
- or relating to any use of the Work by You.\r
- </li>\r
- \r
- <li><strong>Limitation on Liability.</strong> EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE\r
- LAW, IN NO EVENT WILL THE AUTHOR OR THE PUBLISHER BE LIABLE TO YOU ON ANY LEGAL\r
- THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES\r
- ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK OR OTHERWISE, EVEN IF THE AUTHOR\r
- OR THE PUBLISHER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
- </li>\r
- \r
- <li><strong>Termination.</strong>\r
- \r
- <ol style="list-style-type: lower-alpha;">\r
- <li>This License and the rights granted hereunder will terminate automatically upon\r
- any breach by You of any term of this License. Individuals or entities who have\r
- received Derivative Works from You under this License, however, will not have their\r
- licenses terminated provided such individuals or entities remain in full compliance\r
- with those licenses. Sections 1, 2, 6, 7, 8, 9, 10 and 11 will survive any termination\r
- of this License. </li>\r
- \r
- <li>If You bring a copyright, trademark, patent or any other infringement claim against \r
- any contributor over infringements You claim are made by the Work, your License \r
- from such contributor to the Work ends automatically.</li>\r
- \r
- <li>Subject to the above terms and conditions, this License is perpetual (for the duration\r
- of the applicable copyright in the Work). Notwithstanding the above, the Author\r
- reserves the right to release the Work under different license terms or to stop\r
- distributing the Work at any time; provided, however that any such election will\r
- not serve to withdraw this License (or any other license that has been, or is required\r
- to be, granted under the terms of this License), and this License will continue\r
- in full force and effect unless terminated as stated above.\r
- </li>\r
- </ol>\r
- </li>\r
- \r
- <li><strong>Publisher</strong>. The parties hereby confirm that the Publisher shall\r
- not, under any circumstances, be responsible for and shall not have any liability\r
- in respect of the subject matter of this License. The Publisher makes no warranty\r
- whatsoever in connection with the Work and shall not be liable to You or any party\r
- on any legal theory for any damages whatsoever, including without limitation any\r
- general, special, incidental or consequential damages arising in connection to this\r
- license. The Publisher reserves the right to cease making the Work available to\r
- You at any time without notice</li>\r
- \r
- <li><strong>Miscellaneous</strong>\r
- \r
- <ol class="SpacedList" style="list-style-type: lower-alpha;">\r
- <li>This License shall be governed by the laws of the location of the head office of\r
- the Author or if the Author is an individual, the laws of location of the principal\r
- place of residence of the Author.</li>\r
- <li>If any provision of this License is invalid or unenforceable under applicable law,\r
- it shall not affect the validity or enforceability of the remainder of the terms\r
- of this License, and without further action by the parties to this License, such\r
- provision shall be reformed to the minimum extent necessary to make such provision\r
- valid and enforceable. </li>\r
- <li>No term or provision of this License shall be deemed waived and no breach consented\r
- to unless such waiver or consent shall be in writing and signed by the party to\r
- be charged with such waiver or consent. </li>\r
- <li>This License constitutes the entire agreement between the parties with respect to\r
- the Work licensed herein. There are no understandings, agreements or representations\r
- with respect to the Work not specified herein. The Author shall not be bound by\r
- any additional provisions that may appear in any communication from You. This License\r
- may not be modified without the mutual written agreement of the Author and You.\r
- </li>\r
- </ol>\r
- \r
- </li>\r
-</ol>\r
-\r
-</div>\r
-</center>\r
-\r
-</body>\r
-</html>\r
+++ /dev/null
-#include <stddef.h>\r
-#include <stdio.h>\r
-#include "FastDelegate.h"\r
-// Demonstrate the syntax for FastDelegates.\r
-// -Don Clugston, May 2004.\r
-// It's a really boring example, but it shows the most important cases.\r
-\r
-// Declare some functions of varying complexity...\r
-void SimpleStaticFunction(int num, char *str) {\r
- printf("In SimpleStaticFunction. Num=%d, str = %s\n", num, str);\r
-}\r
-\r
-void SimpleVoidFunction() {\r
- printf("In SimpleVoidFunction with no parameters.\n");\r
-}\r
-\r
-class CBaseClass {\r
-protected:\r
- char *m_name;\r
-public:\r
- CBaseClass(char *name) : m_name(name) {};\r
- void SimpleMemberFunction(int num, char *str) {\r
- printf("In SimpleMemberFunction in %s. Num=%d, str = %s\n", m_name, num, str); }\r
- int SimpleMemberFunctionReturnsInt(int num, char *str) {\r
- printf("In SimpleMemberFunction in %s. Num=%d, str = %s\n", m_name, num, str); return -1; }\r
- void ConstMemberFunction(int num, char *str) const {\r
- printf("In ConstMemberFunction in %s. Num=%d, str = %s\n", m_name, num, str); }\r
- virtual void SimpleVirtualFunction(int num, char *str) {\r
- printf("In SimpleVirtualFunction in %s. Num=%d, str = %s\n", m_name, num, str); }\r
- static void StaticMemberFunction(int num, char *str) {\r
- printf("In StaticMemberFunction. Num=%d, str =%s\n", num, str); }\r
-};\r
-\r
-class COtherClass {\r
- double rubbish; // to ensure this class has non-zero size.\r
-public:\r
- virtual void UnusedVirtualFunction(void) { }\r
- virtual void TrickyVirtualFunction(int num, char *str)=0;\r
-};\r
-\r
-class VeryBigClass {\r
- int letsMakeThingsComplicated[400];\r
-};\r
-\r
-// This declaration ensures that we get a convoluted class heirarchy.\r
-class CDerivedClass : public VeryBigClass, virtual public COtherClass, virtual public CBaseClass\r
-{\r
- double m_somemember[8];\r
-public:\r
- CDerivedClass() : CBaseClass("Base of Derived") { m_somemember[0]=1.2345; }\r
- void SimpleDerivedFunction(int num, char *str) { printf("In SimpleDerived. num=%d\n", num); }\r
- virtual void AnotherUnusedVirtualFunction(int num, char *str) {}\r
- virtual void TrickyVirtualFunction(int num, char *str) {\r
- printf("In Derived TrickyMemberFunction. Num=%d, str = %s\n", num, str);\r
- }\r
-};\r
-\r
-using namespace fastdelegate;\r
-\r
-int main(void)\r
-{\r
- // Delegates with up to 8 parameters are supported.\r
- // Here's the case for a void function.\r
- // We declare a delegate and attach it to SimpleVoidFunction()\r
- printf("-- FastDelegate demo --\nA no-parameter delegate is declared using FastDelegate0\n\n");\r
-\r
- FastDelegate0<> noparameterdelegate(&SimpleVoidFunction);\r
-\r
- noparameterdelegate(); // invoke the delegate - this calls SimpleVoidFunction()\r
-\r
- printf("\n-- Examples using two-parameter delegates (int, char *) --\n\n");\r
-\r
- // By default, the return value is void.\r
- typedef FastDelegate2<int, char *> MyDelegate;\r
-\r
- // If you want to have a non-void return value, put it at the end.\r
- typedef FastDelegate2<int, char *, int> IntMyDelegate;\r
-\r
-\r
- MyDelegate funclist[12]; // delegates are initialized to empty\r
- CBaseClass a("Base A");\r
- CBaseClass b("Base B");\r
- CDerivedClass d;\r
- CDerivedClass c;\r
-\r
- IntMyDelegate newdeleg;\r
- newdeleg = MakeDelegate(&a, &CBaseClass::SimpleMemberFunctionReturnsInt);\r
- \r
- // Binding a simple member function\r
- funclist[0].bind(&a, &CBaseClass::SimpleMemberFunction);\r
- \r
- // You can also bind static (free) functions\r
- funclist[1].bind(&SimpleStaticFunction);\r
- // and static member functions\r
- funclist[2].bind(&CBaseClass::StaticMemberFunction);\r
- // and const member functions (these only need a const class pointer). \r
- funclist[11].bind( (const CBaseClass *)&a, &CBaseClass::ConstMemberFunction);\r
- funclist[3].bind( &a, &CBaseClass::ConstMemberFunction);\r
- // and virtual member functions\r
- funclist[4].bind(&b, &CBaseClass::SimpleVirtualFunction);\r
-\r
- // You can also use the = operator. For static functions, a fastdelegate\r
- // looks identical to a simple function pointer.\r
- funclist[5] = &CBaseClass::StaticMemberFunction;\r
-\r
- // The weird rule about the class of derived member function pointers is avoided.\r
- // For MSVC, you can use &CDerivedClass::SimpleVirtualFunction here, but DMC will complain.\r
- // Note that as well as .bind(), you can also use the MakeDelegate()\r
- // global function.\r
- funclist[6] = MakeDelegate(&d, &CBaseClass::SimpleVirtualFunction);\r
-\r
- // The worst case is an abstract virtual function of a virtually-derived class\r
- // with at least one non-virtual base class. This is a VERY obscure situation,\r
- // which you're unlikely to encounter in the real world.\r
- // FastDelegate versions prior to 1.3 had problems with this case on VC6.\r
- // Now, it works without problems on all compilers.\r
- funclist[7].bind(&c, &CDerivedClass::TrickyVirtualFunction);\r
- // BUT... in such cases you should be using the base class as an \r
- // interface, anyway.\r
- funclist[8].bind(&c, &COtherClass::TrickyVirtualFunction);\r
- // Calling a function that was first declared in the derived class is straightforward\r
- funclist[9] = MakeDelegate(&c, &CDerivedClass::SimpleDerivedFunction);\r
-\r
- // You can also bind directly using the constructor\r
- MyDelegate dg(&b, &CBaseClass::SimpleVirtualFunction);\r
-\r
- char *msg = "Looking for equal delegate";\r
- for (int i=0; i<12; i++) {\r
- printf("%d :", i);\r
- // The == and != operators are provided\r
- // Note that they work even for inline functions.\r
- if (funclist[i]==dg) { msg = "Found equal delegate"; };\r
- // operator ! can be used to test for an empty delegate\r
- // You can also use the .empty() member function.\r
- if (!funclist[i]) {\r
- printf("Delegate is empty\n");\r
- } else {\r
- // Invocation generates optimal assembly code.\r
- funclist[i](i, msg);\r
- };\r
- }\r
- return 0;\r
-}\r
-\r