├── testsuite ├── include │ ├── tut.h │ ├── tut_restartable.h │ ├── tut_reporter.h │ └── tut │ │ ├── tut_reporter.hpp │ │ ├── tut_result.hpp │ │ ├── tut_exception.hpp │ │ └── tut_assert.hpp ├── make_all.sh ├── make_clean_all.sh ├── create.bat ├── src │ ├── SimpleCommandTestVO.hpp │ ├── MacroCommandTestVO.hpp │ ├── PureMVCTestCommand.hpp │ ├── PureMVCTestCommand2.hpp │ ├── PureMVCTestCommand3.hpp │ ├── PureMVCTestCommand4.hpp │ ├── FacadeTestVO.hpp │ ├── ControllerTestVO.hpp │ ├── FacadeTestCommand.hpp │ ├── ViewTest.hpp │ ├── ModelTestProxy.hpp │ ├── MacroCommandTestSub1Command.hpp │ ├── IteratorTest.hpp │ ├── MacroCommandTestSub2Command.hpp │ ├── MacroCommandTestCommand.hpp │ ├── SimpleCommandTestSecondCommand.hpp │ ├── SimpleCommandTestCommand.hpp │ ├── ControllerTestCommand.hpp │ ├── ViewTestInheritance.hpp │ ├── ModelTestInheritance.hpp │ ├── ViewTestMediator4.hpp │ ├── ViewTestMediator.hpp │ ├── ControllerTestCommand2.hpp │ ├── ControllerTestInheritance.hpp │ ├── MediatorTest.cpp │ ├── FacadeTestInheritance.hpp │ ├── ViewTestNote.hpp │ ├── ViewTestMediator3.hpp │ ├── ViewTestMediator5.hpp │ ├── ViewTestMediator2.hpp │ ├── SimpleCommandTestFirstCommand.hpp │ ├── ViewTestMediator6.hpp │ ├── ProxyTest.cpp │ ├── SimpleCommandTest.cpp │ ├── ObserverTest.cpp │ ├── NotificationTest.cpp │ ├── MacroCommandTest.cpp │ └── DelegateCommandTest.cpp ├── make_all.bat └── make_clean_all.bat ├── make_all.sh ├── make_clean_all.sh ├── create.sh ├── create-config.sh ├── .project ├── puremvc.pc.in ├── puremvc-static.pc.in ├── create.bat ├── admin ├── python-devel.m4 ├── ltversion.m4 ├── py-compile └── ltsugar.m4 ├── aclocal.m4 ├── VERSION ├── make_all.bat ├── make_clean_all.bat ├── src └── PureMVC │ ├── Patterns │ ├── Command │ │ ├── SimpleCommand.cpp │ │ └── MacroCommand.cpp │ ├── Proxy │ │ └── Proxy.cpp │ ├── Observer │ │ ├── Notifier.cpp │ │ └── Notification.cpp │ └── Mediator │ │ └── Mediator.cpp │ ├── Resource │ └── PureMVC.rc │ └── Core │ └── Model.cpp ├── configure.in ├── include └── PureMVC │ ├── Interfaces │ ├── ICommand.hpp │ ├── IAggregate.hpp │ ├── IIterator.hpp │ ├── IProxy.hpp │ ├── INotifier.hpp │ ├── IObserver.hpp │ ├── IModel.hpp │ ├── INotification.hpp │ └── IMediator.hpp │ └── Patterns │ ├── Command │ ├── SimpleCommand.hpp │ └── DelegateCommand.hpp │ ├── Proxy │ └── Proxy.hpp │ ├── Mediator │ └── Mediator.hpp │ └── Observer │ └── Observer.hpp ├── LICENSE ├── autoconf ├── merge-scripts.py ├── bk-make-pch ├── shared-ld-sh ├── bk-deps └── bakefilize ├── README.md ├── PureMVC.vs2008.sln ├── PureMVC.vs2010.sln ├── bakefile-intel-format-support ├── output │ └── intelw.empy └── rules │ ├── intelw.bkl │ └── FORMATS.bkmanifest └── autoconf_inc.m4 /testsuite/include/tut.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | -------------------------------------------------------------------------------- /make_all.sh: -------------------------------------------------------------------------------- 1 | make -f makefile.gcc 2 | make -f makefile.gcc DEBUG=1 3 | -------------------------------------------------------------------------------- /testsuite/include/tut_restartable.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | -------------------------------------------------------------------------------- /make_clean_all.sh: -------------------------------------------------------------------------------- 1 | make -f makefile.gcc clean 2 | make -f makefile.gcc DEBUG=1 clean 3 | -------------------------------------------------------------------------------- /create.sh: -------------------------------------------------------------------------------- 1 | bakefile -f gnu makefile.bkl -o makefile.gcc 2 | bakefile -f autoconf makefile.bkl 3 | -------------------------------------------------------------------------------- /create-config.sh: -------------------------------------------------------------------------------- 1 | bakefile -f autoconf makefile.bkl 2 | #bakefilize && 3 | aclocal -I autoconf && autoconf 4 | -------------------------------------------------------------------------------- /testsuite/make_all.sh: -------------------------------------------------------------------------------- 1 | make -f makefile.gcc DEBUG=0 SHARE=0 2 | make -f makefile.gcc DEBUG=1 SHARE=0 3 | make -f makefile.gcc DEBUG=0 SHARE=1 4 | make -f makefile.gcc DEBUG=1 SHARE=1 5 | -------------------------------------------------------------------------------- /testsuite/include/tut_reporter.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /testsuite/make_clean_all.sh: -------------------------------------------------------------------------------- 1 | make -f makefile.gcc DEBUG=0 SHARE=0 clean 2 | make -f makefile.gcc DEBUG=1 SHARE=0 clean 3 | make -f makefile.gcc DEBUG=0 SHARE=1 clean 4 | make -f makefile.gcc DEBUG=1 SHARE=1 clean 5 | -------------------------------------------------------------------------------- /testsuite/include/tut/tut_reporter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TUT_REPORTER 2 | #define TUT_REPORTER 3 | 4 | #include 5 | 6 | namespace tut 7 | { 8 | typedef console_reporter reporter; 9 | } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PureMVC_CPP 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /testsuite/create.bat: -------------------------------------------------------------------------------- 1 | bakefile -f msvc makefile.bkl -o makefile.vc 2 | bakefile -f mingw makefile.bkl -o makefile.mgw 3 | bakefile -f borland makefile.bkl -o makefile.bcc 4 | bakefile -f gnu makefile.bkl -o makefile.gcc 5 | bakefile -f intelw makefile.bkl -o makefile.icw 6 | pause 7 | -------------------------------------------------------------------------------- /puremvc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: @PACKAGE_NAME@ 7 | Description: Pkg-config for PureMVC 8 | URL: http://puremvc.org 9 | Version: @PACKAGE_VERSION@ 10 | Libs: -L${libdir} -lPureMVC 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /puremvc-static.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: @PACKAGE_NAME@ 7 | Description: Pkg-config for PureMVC (static linking) 8 | URL: http://puremvc.org 9 | Version: @PACKAGE_VERSION@ 10 | Libs: -L${libdir} -lPureMVCs 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /create.bat: -------------------------------------------------------------------------------- 1 | bakefile -f msvc makefile.bkl -o makefile.vc 2 | bakefile -f mingw makefile.bkl -o makefile.mgw 3 | bakefile -f borland makefile.bkl -o makefile.bcc 4 | bakefile -f dmars makefile.bkl -o makefile.dmc 5 | bakefile -f dmars_smake makefile.bkl -o makefile.dmc_smake 6 | bakefile -f gnu makefile.bkl -o makefile.gcc 7 | bakefile -f autoconf makefile.bkl 8 | bakefile -f intelw makefile.bkl -o makefile.icw 9 | pause 10 | -------------------------------------------------------------------------------- /admin/python-devel.m4: -------------------------------------------------------------------------------- 1 | # PYTHON_DEVEL() 2 | # 3 | # Checks for Python and tries to get the include path to 'Python.h'. 4 | # It provides the $(PYTHON_CPPFLAGS) output variable. 5 | AC_DEFUN([BKL_PYTHON_DEVEL],[ 6 | AC_REQUIRE([AM_PATH_PYTHON]) 7 | 8 | # Check for Python include path 9 | AC_MSG_CHECKING([for Python include path]) 10 | python_path=`${PYTHON} -c "from distutils import sysconfig; print sysconfig.get_python_inc()"` 11 | AC_MSG_RESULT([$python_path]) 12 | if test -z "$python_path" ; then 13 | AC_MSG_ERROR([cannot find Python include path]) 14 | fi 15 | AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path]) 16 | ]) 17 | -------------------------------------------------------------------------------- /aclocal.m4: -------------------------------------------------------------------------------- 1 | # generated automatically by aclocal 1.9.6 -*- Autoconf -*- 2 | 3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 4 | # 2005 Free Software Foundation, Inc. 5 | # This file is free software; the Free Software Foundation 6 | # gives unlimited permission to copy and/or distribute it, 7 | # with or without modifications, as long as this notice is preserved. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 | # PARTICULAR PURPOSE. 13 | 14 | m4_include([autoconf/bakefile-dllar.m4]) 15 | m4_include([autoconf/bakefile-lang.m4]) 16 | m4_include([autoconf/bakefile.m4]) 17 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | PureMVC C++ Port by Tang Khai Phuong 2 | PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 3 | -------------------------------------------------------------------------- 4 | Release Date: 10/21/2011 5 | Platform: C++ (Windows, Unix, MacOS) 6 | Version: 1 7 | Revision: 1 8 | Minor: 0 9 | Author: Tang Khai Phuong 10 | License: Creative Commons Attribution 3.0 United States License 11 | -------------------------------------------------------------------------- 12 | 13 | 1.1.0.0 - First version of PureMVC 14 | Fix: Move header file to correct position 15 | Fix: Segmentation fail on Linux due create Mutex on constructor. 16 | 17 | 1.0.0.0 - First version of PureMVC 18 | -------------------------------------------------------------------------------- /make_all.bat: -------------------------------------------------------------------------------- 1 | set OLD_PATH=%PATH% 2 | 3 | IF NOT EXIST "%VS100COMNTOOLS%vsvars32.bat" GOTO NO_VS10 4 | call "%VS100COMNTOOLS%vsvars32.bat" 5 | nmake -f makefile.vc 6 | nmake -f makefile.vc DEBUG=1 7 | :NO_VS10 8 | set PATH="E:\Compilers\Embarcadero\RAD Studio\7.0\bin" 9 | make -f makefile.bcc CPP0X=1 10 | make -f makefile.bcc DEBUG=1 CPP0X=1 11 | set PATH=E:\Compilers\MinGW\bin 12 | mingw32-make -f makefile.mgw CPP0X=1 13 | mingw32-make -f makefile.mgw DEBUG=1 CPP0X=1 14 | set PATH=E:\Compilers\dm\bin 15 | make -f makefile.dmc 16 | IF NOT EXIST "%ICPP_COMPILER11%bin\iclvars.bat" GOTO NO_INTEL 17 | call "%ICPP_COMPILER11%bin\iclvars.bat" ia32 18 | nmake -f makefile.icw 19 | nmake -f makefile.icw DEBUG=1 20 | :NO_INTEL 21 | set PATH=%OLD_PATH% 22 | 23 | pause 24 | -------------------------------------------------------------------------------- /admin/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3293 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3293]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4' 20 | macro_revision='1.3293' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /make_clean_all.bat: -------------------------------------------------------------------------------- 1 | set OLD_PATH=%PATH% 2 | 3 | IF NOT EXIST "%VS100COMNTOOLS%vsvars32.bat" GOTO NO_VS10 4 | call "%VS100COMNTOOLS%vsvars32.bat" 5 | nmake -f makefile.vc clean 6 | nmake -f makefile.vc DEBUG=1 clean 7 | :NO_VS10 8 | set PATH="E:\Compilers\Embarcadero\RAD Studio\7.0\bin" 9 | make -f makefile.bcc clean 10 | make -f makefile.bcc DEBUG=1 clean 11 | set PATH=E:\Compilers\MinGW\bin 12 | mingw32-make -f makefile.mgw clean 13 | mingw32-make -f makefile.mgw DEBUG=1 clean 14 | set PATH=E:\Compilers\dm\bin 15 | make -f makefile.dmc clean 16 | IF NOT EXIST "%ICPP_COMPILER11%bin\iclvars.bat" GOTO NO_INTEL 17 | call "%ICPP_COMPILER11%bin\iclvars.bat" ia32 18 | nmake -f makefile.icw clean 19 | nmake -f makefile.icw DEBUG=1 clean 20 | :NO_INTEL 21 | set PATH=%OLD_PATH% 22 | 23 | pause 24 | -------------------------------------------------------------------------------- /src/PureMVC/Patterns/Command/SimpleCommand.cpp: -------------------------------------------------------------------------------- 1 | // SimpleCommand.cpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #include "../../Common.hpp" 10 | 11 | SimpleCommand::SimpleCommand(void) 12 | : INotifier() 13 | , ICommand() 14 | , Notifier() 15 | { } 16 | 17 | SimpleCommand::SimpleCommand(SimpleCommand const& arg) 18 | : INotifier() 19 | , ICommand() 20 | , Notifier(arg) 21 | { } 22 | 23 | inline void SimpleCommand::execute(INotification const& notification) 24 | { 25 | (void)notification; 26 | } 27 | 28 | SimpleCommand& SimpleCommand::operator=(SimpleCommand const& arg) 29 | { 30 | _multiton_key = arg._multiton_key; 31 | return *this; 32 | } 33 | 34 | SimpleCommand::~SimpleCommand(void) 35 | { } 36 | -------------------------------------------------------------------------------- /testsuite/src/SimpleCommandTestVO.hpp: -------------------------------------------------------------------------------- 1 | // SimpleCommandTestVO.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__SIMPLE_COMMAND_TEST_VO_HPP__) 10 | #define __SIMPLE_COMMAND_TEST_VO_HPP__ 11 | 12 | namespace data 13 | { 14 | /** 15 | * A utility class used by SimpleCommandTest. 16 | */ 17 | struct SimpleCommandTestVO 18 | { 19 | int input; 20 | int result; 21 | /** 22 | * Constructor. 23 | * 24 | * @param input the number to be fed to the SimpleCommandTestCommand 25 | */ 26 | SimpleCommandTestVO(int input) 27 | { 28 | this->input = input; 29 | this->result = 0; 30 | } 31 | }; 32 | } 33 | 34 | #endif /* __SIMPLE_COMMAND_TEST_VO_HPP__ */ 35 | -------------------------------------------------------------------------------- /testsuite/src/MacroCommandTestVO.hpp: -------------------------------------------------------------------------------- 1 | // MacroCommandTestVO.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__MACRO_COMMAND_TEST_VO_HPP__) 10 | #define __MACRO_COMMAND_TEST_VO_HPP__ 11 | 12 | namespace data 13 | { 14 | /** 15 | * A utility class used by MacroCommandTest. 16 | */ 17 | struct MacroCommandTestVO 18 | { 19 | int input; 20 | int result1; 21 | int result2; 22 | /** 23 | * Constructor. 24 | * 25 | * @param input the number to be fed to the MacroCommandTestCommand 26 | */ 27 | MacroCommandTestVO(int input) 28 | { 29 | this->input = input; 30 | this->result1 = 0; 31 | this->result2 = 0; 32 | } 33 | }; 34 | } 35 | 36 | #endif /* __MACRO_COMMAND_TEST_VO_HPP__ */ 37 | -------------------------------------------------------------------------------- /testsuite/src/PureMVCTestCommand.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(__PURE_MVC_TEST_COMMAND_HPP__) 2 | #define __PURE_MVC_TEST_COMMAND_HPP__ 3 | 4 | #include 5 | #include "SimpleCommandTestVO.hpp" 6 | 7 | namespace data 8 | { 9 | using PureMVC::Patterns::SimpleCommand; 10 | using PureMVC::Interfaces::INotification; 11 | /** 12 | * A PureMVCTestCommand subclass used by SimpleCommand. 13 | * 14 | */ 15 | struct PureMVCTestCommand: SimpleCommand 16 | { 17 | 18 | /** 19 | * Constructor. 20 | */ 21 | PureMVCTestCommand() 22 | :SimpleCommand() 23 | { } 24 | 25 | /** 26 | * Fabricate a result by multiplying the input by 2 27 | * 28 | * @param event the INotification carrying the int 29 | */ 30 | virtual void execute(INotification const& note) 31 | { 32 | int& vo= *(int*)note.getBody(); 33 | vo *= 2; 34 | } 35 | }; 36 | } 37 | 38 | #endif /* __PURE_MVC_TEST_COMMAND_HPP__ */ 39 | -------------------------------------------------------------------------------- /testsuite/src/PureMVCTestCommand2.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(__PURE_MVC_TEST_COMMAND_2_HPP__) 2 | #define __PURE_MVC_TEST_COMMAND_2_HPP__ 3 | 4 | #include 5 | #include "SimpleCommandTestVO.hpp" 6 | 7 | namespace data 8 | { 9 | using PureMVC::Patterns::SimpleCommand; 10 | using PureMVC::Interfaces::INotification; 11 | /** 12 | * A PureMVCTestCommand2 subclass used by SimpleCommand. 13 | * 14 | */ 15 | struct PureMVCTestCommand2: SimpleCommand 16 | { 17 | 18 | /** 19 | * Constructor. 20 | */ 21 | PureMVCTestCommand2() 22 | :SimpleCommand() 23 | { } 24 | 25 | /** 26 | * Fabricate a result by multiplying the input by 3 27 | * 28 | * @param event the INotification carrying the int 29 | */ 30 | virtual void execute(INotification const& note) 31 | { 32 | int& vo= *(int*)note.getBody(); 33 | vo *= 3; 34 | } 35 | }; 36 | } 37 | 38 | #endif /* __PURE_MVC_TEST_COMMAND_2_HPP__ */ 39 | -------------------------------------------------------------------------------- /testsuite/src/PureMVCTestCommand3.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(__PURE_MVC_TEST_COMMAND_3_HPP__) 2 | #define __PURE_MVC_TEST_COMMAND_3_HPP__ 3 | 4 | #include 5 | #include "SimpleCommandTestVO.hpp" 6 | 7 | namespace data 8 | { 9 | using PureMVC::Patterns::SimpleCommand; 10 | using PureMVC::Interfaces::INotification; 11 | /** 12 | * A PureMVCTestCommand3 subclass used by SimpleCommand. 13 | * 14 | */ 15 | struct PureMVCTestCommand3: SimpleCommand 16 | { 17 | 18 | /** 19 | * Constructor. 20 | */ 21 | PureMVCTestCommand3() 22 | :SimpleCommand() 23 | { } 24 | 25 | /** 26 | * Fabricate a result by multiplying the input by 4 27 | * 28 | * @param event the INotification carrying the int 29 | */ 30 | virtual void execute(INotification const& note) 31 | { 32 | int& vo= *(int*)note.getBody(); 33 | vo *= 4; 34 | } 35 | }; 36 | } 37 | 38 | #endif /* __PURE_MVC_TEST_COMMAND_3_HPP__ */ 39 | -------------------------------------------------------------------------------- /testsuite/src/PureMVCTestCommand4.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(__PURE_MVC_TEST_COMMAND_4_HPP__) 2 | #define __PURE_MVC_TEST_COMMAND_4_HPP__ 3 | 4 | #include 5 | #include "SimpleCommandTestVO.hpp" 6 | 7 | namespace data 8 | { 9 | using PureMVC::Patterns::SimpleCommand; 10 | using PureMVC::Interfaces::INotification; 11 | /** 12 | * A PureMVCTestCommand4 subclass used by SimpleCommand. 13 | * 14 | */ 15 | struct PureMVCTestCommand4: SimpleCommand 16 | { 17 | 18 | /** 19 | * Constructor. 20 | */ 21 | PureMVCTestCommand4() 22 | :SimpleCommand() 23 | { } 24 | 25 | /** 26 | * Fabricate a result by multiplying the input by 5 27 | * 28 | * @param event the INotification carrying the int 29 | */ 30 | virtual void execute(INotification const& note) 31 | { 32 | int& vo= *(int*)note.getBody(); 33 | vo *= 5; 34 | } 35 | }; 36 | } 37 | 38 | #endif /* __PURE_MVC_TEST_COMMAND_4_HPP__ */ 39 | -------------------------------------------------------------------------------- /testsuite/src/FacadeTestVO.hpp: -------------------------------------------------------------------------------- 1 | // FacadeTestVO.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__FACADE_TEST_VO_HPP__) 10 | #define __FACADE_TEST_VO_HPP__ 11 | 12 | namespace data 13 | { 14 | /** 15 | * A utility class used by FacadeTest. 16 | * 17 | * @see org.puremvc.as3.multicore.patterns.facade.FacadeTest FacadeTest 18 | * @see org.puremvc.as3.multicore.patterns.facade.FacadeTestCommand FacadeTestCommand 19 | */ 20 | struct FacadeTestVO 21 | { 22 | int input; 23 | int result; 24 | /** 25 | * Constructor. 26 | * 27 | * @param input the number to be fed to the FacadeTestCommand 28 | */ 29 | FacadeTestVO(int input) 30 | { 31 | this->input = input; 32 | this->result = 0; 33 | } 34 | }; 35 | } 36 | 37 | #endif /* __FACADE_TEST_VO_HPP__ */ 38 | -------------------------------------------------------------------------------- /testsuite/make_all.bat: -------------------------------------------------------------------------------- 1 | set OLD_PATH=%PATH% 2 | IF NOT EXIST "%VS100COMNTOOLS%vsvars32.bat" GOTO NO_VS10 3 | call "%VS100COMNTOOLS%vsvars32.bat" 4 | nmake -f makefile.vc DEBUG=0 SHARE=0 5 | nmake -f makefile.vc DEBUG=1 SHARE=0 6 | nmake -f makefile.vc DEBUG=0 SHARE=1 7 | nmake -f makefile.vc DEBUG=1 SHARE=1 8 | :NO_VS10 9 | set PATH="E:\Compilers\Embarcadero\RAD Studio\7.0\bin" 10 | make -f makefile.bcc DEBUG=0 SHARE=0 CPP0X=1 11 | make -f makefile.bcc DEBUG=1 SHARE=0 CPP0X=1 12 | make -f makefile.bcc DEBUG=0 SHARE=1 CPP0X=1 13 | make -f makefile.bcc DEBUG=1 SHARE=1 CPP0X=1 14 | set PATH=E:\Compilers\MinGW\bin 15 | mingw32-make -f makefile.mgw DEBUG=0 SHARE=0 CPP0X=1 16 | mingw32-make -f makefile.mgw DEBUG=1 SHARE=0 CPP0X=1 17 | mingw32-make -f makefile.mgw DEBUG=0 SHARE=1 CPP0X=1 18 | mingw32-make -f makefile.mgw DEBUG=1 SHARE=1 CPP0X=1 19 | IF NOT EXIST "%ICPP_COMPILER11%bin\iclvars.bat" GOTO NO_INTEL 20 | call "%ICPP_COMPILER11%bin\iclvars.bat" ia32 21 | nmake -f makefile.icw DEBUG=0 SHARE=0 22 | nmake -f makefile.icw DEBUG=1 SHARE=0 23 | nmake -f makefile.icw DEBUG=0 SHARE=1 24 | nmake -f makefile.icw DEBUG=1 SHARE=1 25 | :NO_INTEL 26 | set PATH=%OLD_PATH% 27 | pause 28 | -------------------------------------------------------------------------------- /testsuite/make_clean_all.bat: -------------------------------------------------------------------------------- 1 | set OLD_PATH=%PATH% 2 | IF NOT EXIST "%VS100COMNTOOLS%vsvars32.bat" GOTO NO_VS10 3 | call "%VS100COMNTOOLS%vsvars32.bat" 4 | nmake -f makefile.vc DEBUG=0 SHARE=0 clean 5 | nmake -f makefile.vc DEBUG=1 SHARE=0 clean 6 | nmake -f makefile.vc DEBUG=0 SHARE=1 clean 7 | nmake -f makefile.vc DEBUG=1 SHARE=1 clean 8 | :NO_VS10 9 | set PATH="E:\Compilers\Embarcadero\RAD Studio\7.0\bin" 10 | make -f makefile.bcc DEBUG=0 SHARE=0 clean 11 | make -f makefile.bcc DEBUG=1 SHARE=0 clean 12 | make -f makefile.bcc DEBUG=0 SHARE=1 clean 13 | make -f makefile.bcc DEBUG=1 SHARE=1 clean 14 | set PATH=E:\Compilers\MinGW\bin 15 | mingw32-make -f makefile.mgw DEBUG=0 SHARE=0 clean 16 | mingw32-make -f makefile.mgw DEBUG=1 SHARE=0 clean 17 | mingw32-make -f makefile.mgw DEBUG=0 SHARE=1 clean 18 | mingw32-make -f makefile.mgw DEBUG=1 SHARE=1 clean 19 | IF NOT EXIST "%ICPP_COMPILER11%bin\iclvars.bat" GOTO NO_INTEL 20 | call "%ICPP_COMPILER11%bin\iclvars.bat" ia32 21 | nmake -f makefile.icw DEBUG=0 SHARE=0 clean 22 | nmake -f makefile.icw DEBUG=1 SHARE=0 clean 23 | nmake -f makefile.icw DEBUG=0 SHARE=1 clean 24 | nmake -f makefile.icw DEBUG=1 SHARE=1 clean 25 | :NO_INTEL 26 | set PATH=%OLD_PATH% 27 | pause 28 | -------------------------------------------------------------------------------- /testsuite/src/ControllerTestVO.hpp: -------------------------------------------------------------------------------- 1 | // ControllerTestVO.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__CONTROLLER_TEST_VO_HPP__) 10 | #define __CONTROLLER_TEST_VO_HPP__ 11 | 12 | namespace data 13 | { 14 | /** 15 | * A utility class used by ControllerTest. 16 | * 17 | * @see org.puremvc.as3.multicore.core.controller.ControllerTest ControllerTest 18 | * @see org.puremvc.as3.multicore.core.controller.ControllerTestCommand ControllerTestCommand 19 | */ 20 | struct ControllerTestVO 21 | { 22 | int input; 23 | int result; 24 | /** 25 | * Constructor. 26 | * 27 | * @param input the number to be fed to the ControllerTestCommand 28 | */ 29 | ControllerTestVO(int input) 30 | { 31 | this->input = input; 32 | this->result = 0; 33 | } 34 | }; 35 | } 36 | 37 | #endif /* __CONTROLLER_TEST_VO_HPP__ */ 38 | -------------------------------------------------------------------------------- /testsuite/src/FacadeTestCommand.hpp: -------------------------------------------------------------------------------- 1 | // FacadeTestCommand.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__FACADE_TEST_COMMAND_HPP__) 10 | #define __FACADE_TEST_COMMAND_HPP__ 11 | 12 | #include 13 | #include "FacadeTestVO.hpp" 14 | 15 | namespace data 16 | { 17 | using PureMVC::Interfaces::INotification; 18 | using PureMVC::Patterns::SimpleCommand; 19 | 20 | /** 21 | * A SimpleCommand subclass used by FacadeTest. 22 | * 23 | * @see org.puremvc.as3.multicore.patterns.facade.FacadeTest FacadeTest 24 | * @see org.puremvc.as3.multicore.patterns.facade.FacadeTestVO FacadeTestVO 25 | */ 26 | struct FacadeTestCommand : public SimpleCommand 27 | { 28 | void execute(INotification const& notification) 29 | { 30 | FacadeTestVO& vo = *(FacadeTestVO*) notification.getBody(); 31 | vo.result = vo.input * 2; 32 | } 33 | }; 34 | } 35 | 36 | #endif /* __FACADE_TEST_COMMAND_HPP__ */ 37 | -------------------------------------------------------------------------------- /testsuite/src/ViewTest.hpp: -------------------------------------------------------------------------------- 1 | // ViewTest.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__VIEW_TEST_HPP__) 10 | #define __VIEW_TEST_HPP__ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace data 17 | { 18 | using PureMVC::Interfaces::INotification; 19 | 20 | struct ViewTest 21 | { 22 | std::string lastNotification; 23 | bool onRegisterCalled; 24 | bool onRemoveCalled; 25 | int counter; 26 | PureMVC::Mutex viewTestVarsLock; 27 | std::map viewTestVars; 28 | ViewTest(); 29 | // viewTestMethod must be virtual!!! 30 | virtual void viewTestMethod(INotification const& note); 31 | static char const* const NOTE1; 32 | static char const* const NOTE2; 33 | static char const* const NOTE3; 34 | static char const* const NOTE4; 35 | static char const* const NOTE5; 36 | static char const* const NOTE6; 37 | }; 38 | } 39 | 40 | #endif /* __VIEW_TEST_HPP__ */ 41 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | AC_PREREQ(2.53) 2 | AC_INIT([PureMVC], [1.0.0.0], [phuong.tang@puremvc.org]) 3 | dnl pass some unique file file to AC_CONFIG_SRCDIR 4 | AC_CONFIG_SRCDIR([autoconf_inc.m4]) 5 | AC_CANONICAL_HOST 6 | 7 | AC_PROG_CC 8 | AC_PROG_CXX 9 | AC_PROG_CXXCPP 10 | 11 | ############################ Build mode configure ############################# 12 | 13 | AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],[Enable debugging information [default=no]])], USE_DEBUG="$enableval", USE_DEBUG="no") 14 | 15 | ############################ C++0x feature configure ############################# 16 | 17 | AC_ARG_ENABLE([c++0x], [AS_HELP_STRING([--enable-c++0x],[Enable with with C++0x feature [default=no]])], USE_CPP0X="$enableval", USE_CPP0X="no") 18 | 19 | if test $USE_DEBUG = yes ; then 20 | DEBUG=1 21 | if test $USE_CPP0X = yes ; then 22 | CXXFLAGS="-g -O0 -gdwarf-2 -Wall -std=c++0x" 23 | else 24 | CXXFLAGS="-g -O0 -gdwarf-2 -Wall" 25 | fi 26 | else 27 | DEBUG=0 28 | if test $USE_CPP0X = yes ; then 29 | CXXFLAGS="-O2 -std=c++0x" 30 | else 31 | CXXFLAGS=-O2 32 | fi 33 | fi 34 | AC_SUBST(CXXFLAGS) 35 | 36 | ############################################################################### 37 | 38 | 39 | AC_BAKEFILE([m4_include(autoconf_inc.m4)]) 40 | AC_CONFIG_FILES([Makefile puremvc.pc puremvc-static.pc]) 41 | AC_OUTPUT 42 | -------------------------------------------------------------------------------- /testsuite/src/ModelTestProxy.hpp: -------------------------------------------------------------------------------- 1 | // ModelTestProxy.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__MODEL_TEST_PROXY_HPP__) 10 | #define __MODEL_TEST_PROXY_HPP__ 11 | 12 | #include 13 | 14 | namespace data 15 | { 16 | using PureMVC::Patterns::Proxy; 17 | 18 | struct ModelTestProxy: public Proxy 19 | { 20 | static char const* const NAME; 21 | static char const* const ON_REGISTER_CALLED; 22 | static char const* const ON_REMOVE_CALLED; 23 | 24 | ModelTestProxy() :Proxy(NAME, "") 25 | { } 26 | 27 | virtual void onRegister(void) 28 | { 29 | setData(ON_REGISTER_CALLED); 30 | } 31 | 32 | virtual void onRemove(void) 33 | { 34 | setData(ON_REMOVE_CALLED); 35 | } 36 | }; 37 | 38 | char const* const ModelTestProxy::NAME = "ModelTestProxy"; 39 | char const* const ModelTestProxy::ON_REGISTER_CALLED = "onRegister Called"; 40 | char const* const ModelTestProxy::ON_REMOVE_CALLED = "onRemove Called"; 41 | } 42 | 43 | #endif /* __MODEL_TEST_PROXY_HPP__ */ 44 | -------------------------------------------------------------------------------- /src/PureMVC/Patterns/Proxy/Proxy.cpp: -------------------------------------------------------------------------------- 1 | // Proxy.cpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #include "../../Common.hpp" 10 | 11 | char const* const Proxy::NAME = "Proxy"; 12 | 13 | Proxy::Proxy(std::string const& proxy_name, void const* data) 14 | : INotifier() 15 | , IProxy() 16 | , Notifier() 17 | , _proxy_name(proxy_name) 18 | , _data(data) 19 | { } 20 | 21 | Proxy::Proxy(Proxy const& arg) 22 | : INotifier() 23 | , IProxy() 24 | , Notifier(arg) 25 | , _proxy_name(arg._proxy_name) 26 | , _data(arg._data) 27 | { } 28 | 29 | inline std::string const& Proxy::getProxyName(void) const 30 | { 31 | return _proxy_name; 32 | } 33 | 34 | inline void Proxy::setData(void const* data) 35 | { 36 | _data = data; 37 | } 38 | 39 | inline void const* Proxy::getData(void) const 40 | { 41 | return _data; 42 | } 43 | 44 | inline void Proxy::onRegister(void) 45 | { } 46 | 47 | inline void Proxy::onRemove(void) 48 | { } 49 | 50 | Proxy& Proxy::operator=(Proxy const& arg) 51 | { 52 | _proxy_name = arg._proxy_name; 53 | _data = arg._data; 54 | return *this; 55 | } 56 | 57 | Proxy::~Proxy(void) 58 | { } 59 | -------------------------------------------------------------------------------- /testsuite/src/MacroCommandTestSub1Command.hpp: -------------------------------------------------------------------------------- 1 | // MacroCommandTestSub1Command.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__MACRO_COMMAND_TEST_SUB1_COMMAND_HPP__) 10 | #define __MACRO_COMMAND_TEST_SUB1_COMMAND_HPP__ 11 | 12 | #include "MacroCommandTestVO.hpp" 13 | 14 | namespace data 15 | { 16 | using PureMVC::Patterns::SimpleCommand; 17 | using PureMVC::Patterns::INotification; 18 | /** 19 | * A SimpleCommand subclass used by MacroCommandTestCommand. 20 | */ 21 | struct MacroCommandTestSub1Command: public SimpleCommand 22 | { 23 | MacroCommandTestSub1Command(void) 24 | :SimpleCommand() 25 | { } 26 | 27 | /** 28 | * Fabricate a result by multiplying the input by 2 29 | * 30 | * @param event the IEvent carrying the MacroCommandTestVO 31 | */ 32 | void execute(INotification const& note) 33 | { 34 | MacroCommandTestVO& vo = *(MacroCommandTestVO*)note.getBody(); 35 | // Fabricate a result 36 | vo.result1 = 2 * vo.input; 37 | } 38 | }; 39 | } 40 | 41 | #endif /* __MACRO_COMMAND_TEST_SUB1_COMMAND_HPP__ */ 42 | -------------------------------------------------------------------------------- /testsuite/src/IteratorTest.hpp: -------------------------------------------------------------------------------- 1 | // IteratorTest.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__ITERATOR_TEST_HPP__) 10 | #define __ITERATOR_TEST_HPP__ 11 | 12 | #include 13 | 14 | namespace data 15 | { 16 | using PureMVC::Interfaces::IIterator; 17 | using PureMVC::Interfaces::IAggregate; 18 | 19 | struct IteratorTest : public IAggregate 20 | { 21 | typedef std::list list_string_t; 22 | std::list listItem; 23 | 24 | struct Converter : public std::unary_function { 25 | std::string const& operator()(list_string_t::const_iterator const& iterator) const; 26 | }; 27 | class Iterator : public PureMVC::Patterns::Iterator 28 | { friend struct IteratorTest; }; 29 | 30 | virtual void setIterator(IIterator& iterator) const; 31 | 32 | virtual void setIterator(IteratorTest::Iterator& iterator) const; 33 | 34 | virtual IAggregate::Iterator getIterator(void) const; 35 | }; 36 | } 37 | 38 | #endif /* __ITERATOR_TEST_HPP__ */ 39 | -------------------------------------------------------------------------------- /testsuite/src/MacroCommandTestSub2Command.hpp: -------------------------------------------------------------------------------- 1 | // MacroCommandTestSub2Command.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__MACRO_COMMAND_TEST_SUB2_COMMAND_HPP__) 10 | #define __MACRO_COMMAND_TEST_SUB2_COMMAND_HPP__ 11 | 12 | #include "MacroCommandTestVO.hpp" 13 | 14 | namespace data 15 | { 16 | using PureMVC::Patterns::SimpleCommand; 17 | using PureMVC::Patterns::INotification; 18 | /** 19 | * A SimpleCommand subclass used by MacroCommandTestCommand. 20 | */ 21 | struct MacroCommandTestSub2Command: public SimpleCommand 22 | { 23 | MacroCommandTestSub2Command(void) 24 | :SimpleCommand() 25 | { } 26 | 27 | /** 28 | * Fabricate a result by multiplying the input by itself 29 | * 30 | * @param event the IEvent carrying the MacroCommandTestVO 31 | */ 32 | void execute(INotification const& note) 33 | { 34 | MacroCommandTestVO& vo = *(MacroCommandTestVO*)note.getBody(); 35 | // Fabricate a result 36 | vo.result2 = vo.input * vo.input; 37 | } 38 | }; 39 | } 40 | 41 | #endif /* __MACRO_COMMAND_TEST_SUB2_COMMAND_HPP__ */ 42 | -------------------------------------------------------------------------------- /testsuite/src/MacroCommandTestCommand.hpp: -------------------------------------------------------------------------------- 1 | // MacroCommandTestCommand.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__MACRO_COMMAND_TEST_COMMAND_HPP__) 10 | #define __MACRO_COMMAND_TEST_COMMAND_HPP__ 11 | 12 | #include 13 | #include "MacroCommandTestSub1Command.hpp" 14 | #include "MacroCommandTestSub2Command.hpp" 15 | 16 | namespace data 17 | { 18 | using PureMVC::Patterns::MacroCommand; 19 | /** 20 | * A MacroCommand subclass used by MacroCommandTest. 21 | */ 22 | class MacroCommandTestCommand : public MacroCommand 23 | { 24 | public: 25 | /** 26 | * Constructor. 27 | */ 28 | MacroCommandTestCommand(void) 29 | :MacroCommand() 30 | { 31 | initializeMacroCommand(); 32 | } 33 | 34 | protected: 35 | /** 36 | * Initialize the MacroCommandTestCommand by adding 37 | * its 2 SubCommands. 38 | */ 39 | void initializeMacroCommand(void) 40 | { 41 | addSubCommand(new MacroCommandTestSub1Command()); 42 | addSubCommand(new MacroCommandTestSub2Command() ); 43 | } 44 | }; 45 | } 46 | 47 | #endif /* __MACRO_COMMAND_TEST_COMMAND_HPP__ */ 48 | -------------------------------------------------------------------------------- /testsuite/src/SimpleCommandTestSecondCommand.hpp: -------------------------------------------------------------------------------- 1 | // SimpleCommandTestCommand.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__SIMPLE_COMMAND_TEST_SECOND_COMMAND_HPP__) 10 | #define __SIMPLE_COMMAND_TEST_SECOND_COMMAND_HPP__ 11 | 12 | #include 13 | #include "SimpleCommandTestVO.hpp" 14 | 15 | namespace data 16 | { 17 | using PureMVC::Patterns::SimpleCommand; 18 | using PureMVC::Interfaces::INotification; 19 | /** 20 | * A SimpleCommand subclass used by SimpleCommandTest. 21 | */ 22 | struct SimpleCommandTestSecondCommand: SimpleCommand 23 | { 24 | 25 | /** 26 | * Constructor. 27 | */ 28 | SimpleCommandTestSecondCommand() 29 | :SimpleCommand() 30 | { } 31 | 32 | /** 33 | * OUtput 34 | * 35 | * @param event the INotification carrying the SimpleCommandTestVO 36 | */ 37 | virtual void execute(INotification const& note) 38 | { 39 | SimpleCommandTestVO& vo= *(SimpleCommandTestVO*)note.getBody(); 40 | // Fabricate a result 41 | vo.result += 3 * vo.input; 42 | } 43 | }; 44 | } 45 | 46 | #endif /* __SIMPLE_COMMAND_TEST_SECOND_COMMAND_HPP__ */ 47 | -------------------------------------------------------------------------------- /testsuite/src/SimpleCommandTestCommand.hpp: -------------------------------------------------------------------------------- 1 | // SimpleCommandTestCommand.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__SIMPLE_COMMAND_TEST_COMMAND_HPP__) 10 | #define __SIMPLE_COMMAND_TEST_COMMAND_HPP__ 11 | 12 | #include 13 | #include "SimpleCommandTestVO.hpp" 14 | 15 | namespace data 16 | { 17 | using PureMVC::Patterns::SimpleCommand; 18 | using PureMVC::Interfaces::INotification; 19 | /** 20 | * A SimpleCommand subclass used by SimpleCommandTest. 21 | */ 22 | struct SimpleCommandTestCommand: SimpleCommand 23 | { 24 | 25 | /** 26 | * Constructor. 27 | */ 28 | SimpleCommandTestCommand() 29 | :SimpleCommand() 30 | { } 31 | 32 | /** 33 | * Fabricate a result by multiplying the input by 2 34 | * 35 | * @param event the INotification carrying the SimpleCommandTestVO 36 | */ 37 | virtual void execute(INotification const& note) 38 | { 39 | SimpleCommandTestVO& vo= *(SimpleCommandTestVO*)note.getBody(); 40 | // Fabricate a result 41 | vo.result = 2 * vo.input; 42 | } 43 | }; 44 | } 45 | 46 | #endif /* __SIMPLE_COMMAND_TEST_COMMAND_HPP__ */ 47 | -------------------------------------------------------------------------------- /include/PureMVC/Interfaces/ICommand.hpp: -------------------------------------------------------------------------------- 1 | // ICommand.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_INTERFACES_ICOMMMAND_HPP__) 10 | #define __PUREMVC_INTERFACES_ICOMMMAND_HPP__ 11 | 12 | // PureMVC include 13 | #if !defined(__PUREMVC_HPP__) 14 | #define __PUREMVC_INCLUDE__ 15 | #include "../PureMVC.hpp" 16 | #endif /* __PUREMVC_HPP__ */ 17 | 18 | #include "INotifier.hpp" 19 | #include "INotification.hpp" 20 | 21 | namespace PureMVC 22 | { 23 | namespace Interfaces 24 | { 25 | /** 26 | * The interface definition for a PureMVC Command. 27 | * 28 | * @see Interfaces/INotification.hpp PureMVC::Interfaces::INotification 29 | */ 30 | struct PUREMVC_API ICommand : public virtual INotifier 31 | { 32 | /** 33 | * Execute the ICommand's logic to handle a given INotification. 34 | * 35 | * @param notification an INotification to handle. 36 | */ 37 | virtual void execute(INotification const& notification) = 0; 38 | 39 | /** 40 | * Virtual destructor. 41 | */ 42 | virtual ~ICommand(void); 43 | }; 44 | } 45 | } 46 | 47 | #endif /* __PUREMVC_INTERFACES_ICOMMMAND_HPP__ */ 48 | -------------------------------------------------------------------------------- /src/PureMVC/Patterns/Observer/Notifier.cpp: -------------------------------------------------------------------------------- 1 | // Notifier.cpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #include "../../Common.hpp" 10 | 11 | char const* const Notifier::MULTITON_MSG = 12 | "Multiton key for this Notifier not yet initialized!"; 13 | 14 | Notifier::Notifier(void) 15 | : INotifier() 16 | { } 17 | 18 | Notifier::Notifier(Notifier const& arg) 19 | : INotifier() 20 | , _multiton_key(arg._multiton_key) 21 | { } 22 | 23 | void Notifier::sendNotification(std::string const& notification_name, 24 | void const* body, 25 | std::string const& type) 26 | { 27 | getFacade().sendNotification(notification_name, body, type); 28 | } 29 | 30 | void Notifier::initializeNotifier(std::string const& key) 31 | { 32 | _multiton_key = key; 33 | } 34 | 35 | std::string const& Notifier::getMultitonKey(void) const 36 | { 37 | return _multiton_key; 38 | } 39 | 40 | IFacade& Notifier::getFacade(void) 41 | { 42 | if (_multiton_key == "" ) 43 | throw std::runtime_error(MULTITON_MSG); 44 | return Facade::getInstance(_multiton_key); 45 | } 46 | 47 | Notifier& Notifier::operator=(Notifier const& arg) 48 | { 49 | _multiton_key = arg._multiton_key; 50 | return *this; 51 | } 52 | 53 | Notifier::~Notifier(void) 54 | { } 55 | -------------------------------------------------------------------------------- /testsuite/src/ControllerTestCommand.hpp: -------------------------------------------------------------------------------- 1 | // ControllerTestCommand.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__CONTROLLER_TEST_COMMAND_HPP__) 10 | #define __CONTROLLER_TEST_COMMAND_HPP__ 11 | 12 | #include 13 | #include "ControllerTestVO.hpp" 14 | 15 | namespace data 16 | { 17 | using PureMVC::Patterns::SimpleCommand; 18 | using PureMVC::Interfaces::INotification; 19 | using PureMVC::Interfaces::ICommand; 20 | /** 21 | * A SimpleCommand subclass used by ControllerTest. 22 | */ 23 | struct ControllerTestCommand 24 | : public virtual ICommand 25 | , public SimpleCommand 26 | { 27 | /** 28 | * Constructor. 29 | */ 30 | ControllerTestCommand(void) 31 | :SimpleCommand() 32 | { } 33 | 34 | /** 35 | * Fabricate a result by multiplying the input by 2 36 | * 37 | * @param note the note carrying the ControllerTestVO 38 | */ 39 | virtual void execute(INotification const& note) 40 | { 41 | ControllerTestVO& vo= *(ControllerTestVO*)note.getBody(); 42 | // Fabricate a result 43 | vo.result = 2 * vo.input; 44 | } 45 | }; 46 | } 47 | 48 | #endif /* __CONTROLLER_TEST_COMMAND_HPP__ */ 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | * PureMVC MultiCore Framework for C++ (Ported) - Copyright © 2012 Tang Khai Phuong 2 | * PureMVC - Copyright © 2007-2012 Futurescale, Inc. 3 | * All rights reserved. 4 | 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | * Neither the name of Futurescale, Inc., PureMVC.org, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /testsuite/src/ViewTestInheritance.hpp: -------------------------------------------------------------------------------- 1 | // ViewTestInheritance.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__VIEW_TEST_HERITANCE_HPP__) 10 | #define __VIEW_TEST_HERITANCE_HPP__ 11 | 12 | #include 13 | 14 | namespace data 15 | { 16 | using PureMVC::Interfaces::IView; 17 | using PureMVC::Core::View; 18 | 19 | class ViewTestInheritance 20 | : public virtual IView 21 | , public View 22 | { 23 | friend class View; 24 | public: 25 | std::string* initializeViewCalled; 26 | protected: 27 | ViewTestInheritance(void) 28 | :View(this, "ViewTestInheritance") 29 | { } 30 | public: 31 | static ViewTestInheritance& getInstance(void) 32 | { 33 | if (View::find("ViewTestInheritance") == NULL) 34 | new ViewTestInheritance(); 35 | return *(dynamic_cast(&View::getInstance("ViewTestInheritance"))); 36 | } 37 | protected: 38 | void initializeView(void) 39 | { 40 | initializeViewCalled = new std::string("Called!!!"); 41 | View::initializeView(); 42 | } 43 | public: 44 | ~ViewTestInheritance() 45 | { 46 | delete initializeViewCalled; 47 | } 48 | }; 49 | } 50 | 51 | #endif /* __VIEW_TEST_HERITANCE_HPP__ */ 52 | -------------------------------------------------------------------------------- /testsuite/src/ModelTestInheritance.hpp: -------------------------------------------------------------------------------- 1 | // ModelTestInheritance.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__MODEL_TEST_HERITANCE_HPP__) 10 | #define __MODEL_TEST_HERITANCE_HPP__ 11 | 12 | #include 13 | 14 | namespace data 15 | { 16 | using PureMVC::Interfaces::IModel; 17 | using PureMVC::Core::Model; 18 | 19 | class ModelTestInheritance 20 | : public virtual IModel 21 | , public Model 22 | { 23 | friend class Model; 24 | public: 25 | std::string* initializeModelCalled; 26 | protected: 27 | ModelTestInheritance(void) 28 | :Model(this, "ModelTestInheritance") 29 | { } 30 | public: 31 | static ModelTestInheritance& getInstance(void) 32 | { 33 | if (Model::find("ModelTestInheritance") == NULL) 34 | new ModelTestInheritance(); 35 | return *(dynamic_cast(&Model::getInstance("ModelTestInheritance"))); 36 | } 37 | protected: 38 | void initializeModel(void) 39 | { 40 | initializeModelCalled = new std::string("Called!!!"); 41 | Model::initializeModel(); 42 | } 43 | public: 44 | ~ModelTestInheritance() 45 | { 46 | delete initializeModelCalled; 47 | } 48 | }; 49 | } 50 | 51 | #endif /* __MODEL_TEST_HERITANCE_HPP__ */ 52 | -------------------------------------------------------------------------------- /testsuite/src/ViewTestMediator4.hpp: -------------------------------------------------------------------------------- 1 | // ViewTestMediator4.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__VIEW_TEST_MEDIATOR4_HPP__) 10 | #define __VIEW_TEST_MEDIATOR4_HPP__ 11 | 12 | #include 13 | #include 14 | #include "ViewTest.hpp" 15 | 16 | namespace data 17 | { 18 | using PureMVC::Patterns::Mediator; 19 | /** 20 | * A Mediator class used by ViewTest. 21 | */ 22 | struct ViewTestMediator4 : public Mediator 23 | { 24 | /** 25 | * The Mediator name 26 | */ 27 | static char const* const NAME; 28 | 29 | /** 30 | * Constructor 31 | */ 32 | ViewTestMediator4(const void* view) 33 | :Mediator(NAME, view) 34 | { } 35 | 36 | void onRegister(void) 37 | { 38 | viewTest()->onRegisterCalled = true; 39 | } 40 | 41 | void onRemove(void) 42 | { 43 | viewTest()->onRemoveCalled = true; 44 | } 45 | 46 | ViewTest const* viewTest(void) const 47 | { 48 | return (ViewTest*)_view_component; 49 | } 50 | 51 | ViewTest* viewTest(void) 52 | { 53 | return (ViewTest*)_view_component; 54 | } 55 | }; 56 | char const* const ViewTestMediator4::NAME = "ViewTestMediator4"; 57 | } 58 | 59 | #endif /* __VIEW_TEST_MEDIATOR4_HPP__ */ 60 | -------------------------------------------------------------------------------- /testsuite/src/ViewTestMediator.hpp: -------------------------------------------------------------------------------- 1 | // ViewTestMediator.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__VIEW_TEST_MEDIATOR_HPP__) 10 | #define __VIEW_TEST_MEDIATOR_HPP__ 11 | 12 | #include 13 | #include 14 | 15 | namespace data 16 | { 17 | using PureMVC::Patterns::Mediator; 18 | using PureMVC::Patterns::StdContainerAggregate; 19 | using PureMVC::Interfaces::IMediator; 20 | /** 21 | * A Mediator class used by ViewTest. 22 | */ 23 | struct ViewTestMediator : public Mediator 24 | { 25 | /** 26 | * The Mediator name 27 | */ 28 | static char const* const NAME; 29 | 30 | /** 31 | * Constructor 32 | */ 33 | ViewTestMediator(std::string const& name, void const* view) 34 | :Mediator(name, view) 35 | { } 36 | 37 | virtual NotificationNames listNotificationInterests(void) const 38 | { 39 | typedef StdContainerAggregate > result_t; 40 | result_t* result = new result_t; 41 | result->get().push_back("ABC"); 42 | result->get().push_back("DEF"); 43 | result->get().push_back("GHI"); 44 | return NotificationNames(result); 45 | } 46 | }; 47 | char const* const ViewTestMediator::NAME = "ViewTestMediator"; 48 | } 49 | 50 | #endif /* __VIEW_TEST_MEDIATOR_HPP__ */ 51 | -------------------------------------------------------------------------------- /testsuite/src/ControllerTestCommand2.hpp: -------------------------------------------------------------------------------- 1 | // ControllerTestCommand2.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__CONTROLLER_TEST_COMMAND2_HPP__) 10 | #define __CONTROLLER_TEST_COMMAND2_HPP__ 11 | 12 | #include 13 | #include "ControllerTestVO.hpp" 14 | 15 | namespace data 16 | { 17 | using PureMVC::Patterns::SimpleCommand; 18 | using PureMVC::Interfaces::INotification; 19 | using PureMVC::Interfaces::ICommand; 20 | /** 21 | * A SimpleCommand subclass used by ControllerTest. 22 | */ 23 | struct ControllerTestCommand2 24 | : public virtual ICommand 25 | , public SimpleCommand 26 | { 27 | /** 28 | * Constructor. 29 | */ 30 | ControllerTestCommand2(void) 31 | :SimpleCommand() 32 | { } 33 | 34 | /** 35 | * Fabricate a result by multiplying the input by 2 and adding to the existing result 36 | *

37 | * This tests accumulation effect that would show if the command were executed more than once. 38 | * @param note the note carrying the ControllerTestVO 39 | */ 40 | virtual void execute(INotification const& note) 41 | { 42 | ControllerTestVO& vo= *(ControllerTestVO*)note.getBody(); 43 | // Fabricate a result 44 | vo.result = vo.result+(2 * vo.input); 45 | } 46 | }; 47 | } 48 | 49 | #endif /* __CONTROLLER_TEST_COMMAND2_HPP__ */ 50 | -------------------------------------------------------------------------------- /testsuite/src/ControllerTestInheritance.hpp: -------------------------------------------------------------------------------- 1 | // ControllerTestInheritance.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__CONTROLLER_TEST_HERITANCE_HPP__) 10 | #define __CONTROLLER_TEST_HERITANCE_HPP__ 11 | 12 | #include 13 | 14 | namespace data 15 | { 16 | using PureMVC::Core::Controller; 17 | using PureMVC::Interfaces::IController; 18 | 19 | class ControllerTestInheritance 20 | : public virtual IController 21 | , public Controller 22 | { 23 | friend class Controller; 24 | public: 25 | std::string* initializeControllerCalled; 26 | protected: 27 | ControllerTestInheritance(void) 28 | :Controller(this, "ControllerTestInheritance") 29 | { } 30 | public: 31 | static ControllerTestInheritance& getInstance(void) 32 | { 33 | if (Controller::find("ControllerTestInheritance") == NULL) 34 | new ControllerTestInheritance(); 35 | return *(dynamic_cast(&Controller::getInstance("ControllerTestInheritance"))); 36 | } 37 | protected: 38 | virtual void initializeController(void) 39 | { 40 | initializeControllerCalled = new std::string("Called!!!"); 41 | Controller::initializeController(); 42 | } 43 | public: 44 | ~ControllerTestInheritance() 45 | { 46 | delete initializeControllerCalled; 47 | } 48 | }; 49 | } 50 | 51 | #endif /* __CONTROLLER_TEST_HERITANCE_HPP__ */ 52 | -------------------------------------------------------------------------------- /autoconf/merge-scripts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Merges helper scripts into bakefile.m4 4 | # 5 | # $Id: merge-scripts.py 988 2007-01-11 00:00:03Z vaclavslavik $ 6 | 7 | MARK_IDENT = 'dnl ===================== ' 8 | MARK_BEGINS = ' begins here =====================' 9 | MARK_ENDS = ' ends here =====================' 10 | 11 | import re 12 | 13 | def mergeFile(filename): 14 | f = open(filename, 'rt').readlines() 15 | f2 = [] 16 | for i in f: 17 | i = re.sub(r'\$', r'${D}', i) 18 | i = re.sub(r'@([a-zA-Z0-9_]+)@', r'${\1}', i) 19 | i = re.sub(r'\[', r'@<:@', i) 20 | i = re.sub(r'\\', r'\\\\', i) 21 | i = re.sub(r'\]', r'@:>@', i) 22 | i = re.sub(r'`', r'\`', i) 23 | f2.append(i) 24 | return f2 25 | 26 | def mergeInFile(m4file): 27 | bk = open(m4file, 'rt').readlines() 28 | bk2 = [] 29 | i = 0 30 | while i < len(bk): 31 | line = bk[i] 32 | bk2.append(line) 33 | if (line.startswith(MARK_IDENT) and line.strip().endswith(MARK_BEGINS)): 34 | filename = line[len(MARK_IDENT):-len(MARK_BEGINS)-1] 35 | print 'merging %s...' % filename 36 | bk2.append("dnl (Created by merge-scripts.py from %s\n" % filename) 37 | bk2.append("dnl file do not edit here!)\n") 38 | bk2.append("D='$'\n") 39 | bk2.append('cat <%s\n' % filename) 40 | bk2 += mergeFile(filename) 41 | bk2.append('EOF\n') 42 | i += 1 43 | while not (bk[i].startswith(MARK_IDENT) and 44 | bk[i].strip().endswith(MARK_ENDS)): 45 | i += 1 46 | bk2.append(bk[i]) 47 | i += 1 48 | 49 | open('%s~' % m4file, 'wt').writelines(bk) 50 | open(m4file, 'wt').writelines(bk2) 51 | 52 | mergeInFile('bakefile.m4') 53 | mergeInFile('bakefile-dllar.m4') 54 | -------------------------------------------------------------------------------- /testsuite/src/MediatorTest.cpp: -------------------------------------------------------------------------------- 1 | // MediatorTest.cpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if defined(_MSC_VER) 10 | #pragma warning( disable : 4250 ) // Disable: 'class1' : inherits 'class2::member' via dominance 11 | #pragma warning( disable : 4355 ) // The this pointer is valid only within nonstatic member functions. It cannot be used in the initializer list for a base class.ck(16) 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | namespace data 19 | { 20 | struct MediatorTest 21 | { }; 22 | } 23 | 24 | namespace testgroup 25 | { 26 | typedef tut::test_group mediator_test_t; 27 | typedef mediator_test_t::object object ; 28 | mediator_test_t mediator_test("MediatorTest"); 29 | } 30 | 31 | namespace tut 32 | { 33 | using namespace testgroup; 34 | 35 | using PureMVC::Patterns::Mediator; 36 | 37 | template<> template<> 38 | void object::test<1>(void) 39 | { 40 | set_test_name("testNameAccessor"); 41 | 42 | Mediator mediator; 43 | ensure_equals("Expecting mediator.getMediatorName() == Mediator.NAME", mediator.getMediatorName(), Mediator::NAME); 44 | } 45 | 46 | template<> template<> 47 | void object::test<2>(void) 48 | { 49 | set_test_name("testViewAccessor"); 50 | 51 | std::string *str = new std::string(); 52 | Mediator mediator(Mediator::NAME, str); 53 | 54 | ensure( "Expecting mediator.getViewComponent() not null", mediator.getViewComponent() != NULL ); 55 | 56 | delete str; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /include/PureMVC/Interfaces/IAggregate.hpp: -------------------------------------------------------------------------------- 1 | // IAggregate.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_INTERFACES_IAGGREGATE_HPP__) 10 | #define __PUREMVC_INTERFACES_IAGGREGATE_HPP__ 11 | 12 | // STL include 13 | #include 14 | #include 15 | // PureMVC include 16 | #if !defined(__PUREMVC_HPP__) 17 | #define __PUREMVC_INCLUDE__ 18 | #include "../PureMVC.hpp" 19 | #endif /* __PUREMVC_HPP__ */ 20 | 21 | #include "IIterator.hpp" 22 | 23 | namespace PureMVC 24 | { 25 | namespace Interfaces 26 | { 27 | /** 28 | * Interface of aggregate class. 29 | */ 30 | template 31 | struct IAggregate 32 | { 33 | typedef _Type type; 34 | 35 | #if defined(PUREMVC_USES_TR1) 36 | typedef std::unique_ptr > Iterator; 37 | #else 38 | typedef std::auto_ptr > Iterator; 39 | #endif 40 | 41 | /** 42 | * Set item collection from this to iterator. 43 | * 44 | * @param [out] iterator container. 45 | **/ 46 | virtual void setIterator(IIterator<_Type>& iterator) const = 0; 47 | 48 | /** 49 | * Get iterator collection. 50 | * 51 | * @return The auto pointer of iterator. 52 | **/ 53 | virtual Iterator getIterator(void) const = 0; 54 | 55 | /** 56 | * Virtual destructor. 57 | */ 58 | virtual ~IAggregate() { }; 59 | }; 60 | } 61 | } 62 | 63 | #endif /* __PUREMVC_INTERFACES_IAGGREGATE_HPP__ */ 64 | -------------------------------------------------------------------------------- /src/PureMVC/Patterns/Command/MacroCommand.cpp: -------------------------------------------------------------------------------- 1 | // MacroCommand.cpp2 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #include "../../Common.hpp" 10 | 11 | MacroCommand::MacroCommand(void) 12 | : INotifier() 13 | , ICommand() 14 | , Notifier() 15 | { 16 | initializeMacroCommand(); 17 | } 18 | 19 | MacroCommand::MacroCommand(std::list const& command_list) 20 | : INotifier() 21 | , ICommand() 22 | , Notifier() 23 | , _sub_commands(command_list) 24 | { 25 | initializeMacroCommand(); 26 | } 27 | 28 | MacroCommand::MacroCommand(MacroCommand const& arg) 29 | : INotifier() 30 | , ICommand() 31 | , Notifier(arg) 32 | , _sub_commands(arg._sub_commands) 33 | { 34 | initializeMacroCommand(); 35 | } 36 | 37 | inline void MacroCommand::initializeMacroCommand(void) 38 | { } 39 | 40 | inline void MacroCommand::addSubCommand(ICommand* command) 41 | { 42 | if (command == NULL) 43 | return; 44 | _sub_commands.push_back(command); 45 | } 46 | 47 | void MacroCommand::execute(INotification const& notification) 48 | { 49 | CommandList::iterator result = _sub_commands.begin(); 50 | while(result != _sub_commands.end()) 51 | { 52 | (*result)->initializeNotifier(_multiton_key); 53 | (*result)->execute(notification); 54 | 55 | _sub_commands.erase(result); 56 | result = _sub_commands.begin(); 57 | } 58 | } 59 | 60 | MacroCommand& MacroCommand::operator=(MacroCommand const& arg) 61 | { 62 | _multiton_key = arg._multiton_key; 63 | _sub_commands = arg._sub_commands; 64 | return *this; 65 | } 66 | 67 | MacroCommand::~MacroCommand(void) 68 | { } 69 | -------------------------------------------------------------------------------- /include/PureMVC/Interfaces/IIterator.hpp: -------------------------------------------------------------------------------- 1 | // IIterator.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_INTERFACES_IITERATOR_HPP__) 10 | #define __PUREMVC_INTERFACES_IITERATOR_HPP__ 11 | 12 | // PureMVC include 13 | #if !defined(__PUREMVC_HPP__) 14 | #define __PUREMVC_INCLUDE__ 15 | #include "../PureMVC.hpp" 16 | #endif /* __PUREMVC_HPP__ */ 17 | 18 | namespace PureMVC 19 | { 20 | namespace Interfaces 21 | { 22 | /** 23 | * Interface of iterator class 24 | */ 25 | template 26 | struct IIterator 27 | { 28 | typedef _Type type; 29 | 30 | /** 31 | * Gets the current item. 32 | * 33 | * @return The references of current item. 34 | **/ 35 | virtual _Type const& getCurrent(void) const = 0; 36 | 37 | /** 38 | * Gets the current item base on operator. 39 | * 40 | * @return The references of current item. 41 | **/ 42 | virtual _Type const& operator*(void) const = 0; 43 | 44 | /** 45 | * Move to next item. 46 | * 47 | * @return true if it succeeds, false if it fails. 48 | **/ 49 | virtual bool moveNext(void) const = 0; 50 | 51 | /** 52 | * Reset iterator. 53 | **/ 54 | virtual void reset(void) const = 0; 55 | 56 | /** 57 | * Virtual destructor. 58 | */ 59 | virtual ~IIterator(void) { }; 60 | }; 61 | } 62 | } 63 | 64 | #endif /* __PUREMVC_INTERFACES_IITERATOR_HPP__ */ 65 | -------------------------------------------------------------------------------- /autoconf/bk-make-pch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script is part of Bakefile (http://www.bakefile.org) autoconf 4 | # script. It is used to generated precompiled headers. 5 | # 6 | # Permission is given to use this file in any way. 7 | 8 | outfile="${1}" 9 | header="${2}" 10 | shift 11 | shift 12 | 13 | builddir=`echo $outfile | sed -e 's,/\.pch/.*$,,g'` 14 | 15 | compiler="" 16 | headerfile="" 17 | 18 | while test ${#} -gt 0; do 19 | add_to_cmdline=1 20 | case "${1}" in 21 | -I* ) 22 | incdir=`echo ${1} | sed -e 's/-I\(.*\)/\1/g'` 23 | if test "x${headerfile}" = "x" -a -f "${incdir}/${header}" ; then 24 | headerfile="${incdir}/${header}" 25 | fi 26 | ;; 27 | -use-pch|-use_pch|-pch-use ) 28 | shift 29 | add_to_cmdline=0 30 | ;; 31 | esac 32 | if test $add_to_cmdline = 1 ; then 33 | compiler="${compiler} ${1}" 34 | fi 35 | shift 36 | done 37 | 38 | if test "x${headerfile}" = "x" ; then 39 | echo "error: can't find header ${header} in include paths" >&2 40 | else 41 | if test -f ${outfile} ; then 42 | rm -f ${outfile} 43 | else 44 | mkdir -p `dirname ${outfile}` 45 | fi 46 | depsfile="${builddir}/.deps/`echo ${outfile} | tr '/.' '__'`.d" 47 | mkdir -p ${builddir}/.deps 48 | if test "x@GCC_PCH@" = "x1" ; then 49 | # can do this because gcc is >= 3.4: 50 | ${compiler} -o ${outfile} -MMD -MF "${depsfile}" "${headerfile}" 51 | elif test "x@ICC_PCH@" = "x1" ; then 52 | filename=pch_gen-$$ 53 | file=${filename}.c 54 | dfile=${filename}.d 55 | cat > $file < $depsfile && \ 61 | rm -f $file $dfile ${filename}.o 62 | fi 63 | exit ${?} 64 | fi 65 | -------------------------------------------------------------------------------- /src/PureMVC/Patterns/Observer/Notification.cpp: -------------------------------------------------------------------------------- 1 | // Notification.cpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #include "../../Common.hpp" 10 | 11 | Notification::Notification(std::string const& name, 12 | void const* body, 13 | std::string const& type) 14 | : INotification() 15 | , _name(name) 16 | , _body(body) 17 | , _type(type) 18 | { } 19 | 20 | Notification::Notification(Notification const& arg) 21 | : INotification() 22 | , _name(arg._name) 23 | , _body(arg._body) 24 | , _type(arg._type) 25 | { } 26 | 27 | inline std::string const& Notification::getName(void) const 28 | { 29 | return _name; 30 | } 31 | 32 | inline void Notification::setBody(void const* body) 33 | { 34 | _body = body; 35 | } 36 | 37 | inline void const* Notification::getBody(void) const 38 | { 39 | return _body; 40 | } 41 | 42 | inline void Notification::setType(std::string const& type) 43 | { 44 | _type = type; 45 | } 46 | 47 | inline std::string const& Notification::getType(void) const 48 | { 49 | return _type; 50 | } 51 | 52 | inline std::string Notification::toString(void) const 53 | { 54 | std::string msg; 55 | toString(msg); 56 | return msg; 57 | } 58 | 59 | void Notification::toString(std::string& arg) const 60 | { 61 | arg = "Notification Name: "; 62 | arg += getName(); 63 | arg += "\nBody: "; 64 | arg += typeid(_body).name(); 65 | arg += "\nType: "; 66 | arg += _type; 67 | } 68 | 69 | Notification& Notification::operator=(Notification const& arg) 70 | { 71 | _name = arg._name; 72 | _type = arg._type; 73 | _body = arg._body; 74 | return *this; 75 | } 76 | 77 | Notification::~Notification(void) 78 | { } 79 | -------------------------------------------------------------------------------- /include/PureMVC/Interfaces/IProxy.hpp: -------------------------------------------------------------------------------- 1 | // IProxy.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_INTERFACES_IPROXY_HPP__) 10 | #define __PUREMVC_INTERFACES_IPROXY_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | #include "INotifier.hpp" 21 | 22 | namespace PureMVC 23 | { 24 | namespace Interfaces 25 | { 26 | struct PUREMVC_API IProxy : public virtual INotifier 27 | { 28 | /** 29 | * Get the Proxy name 30 | * 31 | * @return the Proxy instance name 32 | */ 33 | virtual std::string const& getProxyName(void) const = 0; 34 | 35 | /** 36 | * Set the data object 37 | * 38 | * @param data the data object 39 | */ 40 | virtual void setData(void const* data) = 0; 41 | 42 | /** 43 | * Get the data object 44 | * 45 | * @return the data as type void* 46 | */ 47 | virtual void const* getData(void) const = 0; 48 | 49 | /** 50 | * Called by the Model when the Proxy is registered 51 | */ 52 | virtual void onRegister(void) = 0; 53 | 54 | /** 55 | * Called by the Model when the Proxy is removed 56 | */ 57 | virtual void onRemove(void) = 0; 58 | 59 | /** 60 | * Virtual destructor. 61 | */ 62 | virtual ~IProxy(void); 63 | }; 64 | } 65 | } 66 | 67 | #endif /* __PUREMVC_INTERFACES_IPROXY_HPP__ */ 68 | -------------------------------------------------------------------------------- /testsuite/src/FacadeTestInheritance.hpp: -------------------------------------------------------------------------------- 1 | // FacadeTestInheritance.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__FACADE_TEST_HERITANCE_HPP__) 10 | #define __FACADE_TEST_HERITANCE_HPP__ 11 | 12 | #include 13 | 14 | namespace data 15 | { 16 | using PureMVC::Interfaces::IFacade; 17 | using PureMVC::Patterns::Facade; 18 | 19 | class FacadeTestInheritance 20 | : public virtual IFacade 21 | , public Facade 22 | { 23 | friend class Facade; 24 | public: 25 | std::string* initializeNotifierCalled; 26 | std::string* initializeFacadeCalled; 27 | protected: 28 | FacadeTestInheritance(void) 29 | :Facade(this, "FacadeTestInheritance") 30 | { } 31 | public: 32 | static FacadeTestInheritance& getInstance(void) 33 | { 34 | if (Facade::hasCore("FacadeTestInheritance")) 35 | { 36 | return *(dynamic_cast(&Facade::getInstance("FacadeTestInheritance"))); 37 | } 38 | return *(new FacadeTestInheritance()); 39 | } 40 | protected: 41 | void initializeNotifier(std::string const& key) 42 | { 43 | initializeNotifierCalled = new std::string("Called!!!"); 44 | Facade::initializeNotifier(key); 45 | } 46 | 47 | void initializeFacade(void) 48 | { 49 | initializeFacadeCalled = new std::string("Called!!!"); 50 | Facade::initializeFacade(); 51 | } 52 | ~FacadeTestInheritance() 53 | { 54 | delete initializeNotifierCalled; 55 | delete initializeFacadeCalled; 56 | } 57 | }; 58 | } 59 | 60 | #endif /* __FACADE_TEST_HERITANCE_HPP__ */ 61 | -------------------------------------------------------------------------------- /src/PureMVC/Patterns/Mediator/Mediator.cpp: -------------------------------------------------------------------------------- 1 | // Mediator.cpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #include "../../Common.hpp" 10 | 11 | char const* const Mediator::NAME = "Mediator"; 12 | 13 | Mediator::Mediator(std::string const& mediator_name, 14 | void const* view_component) 15 | : INotifier() 16 | , IMediator() 17 | , Notifier() 18 | , _mediator_name(mediator_name) 19 | , _view_component(view_component) 20 | { } 21 | 22 | Mediator::Mediator(Mediator const& arg) 23 | : INotifier() 24 | , IMediator() 25 | , Notifier(arg) 26 | , _mediator_name(arg._mediator_name) 27 | , _view_component(arg._view_component) 28 | { } 29 | 30 | inline std::string const& Mediator::getMediatorName(void) const 31 | { 32 | return _mediator_name; 33 | } 34 | 35 | inline void Mediator::setViewComponent(void const* view_component) 36 | { 37 | _view_component = view_component; 38 | } 39 | 40 | inline void const* Mediator::getViewComponent(void) const 41 | { 42 | return _view_component; 43 | } 44 | 45 | inline Mediator::NotificationNames Mediator::listNotificationInterests(void) const 46 | { 47 | typedef std::list list_t; 48 | typedef StdContainerAggregate result_t; 49 | return NotificationNames(new result_t); 50 | } 51 | 52 | inline void Mediator::handleNotification(INotification const& notification) 53 | { 54 | (void)notification; 55 | } 56 | 57 | inline void Mediator::onRegister(void) 58 | { } 59 | 60 | inline void Mediator::onRemove(void) 61 | { } 62 | 63 | Mediator& Mediator::operator=(Mediator const& arg) 64 | { 65 | _mediator_name = arg._mediator_name; 66 | _view_component = arg._view_component; 67 | return *this; 68 | } 69 | 70 | Mediator::~Mediator(void) 71 | { } 72 | -------------------------------------------------------------------------------- /testsuite/src/ViewTestNote.hpp: -------------------------------------------------------------------------------- 1 | // ViewTestNote.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__VIEW_TEST_NOTE_HPP__) 10 | #define __VIEW_TEST_NOTE_HPP__ 11 | 12 | #include 13 | #include 14 | 15 | namespace data 16 | { 17 | using PureMVC::Interfaces::INotification; 18 | using PureMVC::Patterns::Notification; 19 | /** 20 | * A Notification class used by ViewTest. 21 | * 22 | * @see org.puremvc.as3.multicore.core.view.ViewTest ViewTest 23 | */ 24 | struct ViewTestNote : public Notification 25 | { 26 | /** 27 | * The name of this Notification. 28 | */ 29 | static char const* const NAME; 30 | /** 31 | * Constructor. 32 | * 33 | * @param name Ignored and forced to NAME. 34 | * @param body the body of the Notification to be constructed. 35 | */ 36 | ViewTestNote(std::string const& name, void const* body) 37 | :Notification(name, body) 38 | { } 39 | 40 | /** 41 | * Factory method. 42 | * 43 | *

44 | * This method creates new instances of the ViewTestNote class, 45 | * automatically setting the note name so you don't have to. Use 46 | * this as an alternative to the constructor.

47 | * 48 | * @param name the name of the Notification to be constructed. 49 | * @param body the body of the Notification to be constructed. 50 | */ 51 | static INotification* create(std::string const& name, void const* body ) 52 | { 53 | return new data::ViewTestNote(name, body); 54 | } 55 | }; 56 | char const* const ViewTestNote::NAME = "ViewTestNote"; 57 | } 58 | 59 | #endif /* __VIEW_TEST_NOTE_HPP__ */ 60 | -------------------------------------------------------------------------------- /testsuite/src/ViewTestMediator3.hpp: -------------------------------------------------------------------------------- 1 | // ViewTestMediator3.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__VIEW_TEST_MEDIATOR3_HPP__) 10 | #define __VIEW_TEST_MEDIATOR3_HPP__ 11 | 12 | #include 13 | #include 14 | #include "ViewTest.hpp" 15 | 16 | namespace data 17 | { 18 | using PureMVC::Patterns::Mediator; 19 | /** 20 | * A Mediator class used by ViewTest. 21 | */ 22 | struct ViewTestMediator3 : public Mediator 23 | { 24 | /** 25 | * The Mediator name 26 | */ 27 | static char const* const NAME; 28 | 29 | /** 30 | * Constructor 31 | */ 32 | ViewTestMediator3(const void* view) 33 | :Mediator(NAME, view) 34 | { } 35 | 36 | virtual NotificationNames listNotificationInterests(void) const 37 | { 38 | // be sure that the mediator has some Observers created 39 | // in order to test removeMediator 40 | typedef StdContainerAggregate > result_t; 41 | result_t* result = new result_t; 42 | result->get().push_back(ViewTest::NOTE3); 43 | return NotificationNames(result); 44 | } 45 | 46 | virtual void handleNotification(INotification const& notification) 47 | { 48 | viewTest()->lastNotification = notification.getName(); 49 | } 50 | 51 | ViewTest const* viewTest(void) const 52 | { 53 | return (ViewTest*)_view_component; 54 | } 55 | 56 | ViewTest* viewTest(void) 57 | { 58 | return (ViewTest*)_view_component; 59 | } 60 | }; 61 | char const* const ViewTestMediator3::NAME = "ViewTestMediator3"; 62 | } 63 | 64 | #endif /* __VIEW_TEST_MEDIATOR3_HPP__ */ 65 | -------------------------------------------------------------------------------- /testsuite/src/ViewTestMediator5.hpp: -------------------------------------------------------------------------------- 1 | // ViewTestMediator5.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__VIEW_TEST_MEDIATOR5_HPP__) 10 | #define __VIEW_TEST_MEDIATOR5_HPP__ 11 | 12 | #include 13 | #include 14 | #include "ViewTest.hpp" 15 | 16 | namespace data 17 | { 18 | using PureMVC::Patterns::Mediator; 19 | /** 20 | * A Mediator class used by ViewTest. 21 | */ 22 | struct ViewTestMediator5 : public Mediator 23 | { 24 | /** 25 | * The Mediator name 26 | */ 27 | static char const* const NAME; 28 | 29 | /** 30 | * Constructor 31 | */ 32 | ViewTestMediator5(const void* view) 33 | :Mediator(NAME, view) 34 | { } 35 | 36 | virtual NotificationNames listNotificationInterests(void) const 37 | { 38 | // be sure that the mediator has some Observers created 39 | // in order to test removeMediator 40 | typedef StdContainerAggregate > result_t; 41 | result_t* result = new result_t; 42 | result->get().push_back(ViewTest::NOTE5); 43 | return NotificationNames(result); 44 | } 45 | 46 | virtual void handleNotification(INotification const& notification) 47 | { 48 | (void)notification; 49 | viewTest()->counter++; 50 | } 51 | 52 | ViewTest const* viewTest(void) const 53 | { 54 | return (ViewTest*)_view_component; 55 | } 56 | 57 | ViewTest* viewTest(void) 58 | { 59 | return (ViewTest*)_view_component; 60 | } 61 | }; 62 | char const* const ViewTestMediator5::NAME = "ViewTestMediator5"; 63 | } 64 | 65 | #endif /* __VIEW_TEST_MEDIATOR5_HPP__ */ 66 | -------------------------------------------------------------------------------- /testsuite/src/ViewTestMediator2.hpp: -------------------------------------------------------------------------------- 1 | // ViewTestMediator2.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__VIEW_TEST_MEDIATOR2_HPP__) 10 | #define __VIEW_TEST_MEDIATOR2_HPP__ 11 | 12 | #include 13 | #include 14 | #include "ViewTest.hpp" 15 | 16 | namespace data 17 | { 18 | using PureMVC::Patterns::Mediator; 19 | /** 20 | * A Mediator class used by ViewTest. 21 | */ 22 | struct ViewTestMediator2 : public Mediator 23 | { 24 | /** 25 | * The Mediator name 26 | */ 27 | static char const* const NAME; 28 | 29 | /** 30 | * Constructor 31 | */ 32 | ViewTestMediator2(const void* view) 33 | :Mediator(NAME, view) 34 | { } 35 | 36 | virtual NotificationNames listNotificationInterests(void) const 37 | { 38 | // be sure that the mediator has some Observers created 39 | // in order to test removeMediator 40 | typedef StdContainerAggregate > result_t; 41 | result_t* result = new result_t; 42 | result->get().push_back(ViewTest::NOTE1); 43 | result->get().push_back(ViewTest::NOTE2); 44 | return NotificationNames(result); 45 | } 46 | 47 | virtual void handleNotification(INotification const& notification) 48 | { 49 | viewTest()->lastNotification = notification.getName(); 50 | } 51 | 52 | ViewTest const* viewTest(void) const 53 | { 54 | return (ViewTest*)_view_component; 55 | } 56 | 57 | ViewTest* viewTest(void) 58 | { 59 | return (ViewTest*)_view_component; 60 | } 61 | }; 62 | char const* const ViewTestMediator2::NAME = "ViewTestMediator2"; 63 | } 64 | 65 | #endif /* __VIEW_TEST_MEDIATOR2_HPP__ */ 66 | -------------------------------------------------------------------------------- /testsuite/src/SimpleCommandTestFirstCommand.hpp: -------------------------------------------------------------------------------- 1 | // SimpleCommandTestCommand.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__SIMPLE_COMMAND_TEST_FIRST_COMMAND_HPP__) 10 | #define __SIMPLE_COMMAND_TEST_FIRST_COMMAND_HPP__ 11 | 12 | #include 13 | #include "SimpleCommandTestVO.hpp" 14 | #include "SimpleCommandTestSecondCommand.hpp" 15 | 16 | namespace data 17 | { 18 | using PureMVC::Patterns::SimpleCommand; 19 | using PureMVC::Interfaces::INotification; 20 | /** 21 | * A SimpleCommandTestFirstCommand subclass used by SimpleCommandTest. 22 | */ 23 | struct SimpleCommandTestFirstCommand: SimpleCommand 24 | { 25 | 26 | /** 27 | * Constructor. 28 | */ 29 | SimpleCommandTestFirstCommand() 30 | :SimpleCommand() 31 | { } 32 | 33 | /** 34 | * It just register SimpleCommandTestSecondCommand 35 | * 36 | * @param event the INotification carrying the SimpleCommandTestVO 37 | */ 38 | virtual void execute(INotification const& note) 39 | { 40 | // Combine test. Remove itself. 41 | getFacade().removeCommand("simpleCommandTestFirstCommand"); 42 | 43 | // Send itself again. 44 | sendNotification("simpleCommandTestFirstCommand", note.getBody(), note.getType()); 45 | 46 | SimpleCommandTestVO& vo= *(SimpleCommandTestVO*)note.getBody(); 47 | // Fabricate a result 48 | vo.result += 2 * vo.input; 49 | 50 | // Register second command. 51 | static SimpleCommandTestSecondCommand command; 52 | getFacade().registerCommand("simpleCommandTestSecondCommand", &command); 53 | 54 | // Then sending notification. 55 | sendNotification("simpleCommandTestSecondCommand", note.getBody(), note.getType()); 56 | } 57 | }; 58 | } 59 | 60 | #endif /* __SIMPLE_COMMAND_TEST_FIRST_COMMAND_HPP__ */ 61 | -------------------------------------------------------------------------------- /include/PureMVC/Patterns/Command/SimpleCommand.hpp: -------------------------------------------------------------------------------- 1 | // SimpleCommand.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_PATTERNS_COMMAND_SIMPLE_COMMAND_HPP__) 10 | #define __PUREMVC_PATTERNS_COMMAND_SIMPLE_COMMAND_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | #include "../../Interfaces/ICommand.hpp" 21 | #include "../Observer/Notifier.hpp" 22 | 23 | namespace PureMVC 24 | { 25 | namespace Patterns 26 | { 27 | using Interfaces::ICommand; 28 | using Interfaces::INotifier; 29 | 30 | class PUREMVC_API SimpleCommand 31 | : public virtual ICommand 32 | , public virtual INotifier 33 | , public Notifier 34 | { 35 | public: 36 | /** 37 | * Constructor. 38 | */ 39 | explicit SimpleCommand(void); 40 | 41 | /** 42 | * Copy constructor. 43 | */ 44 | explicit SimpleCommand(SimpleCommand const& arg); 45 | 46 | public: 47 | /** 48 | * Fulfill the use-case initiated by the given INotification. 49 | * 50 | *

51 | * In the Command Pattern, an application use-case typically 52 | * begins with some user action, which results in an INotification being broadcast, which 53 | * is handled by business logic in the execute method of an 54 | * ICommand.

55 | * 56 | * @param notification the INotification to handle. 57 | */ 58 | virtual void execute(INotification const& notification); 59 | 60 | /** 61 | * Copy operator. 62 | */ 63 | SimpleCommand& operator=(SimpleCommand const& arg); 64 | 65 | /** 66 | * Virtual destructor. 67 | */ 68 | virtual ~SimpleCommand(void); 69 | }; 70 | } 71 | } 72 | 73 | #endif /* __PUREMVC_PATTERNS_COMMAND_SIMPLE_COMMAND_HPP__ */ 74 | -------------------------------------------------------------------------------- /testsuite/src/ViewTestMediator6.hpp: -------------------------------------------------------------------------------- 1 | // ViewTestMediator6.hpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__VIEW_TEST_MEDIATOR6_HPP__) 10 | #define __VIEW_TEST_MEDIATOR6_HPP__ 11 | 12 | #include 13 | #include 14 | #include "ViewTest.hpp" 15 | 16 | namespace data 17 | { 18 | using PureMVC::Interfaces::INotification; 19 | using PureMVC::Interfaces::IView; 20 | using PureMVC::Patterns::Mediator; 21 | using PureMVC::Core::View; 22 | /** 23 | * A Mediator class used by ViewTest. 24 | */ 25 | struct ViewTestMediator6 : public Mediator 26 | { 27 | /** 28 | * The Mediator base name 29 | */ 30 | static char const* const NAME; 31 | 32 | /** 33 | * Constructor 34 | */ 35 | ViewTestMediator6(std::string const& name, const void* view) 36 | :Mediator(name, view) 37 | { } 38 | 39 | virtual NotificationNames listNotificationInterests(void) const 40 | { 41 | // be sure that the mediator has some Observers created 42 | // in order to test removeMediator 43 | typedef StdContainerAggregate > result_t; 44 | result_t* result = new result_t; 45 | result->get().push_back(ViewTest::NOTE6); 46 | return NotificationNames(result); 47 | } 48 | 49 | virtual void handleNotification(INotification const& notification) 50 | { 51 | (void)notification; 52 | IView& view = View::getInstance("ViewTestKey11"); 53 | // Now supporting remove observer in list during loop 54 | view.removeMediator(getMediatorName()); 55 | } 56 | 57 | void onRemove(void) 58 | { 59 | viewTest()->counter++; 60 | } 61 | 62 | ViewTest const* viewTest(void) const 63 | { 64 | return (ViewTest*)_view_component; 65 | } 66 | 67 | ViewTest* viewTest(void) 68 | { 69 | return (ViewTest*)_view_component; 70 | } 71 | }; 72 | char const* const ViewTestMediator6::NAME = "ViewTestMediator6"; 73 | } 74 | 75 | #endif /* __VIEW_TEST_MEDIATOR6_HPP__ */ 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## [PureMVC](http://puremvc.github.com/) C++ MultiCore Framework 2 | PureMVC is a lightweight framework for creating applications based upon the classic [Model-View-Controller](http://en.wikipedia.org/wiki/Model-view-controller) design meta-pattern. This is a C++ port of the [AS3 reference implementation of the MultiCore Version](https://github.com/PureMVC/puremvc-as3-multicore-framework/wiki). It supports [modular programming](http://en.wikipedia.org/wiki/Modular_programming) through the use of [Multiton](http://en.wikipedia.org/wiki/Multiton) Core actors. 3 | 4 | * [API Docs](http://puremvc.org/pages/docs/CPP/multicore) 5 | * [Discussion](http://forums.puremvc.org/index.php?board=104.0) 6 | * [Overview Presentation](http://puremvc.tv/#P002) 7 | 8 | 9 | ## Status 10 | Production - [Version 1.0](https://github.com/PureMVC/puremvc-cpp-multicore-framework/blob/master/VERSION) 11 | 12 | ## Platforms / Technologies 13 | * [C++](http://en.wikipedia.org/wiki/C%2B%2B) 14 | 15 | ## License 16 | * PureMVC MultiCore Framework for C++ (Ported) - Copyright © 2012 Tang Khai Phuong 17 | * PureMVC - Copyright © 2007-2012 Futurescale, Inc. 18 | * All rights reserved. 19 | 20 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 21 | 22 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 23 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 24 | * Neither the name of Futurescale, Inc., PureMVC.org, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /autoconf/shared-ld-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #----------------------------------------------------------------------------- 3 | #-- Name: distrib/mac/shared-ld-sh 4 | #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X 5 | #-- Author: Gilles Depeyrot 6 | #-- Copyright: (c) 2002 Gilles Depeyrot 7 | #-- Licence: any use permitted 8 | #----------------------------------------------------------------------------- 9 | 10 | verbose=0 11 | args="" 12 | objects="" 13 | linking_flag="-dynamiclib" 14 | ldargs="-r -keep_private_externs -nostdlib" 15 | 16 | if test "x$CXX" = "x"; then 17 | CXX="c++" 18 | fi 19 | 20 | while test $# -gt 0; do 21 | case $1 in 22 | 23 | -v) 24 | verbose=1 25 | ;; 26 | 27 | -o|-compatibility_version|-current_version|-framework|-undefined|-install_name) 28 | # collect these options and values 29 | args="${args} $1 $2" 30 | shift 31 | ;; 32 | 33 | -arch|-isysroot) 34 | # collect these options and values 35 | ldargs="${ldargs} $1 $2" 36 | shift 37 | ;; 38 | 39 | -s|-Wl,*) 40 | # collect these load args 41 | ldargs="${ldargs} $1" 42 | ;; 43 | 44 | -l*|-L*|-flat_namespace|-headerpad_max_install_names) 45 | # collect these options 46 | args="${args} $1" 47 | ;; 48 | 49 | -dynamiclib|-bundle) 50 | linking_flag="$1" 51 | ;; 52 | 53 | -*) 54 | echo "shared-ld: unhandled option '$1'" 55 | exit 1 56 | ;; 57 | 58 | *.o | *.a | *.dylib) 59 | # collect object files 60 | objects="${objects} $1" 61 | ;; 62 | 63 | *) 64 | echo "shared-ld: unhandled argument '$1'" 65 | exit 1 66 | ;; 67 | 68 | esac 69 | shift 70 | done 71 | 72 | status=0 73 | 74 | # 75 | # Link one module containing all the others 76 | # 77 | if test ${verbose} = 1; then 78 | echo "$CXX ${ldargs} ${objects} -o master.$$.o" 79 | fi 80 | $CXX ${ldargs} ${objects} -o master.$$.o 81 | status=$? 82 | 83 | # 84 | # Link the shared library from the single module created, but only if the 85 | # previous command didn't fail: 86 | # 87 | if test ${status} = 0; then 88 | if test ${verbose} = 1; then 89 | echo "$CXX ${linking_flag} master.$$.o ${args}" 90 | fi 91 | $CXX ${linking_flag} master.$$.o ${args} 92 | status=$? 93 | fi 94 | 95 | # 96 | # Remove intermediate module 97 | # 98 | rm -f master.$$.o 99 | 100 | exit $status 101 | -------------------------------------------------------------------------------- /PureMVC.vs2008.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PureMVC", "PureMVC.vs2008.vcproj", "{8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite.vs2008.vcproj", "{A0E5F375-EE50-414B-A083-C879493B47B3}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50} = {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50} 9 | EndProjectSection 10 | EndProject 11 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{25325B79-2612-4E4A-9BAB-49406161F2A5}" 12 | ProjectSection(SolutionItems) = preProject 13 | license.txt = license.txt 14 | version.txt = version.txt 15 | EndProjectSection 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug Share|Win32 = Debug Share|Win32 20 | Debug Static|Win32 = Debug Static|Win32 21 | Release Share|Win32 = Release Share|Win32 22 | Release Static|Win32 = Release Static|Win32 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Debug Share|Win32.ActiveCfg = Debug Share|Win32 26 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Debug Share|Win32.Build.0 = Debug Share|Win32 27 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 28 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Debug Static|Win32.Build.0 = Debug Static|Win32 29 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Release Share|Win32.ActiveCfg = Release Share|Win32 30 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Release Share|Win32.Build.0 = Release Share|Win32 31 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Release Static|Win32.ActiveCfg = Release Static|Win32 32 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Release Static|Win32.Build.0 = Release Static|Win32 33 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Debug Share|Win32.ActiveCfg = Debug Share|Win32 34 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Debug Share|Win32.Build.0 = Debug Share|Win32 35 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 36 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Debug Static|Win32.Build.0 = Debug Static|Win32 37 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Release Share|Win32.ActiveCfg = Release Share|Win32 38 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Release Share|Win32.Build.0 = Release Share|Win32 39 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Release Static|Win32.ActiveCfg = Release Static|Win32 40 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Release Static|Win32.Build.0 = Release Static|Win32 41 | EndGlobalSection 42 | GlobalSection(SolutionProperties) = preSolution 43 | HideSolutionNode = FALSE 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /PureMVC.vs2010.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{25325B79-2612-4E4A-9BAB-49406161F2A5}" 5 | ProjectSection(SolutionItems) = preProject 6 | license.txt = license.txt 7 | version.txt = version.txt 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PureMVC", "PureMVC.vs2010.vcxproj", "{8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite.vs2010.vcxproj", "{A0E5F375-EE50-414B-A083-C879493B47B3}" 13 | ProjectSection(ProjectDependencies) = postProject 14 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50} = {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50} 15 | EndProjectSection 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug Share|Win32 = Debug Share|Win32 20 | Debug Static|Win32 = Debug Static|Win32 21 | Release Share|Win32 = Release Share|Win32 22 | Release Static|Win32 = Release Static|Win32 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Debug Share|Win32.ActiveCfg = Debug Share|Win32 26 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Debug Share|Win32.Build.0 = Debug Share|Win32 27 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 28 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Debug Static|Win32.Build.0 = Debug Static|Win32 29 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Release Share|Win32.ActiveCfg = Release Share|Win32 30 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Release Share|Win32.Build.0 = Release Share|Win32 31 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Release Static|Win32.ActiveCfg = Release Static|Win32 32 | {8E6DD691-B2F0-4567-8A4D-92DFDE03CB50}.Release Static|Win32.Build.0 = Release Static|Win32 33 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Debug Share|Win32.ActiveCfg = Debug Share|Win32 34 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Debug Share|Win32.Build.0 = Debug Share|Win32 35 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 36 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Debug Static|Win32.Build.0 = Debug Static|Win32 37 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Release Share|Win32.ActiveCfg = Release Share|Win32 38 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Release Share|Win32.Build.0 = Release Share|Win32 39 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Release Static|Win32.ActiveCfg = Release Static|Win32 40 | {A0E5F375-EE50-414B-A083-C879493B47B3}.Release Static|Win32.Build.0 = Release Static|Win32 41 | EndGlobalSection 42 | GlobalSection(SolutionProperties) = preSolution 43 | HideSolutionNode = FALSE 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /bakefile-intel-format-support/output/intelw.empy: -------------------------------------------------------------------------------- 1 | @# 2 | @# This file is part of Bakefile (http://www.bakefile.org) 3 | @# 4 | @# Copyright (C) 2003-2007 Vaclav Slavik 5 | @# Support for Intel C++ on Windows by Phuong Tang - tangkhaiphuong@gmail.com 6 | @# 7 | @# Permission is hereby granted, free of charge, to any person obtaining a 8 | @# copy of this software and associated documentation files (the "Software"), 9 | @# to deal in the Software without restriction, including without limitation 10 | @# the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | @# and/or sell copies of the Software, and to permit persons to whom the 12 | @# Software is furnished to do so, subject to the following conditions: 13 | @# 14 | @# The above copyright notice and this permission notice shall be included in 15 | @# all copies or substantial portions of the Software. 16 | @# 17 | @# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | @# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | @# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | @# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | @# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | @# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | @# DEALINGS IN THE SOFTWARE. 24 | @# 25 | @# $Id: msvc.empy 1020 2007-03-05 13:52:29Z vaclavslavik $ 26 | @# 27 | @empy.include(os.path.join(RULESDIR, '_hdr_makefile.empy')) 28 | @[if OPTIONS_FILE != '']!include <@OPTIONS_FILE> 29 | @[end if]@ 30 | @[if OPTIONS_FILE == '']@ 31 | @empy.include(os.path.join(RULESDIR, 'watcom-opts.empy')) 32 | @[end if]@ 33 | 34 | # ------------------------------------------------------------------------- 35 | # Do not modify the rest of this file! 36 | # ------------------------------------------------------------------------- 37 | 38 | ### Variables: ### 39 | 40 | @[for v in make_vars]@ 41 | @utils.wrapLongLine('%s = ' % v.name, v.value, ' \\', variable=v.name) 42 | @[end for]@ 43 | 44 | ### Conditionally set variables: ### 45 | 46 | @[for c in cond_vars]@ 47 | @[for v in c.values]@ 48 | !if @utils.condition2string(v.cond, utils.CONDSTR_MSVC) 49 | @utils.wrapLongLine('%s = ' % c.name, v.value, ' \\', variable=c.name) 50 | !endif 51 | @[end for]@ 52 | @[end for]@ 53 | 54 | @[if BUILDDIR != '.'] 55 | all: @BUILDDIR 56 | @BUILDDIR: 57 | @\t-if not exist @BUILDDIR mkdir @BUILDDIR 58 | @[end if]@ 59 | 60 | ### Targets: ### 61 | @[for t in targets] 62 | @[if t.cond != None]@ 63 | !if @utils.condition2string(t.cond, utils.CONDSTR_MSVC) 64 | @[end if]@ 65 | @t.__targetdir@t.__targetname: @t.__deps 66 | @[for cmd in t.__command.splitlines()]@ 67 | @(cmd.strip()[:2]=='<<' ? '<<' : '\t'+cmd.strip()) 68 | @[end for]@ 69 | @[if t.cond != None]@ 70 | !endif 71 | @[end if]@ 72 | @[end for]@ 73 | 74 | @[for f in fragments] 75 | @f.content 76 | @[end for]@ 77 | -------------------------------------------------------------------------------- /testsuite/include/tut/tut_result.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TUT_RESULT_H_GUARD 2 | #define TUT_RESULT_H_GUARD 3 | 4 | #include 5 | 6 | namespace tut 7 | { 8 | 9 | #if defined(TUT_USE_POSIX) 10 | struct test_result_posix 11 | { 12 | test_result_posix() 13 | : pid(getpid()) 14 | { 15 | } 16 | 17 | pid_t pid; 18 | }; 19 | #else 20 | struct test_result_posix 21 | { 22 | }; 23 | #endif 24 | 25 | /** 26 | * Return type of runned test/test group. 27 | * 28 | * For test: contains result of test and, possible, message 29 | * for failure or exception. 30 | */ 31 | struct test_result : public test_result_posix 32 | { 33 | /** 34 | * Test group name. 35 | */ 36 | std::string group; 37 | 38 | /** 39 | * Test number in group. 40 | */ 41 | int test; 42 | 43 | /** 44 | * Test name (optional) 45 | */ 46 | std::string name; 47 | 48 | /** 49 | * ok - test finished successfully 50 | * fail - test failed with ensure() or fail() methods 51 | * ex - test throwed an exceptions 52 | * warn - test finished successfully, but test destructor throwed 53 | * term - test forced test application to terminate abnormally 54 | */ 55 | enum result_type 56 | { 57 | ok, 58 | fail, 59 | ex, 60 | warn, 61 | term, 62 | ex_ctor, 63 | rethrown, 64 | dummy 65 | }; 66 | 67 | result_type result; 68 | 69 | /** 70 | * Exception message for failed test. 71 | */ 72 | std::string message; 73 | std::string exception_typeid; 74 | 75 | /** 76 | * Default constructor. 77 | */ 78 | test_result() 79 | : test(0), 80 | result(ok) 81 | { 82 | } 83 | 84 | /** 85 | * Constructor. 86 | */ 87 | test_result(const std::string& grp, int pos, 88 | const std::string& test_name, result_type res) 89 | : group(grp), 90 | test(pos), 91 | name(test_name), 92 | result(res) 93 | { 94 | } 95 | 96 | /** 97 | * Constructor with exception. 98 | */ 99 | test_result(const std::string& grp,int pos, 100 | const std::string& test_name, result_type res, 101 | const std::exception& ex) 102 | : group(grp), 103 | test(pos), 104 | name(test_name), 105 | result(res), 106 | message(ex.what()), 107 | exception_typeid(typeid(ex).name()) 108 | { 109 | } 110 | 111 | /** Constructor with typeid. 112 | */ 113 | test_result(const std::string& grp,int pos, 114 | const std::string& test_name, result_type res, 115 | const std::string& ex_typeid, 116 | const std::string& msg) 117 | : group(grp), 118 | test(pos), 119 | name(test_name), 120 | result(res), 121 | message(msg), 122 | exception_typeid(ex_typeid) 123 | { 124 | } 125 | }; 126 | 127 | } 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /testsuite/src/ProxyTest.cpp: -------------------------------------------------------------------------------- 1 | // ProxyTest.cpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if defined(_MSC_VER) 10 | #pragma warning( disable : 4250 ) // Disable: 'class1' : inherits 'class2::member' via dominance 11 | #pragma warning( disable : 4355 ) // The this pointer is valid only within nonstatic member functions. It cannot be used in the initializer list for a base class.ck(16) 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | namespace data 19 | { 20 | struct ProxyTest 21 | { }; 22 | } 23 | 24 | namespace testgroup 25 | { 26 | typedef tut::test_group proxy_test_t; 27 | typedef proxy_test_t::object object; 28 | proxy_test_t proxy_test("ProxyTest"); 29 | } 30 | 31 | namespace tut 32 | { 33 | using namespace testgroup; 34 | using PureMVC::Patterns::Proxy; 35 | 36 | template<> template<> 37 | void object::test<1>(void) 38 | { 39 | set_test_name("testNameAccessor"); 40 | 41 | Proxy proxy("TestProxy"); 42 | 43 | ensure_equals( "Expecting proxy.getProxyName() == 'TestProxy'", proxy.getProxyName(), "TestProxy" ); 44 | } 45 | 46 | template<> template<> 47 | void object::test<2>(void) 48 | { 49 | set_test_name("testDataAccessors"); 50 | 51 | Proxy proxy("colors"); 52 | std::vector* data = new std::vector(); 53 | data->push_back("red"); 54 | data->push_back("green"); 55 | data->push_back("blue"); 56 | proxy.setData(data); 57 | 58 | data = (std::vector*)proxy.getData(); 59 | 60 | ensure_equals( "Expecting data.length == 3", data->size(), 3 ); 61 | ensure_equals( "Expecting data[0] == 'red'", (*data)[0], "red" ); 62 | ensure_equals( "Expecting data[1] == 'green'", (*data)[1], "green" ); 63 | ensure_equals( "Expecting data[2] == 'blue'", (*data)[2], "blue" ); 64 | delete data; 65 | proxy.setData(NULL); 66 | } 67 | 68 | template<> template<> 69 | void object::test<4>(void) 70 | { 71 | set_test_name("testConstructor"); 72 | 73 | std::vector* data = new std::vector(); 74 | data->push_back("red"); 75 | data->push_back("green"); 76 | data->push_back("blue"); 77 | Proxy* proxy = new Proxy("colors", data); 78 | 79 | data = (std::vector*)proxy->getData(); 80 | 81 | ensure("Expecting proxy not null", proxy != NULL); 82 | ensure_equals( "Expecting proxy.getProxyName() == 'colors'", proxy->getProxyName(), "colors"); 83 | ensure_equals( "Expecting data.length == 3", data->size(), 3 ); 84 | ensure_equals( "Expecting data[0] == 'red'", (*data)[0], "red" ); 85 | ensure_equals( "Expecting data[1] == 'green'", (*data)[1], "green" ); 86 | ensure_equals( "Expecting data[2] == 'blue'", (*data)[2], "blue" ); 87 | 88 | delete proxy; 89 | delete data; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /testsuite/include/tut/tut_exception.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TUT_EXCEPTION_H_GUARD 2 | #define TUT_EXCEPTION_H_GUARD 3 | 4 | #include 5 | #include "tut_result.hpp" 6 | 7 | namespace tut 8 | { 9 | 10 | /** 11 | * The base for all TUT exceptions. 12 | */ 13 | struct tut_error : public std::exception 14 | { 15 | tut_error(const std::string& msg) 16 | : err_msg(msg) 17 | { 18 | } 19 | 20 | virtual test_result::result_type result() const 21 | { 22 | return test_result::ex; 23 | } 24 | 25 | const char* what() const throw() 26 | { 27 | return err_msg.c_str(); 28 | } 29 | 30 | ~tut_error() throw() 31 | { 32 | } 33 | 34 | private: 35 | 36 | std::string err_msg; 37 | }; 38 | 39 | /** 40 | * Group not found exception. 41 | */ 42 | struct no_such_group : public tut_error 43 | { 44 | no_such_group(const std::string& grp) 45 | : tut_error(grp) 46 | { 47 | } 48 | 49 | ~no_such_group() throw() 50 | { 51 | } 52 | }; 53 | 54 | /** 55 | * Internal exception to be throwed when 56 | * test constructor has failed. 57 | */ 58 | struct bad_ctor : public tut_error 59 | { 60 | bad_ctor(const std::string& msg) 61 | : tut_error(msg) 62 | { 63 | } 64 | 65 | test_result::result_type result() const 66 | { 67 | return test_result::ex_ctor; 68 | } 69 | 70 | ~bad_ctor() throw() 71 | { 72 | } 73 | }; 74 | 75 | /** 76 | * Exception to be throwed when ensure() fails or fail() called. 77 | */ 78 | struct failure : public tut_error 79 | { 80 | failure(const std::string& msg) 81 | : tut_error(msg) 82 | { 83 | } 84 | 85 | test_result::result_type result() const 86 | { 87 | return test_result::fail; 88 | } 89 | 90 | ~failure() throw() 91 | { 92 | } 93 | }; 94 | 95 | /** 96 | * Exception to be throwed when test desctructor throwed an exception. 97 | */ 98 | struct warning : public tut_error 99 | { 100 | warning(const std::string& msg) 101 | : tut_error(msg) 102 | { 103 | } 104 | 105 | test_result::result_type result() const 106 | { 107 | return test_result::warn; 108 | } 109 | 110 | ~warning() throw() 111 | { 112 | } 113 | }; 114 | 115 | /** 116 | * Exception to be throwed when test issued SEH (Win32) 117 | */ 118 | struct seh : public tut_error 119 | { 120 | seh(const std::string& msg) 121 | : tut_error(msg) 122 | { 123 | } 124 | 125 | virtual test_result::result_type result() const 126 | { 127 | return test_result::term; 128 | } 129 | 130 | ~seh() throw() 131 | { 132 | } 133 | }; 134 | 135 | /** 136 | * Exception to be throwed when child processes fail. 137 | */ 138 | struct rethrown : public failure 139 | { 140 | explicit rethrown(const test_result &result) 141 | : failure(result.message), tr(result) 142 | { 143 | } 144 | 145 | virtual test_result::result_type result() const 146 | { 147 | return test_result::rethrown; 148 | } 149 | 150 | ~rethrown() throw() 151 | { 152 | } 153 | 154 | const test_result tr; 155 | }; 156 | 157 | } 158 | 159 | #endif 160 | -------------------------------------------------------------------------------- /testsuite/src/SimpleCommandTest.cpp: -------------------------------------------------------------------------------- 1 | // SimpleCommandTest.cpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if defined(_MSC_VER) 10 | #pragma warning( disable : 4250 ) // Disable: 'class1' : inherits 'class2::member' via dominance 11 | #pragma warning( disable : 4355 ) // The this pointer is valid only within nonstatic member functions. It cannot be used in the initializer list for a base class.ck(16) 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include "SimpleCommandTestCommand.hpp" 19 | #include "SimpleCommandTestVO.hpp" 20 | #include "SimpleCommandTestFirstCommand.hpp" 21 | #include "SimpleCommandTestSecondCommand.hpp" 22 | 23 | namespace data 24 | { 25 | struct SimpleCommandTest 26 | { }; 27 | } 28 | 29 | namespace testgroup 30 | { 31 | typedef tut::test_group simple_command_test_t; 32 | typedef simple_command_test_t::object object; 33 | simple_command_test_t simple_command_test("SimpleCommandTest"); 34 | } 35 | 36 | namespace tut 37 | { 38 | using namespace testgroup; 39 | 40 | using PureMVC::Interfaces::INotification; 41 | using PureMVC::Interfaces::IFacade; 42 | using PureMVC::Patterns::Notification; 43 | using PureMVC::Patterns::Facade; 44 | 45 | template<> template<> 46 | void simple_command_test_t::object::test<1>(void) 47 | { 48 | set_test_name("testSimpleCommandExecute"); 49 | 50 | data::SimpleCommandTestVO vo(5); 51 | Notification note("SimpleCommandTestNote", &vo); 52 | data::SimpleCommandTestCommand command; 53 | 54 | command.execute((INotification&)note); 55 | 56 | ensure_equals( "Expecting vo.result == 10", vo.result, 10 ); 57 | } 58 | 59 | template<> template<> 60 | void simple_command_test_t::object::test<2>(void) 61 | { 62 | set_test_name("testRegisterCommandInCommand"); 63 | 64 | // create dummy facade. 65 | IFacade &facade = Facade::getInstance(); 66 | 67 | // create test value object 68 | // vo.input = 10; 69 | // v.result = 0; 70 | data::SimpleCommandTestVO vo(10); 71 | 72 | // Register simple test command first. 73 | data::SimpleCommandTestFirstCommand command; 74 | facade.registerCommand("simpleCommandTestFirstCommand", &command); 75 | 76 | // activating command first. 77 | facade.sendNotification("simpleCommandTestFirstCommand", &vo); 78 | 79 | // The result should be 50 80 | // vo.result += 2 * vo.input; 81 | // vo.result += 3 * vo.input; 82 | ensure_equals( "Expecting vo.result == 50", vo.result, 50 ); 83 | 84 | // activating again command second. 85 | facade.sendNotification("simpleCommandTestSecondCommand", &vo); 86 | 87 | // result should be 80 88 | // vo.result += 3 * vo.input; 89 | ensure_equals( "Expecting vo.result == 80", vo.result, 80 ); 90 | 91 | // activating command first. 92 | facade.sendNotification("simpleCommandTestFirstCommand", &vo); 93 | 94 | // The result does not change 95 | ensure_equals( "Expecting vo.result == 80", vo.result, 80 ); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /testsuite/src/ObserverTest.cpp: -------------------------------------------------------------------------------- 1 | // ObserverTest.cpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if defined(_MSC_VER) 10 | #pragma warning( disable : 4250 ) // Disable: 'class1' : inherits 'class2::member' via dominance 11 | #pragma warning( disable : 4355 ) // The this pointer is valid only within nonstatic member functions. It cannot be used in the initializer list for a base class.ck(16) 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | namespace data 19 | { 20 | using PureMVC::Interfaces::INotification; 21 | 22 | struct IObserverTest 23 | { 24 | virtual void observerTestMethod(INotification const& note) = 0; 25 | }; 26 | struct ObserverTest : virtual IObserverTest 27 | { 28 | int observerTestVar; 29 | // observerTestMethod must be virtual!!! 30 | virtual void observerTestMethod(INotification const& note) 31 | { 32 | observerTestVar = *(int*)note.getBody(); 33 | } 34 | }; 35 | } 36 | 37 | namespace testgroup 38 | { 39 | typedef tut::test_group observer_test_t; 40 | typedef observer_test_t::object object ; 41 | observer_test_t observer_test("ObserverTest"); 42 | } 43 | 44 | namespace tut 45 | { 46 | using namespace testgroup; 47 | 48 | using PureMVC::Patterns::Observer; 49 | using PureMVC::Patterns::Notification; 50 | using PureMVC::Interfaces::INotification; 51 | using PureMVC::Interfaces::IObserver; 52 | using PureMVC::Patterns::createObserver; 53 | 54 | template<> template<> 55 | void object::test<1>(void) 56 | { 57 | set_test_name("testObserverConstructor"); 58 | 59 | // Create observer passing in notification method and context 60 | IObserver* observer = createObserver(&data::ObserverTest::observerTestMethod, this); 61 | 62 | // create a test note, setting a body value and notify 63 | // the observer with it. since the observer is this class 64 | // and the notification method is observerTestMethod, 65 | // successful notification will result in our local 66 | // observerTestVar being set to the value we pass in 67 | // on the note body. 68 | int value = 5; 69 | Notification note("ObserverTestNote", &value); 70 | observer->notifyObserver(note); 71 | 72 | // test assertions 73 | ensure_equals( "Expecting observerTestVar = 5", observerTestVar, 5); 74 | 75 | delete observer; 76 | } 77 | 78 | template<> template<> 79 | void object::test<3>(void) 80 | { 81 | set_test_name("testObserverCompareNotifyContext"); 82 | 83 | IObserver* observer = createObserver(&data::ObserverTest::observerTestMethod, this); 84 | void* negTestObj = new std::string(); 85 | 86 | // test assertions 87 | ensure_equals( "Expecting observer.compareNotifyContext(negTestObj) == false", observer->compareNotifyContext(negTestObj),false ); 88 | ensure_equals( "Expecting observer.compareNotifyContext(this) == true", observer->compareNotifyContext(this), true ); 89 | delete observer; 90 | delete (std::string*)negTestObj; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /testsuite/src/NotificationTest.cpp: -------------------------------------------------------------------------------- 1 | // NotificationTest.cpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if defined(_MSC_VER) 10 | #pragma warning( disable : 4250 ) // Disable: 'class1' : inherits 'class2::member' via dominance 11 | #pragma warning( disable : 4355 ) // The this pointer is valid only within nonstatic member functions. It cannot be used in the initializer list for a base class.ck(16) 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | namespace data 19 | { 20 | struct NotificationTest 21 | { }; 22 | } 23 | 24 | namespace testgroup 25 | { 26 | typedef tut::test_group notification_test_t; 27 | typedef notification_test_t::object object; 28 | notification_test_t notification_test("NotificationTest"); 29 | } 30 | 31 | namespace tut 32 | { 33 | using namespace testgroup; 34 | 35 | using PureMVC::Interfaces::INotification; 36 | using PureMVC::Patterns::Notification; 37 | 38 | template<> template<> 39 | void object::test<1>(void) 40 | { 41 | set_test_name("testNameAccessors"); 42 | 43 | INotification* note = new Notification("TestNote"); 44 | 45 | // test assertions 46 | ensure_equals("Expecting note.getName() == 'TestNote'", note->getName(), "TestNote"); 47 | 48 | delete note; 49 | } 50 | 51 | template<> template<> 52 | void object::test<2>(void) 53 | { 54 | set_test_name("testBodyAccessors"); 55 | 56 | int value = 5; 57 | INotification* note = new Notification(""); 58 | 59 | note->setBody(&value); 60 | 61 | // test assertions 62 | ensure_equals("Expecting note.getBody()as Number == 5", *(int*)note->getBody(), 5); 63 | 64 | delete note; 65 | } 66 | 67 | template<> template<> 68 | void object::test<3>(void) 69 | { 70 | set_test_name("testConstructor"); 71 | 72 | int value = 5; 73 | INotification* note = new Notification("TestNote", &value, "TestNoteType"); 74 | 75 | // test assertions 76 | ensure_equals( "Expecting note.getName() == 'TestNote'", note->getName(), "TestNote"); 77 | ensure_equals( "Expecting note.getBody()as Number == 5", *(int*)note->getBody(), 5); 78 | ensure_equals( "Expecting note.getType() == 'TestNoteType'", note->getType(), "TestNoteType"); 79 | 80 | delete note; 81 | } 82 | 83 | template<> template<> 84 | void object::test<4>(void) 85 | { 86 | set_test_name("testToString"); 87 | 88 | int value[] = {1 ,3 ,5}; 89 | INotification* note = new Notification("TestNote", value, "TestType"); 90 | 91 | std::string ts = "Notification Name: TestNote\nBody: "; 92 | ts += typeid(void const*).name(); 93 | ts += "\nType: TestType"; 94 | 95 | std::string temp("Expecting note.testToString() == '"); 96 | (temp += ts) += "'"; 97 | std::string to_string = note->toString(); 98 | //// test assertions 99 | ensure_equals(temp, to_string, ts ); 100 | 101 | delete note; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /include/PureMVC/Interfaces/INotifier.hpp: -------------------------------------------------------------------------------- 1 | // INotifier.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_INTERFACES_INOTIFIER_HPP__) 10 | #define __PUREMVC_INTERFACES_INOTIFIER_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | namespace PureMVC 21 | { 22 | namespace Interfaces 23 | { 24 | /** 25 | * The interface definition for a PureMVC Notifier. 26 | * 27 | *

28 | * MacroCommand, Command, Mediator and Proxy 29 | * all have a need to send Notifications.

30 | * 31 | *

32 | * The INotifier interface provides a common method called 33 | * sendNotification that relieves implementation code of 34 | * the necessity to actually construct Notifications.

35 | * 36 | *

37 | * The Notifier class, which all of the above mentioned classes 38 | * extend, also provides an initialized reference to the Facade 39 | * Singleton, which is required for the convienience method 40 | * for sending Notifications, but also eases implementation as these 41 | * classes have frequent Facade interactions and usually require 42 | * access to the facade anyway.

43 | * 44 | * @see Interfaces/IFacade.hpp PureMVC::Interfaces::IFacade 45 | * @see Interfaces/INotification.hpp PureMVC::Interfaces::INotification 46 | */ 47 | struct PUREMVC_API INotifier 48 | { 49 | /** 50 | * Send a INotification. 51 | * 52 | *

53 | * Convenience method to prevent having to construct new 54 | * notification instances in our implementation code.

55 | * 56 | * @param notification_name the name of the notification to send 57 | * @param body the body of the notification (optional) 58 | * @param type the type of the notification (optional) 59 | */ 60 | virtual void sendNotification(std::string const& notification_name, void const* body = NULL, std::string const& type = "") = 0; 61 | 62 | /** 63 | * Initialize this INotifier instance. 64 | *

65 | * This is how a Notifier gets its multitonKey. 66 | * Calls to sendNotification or to access the 67 | * facade will fail until after this method 68 | * has been called.

69 | * 70 | * @param key the multitonKey for this INotifier to use 71 | */ 72 | virtual void initializeNotifier(std::string const& key) = 0; 73 | 74 | /** 75 | * Get multiton key. 76 | * 77 | * @return the key of notifier. 78 | */ 79 | virtual std::string const& getMultitonKey(void) const = 0; 80 | 81 | /** 82 | * Virtual destructor. 83 | */ 84 | virtual ~INotifier(void); 85 | }; 86 | } 87 | } 88 | 89 | #endif /* __PUREMVC_INTERFACES_INOTIFIER_HPP__ */ 90 | -------------------------------------------------------------------------------- /include/PureMVC/Interfaces/IObserver.hpp: -------------------------------------------------------------------------------- 1 | // IObserver.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_INTERFACES_IOBSERVER_HPP__) 10 | #define __PUREMVC_INTERFACES_IOBSERVER_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | #include "INotification.hpp" 21 | 22 | namespace PureMVC 23 | { 24 | namespace Interfaces 25 | { 26 | /** 27 | * The interface definition for a PureMVC Observer. 28 | * 29 | *

30 | * In PureMVC, IObserver implementors assume these responsibilities: 31 | *

    32 | *
  • Encapsulate the notification (callback) method of the interested object.
  • 33 | *
  • Encapsulate the notification context (this) of the interested object.
  • 34 | *
  • Provide methods for setting the interested object' notification method and context.
  • 35 | *
  • Provide a method for notifying the interested object.
  • 36 | *
37 | * 38 | *

39 | * PureMVC does not rely upon underlying event 40 | * models such as the one provided with Flash, 41 | * and ActionScript 3 does not have an inherent 42 | * event model.

43 | * 44 | *

45 | * The Observer Pattern as implemented within 46 | * PureMVC exists to support event driven communication 47 | * between the application and the actors of the 48 | * MVC triad.

49 | * 50 | *

51 | * An Observer is an object that encapsulates information 52 | * about an interested object with a notification method that 53 | * should be called when an INotification is broadcast. The Observer then 54 | * acts as a proxy for notifying the interested object. 55 | * 56 | *

57 | * Observers can receive Notifications by having their 58 | * notifyObserver method invoked, passing 59 | * in an object implementing the INotification interface, such 60 | * as a subclass of Notification.

61 | * 62 | * @see Interfaces/IView.hpp PureMVC::Interfaces::IView 63 | * @see Interfaces/INotification.hpp PureMVC::Interfaces::INotification 64 | */ 65 | struct PUREMVC_API IObserver 66 | { 67 | /** 68 | * Notify the interested object. 69 | * 70 | * @param notification the INotification to pass to the interested object's notification method 71 | */ 72 | virtual void notifyObserver(INotification const& notification) = 0; 73 | 74 | /** 75 | * Compare the given object to the notification context object. 76 | * 77 | * @param object the object to compare. 78 | * @return boolean indicating if the notification context and the observer are the same. 79 | */ 80 | virtual bool compareNotifyContext(void const* object) const = 0; 81 | 82 | /** 83 | * Virtual destructor. 84 | */ 85 | virtual ~IObserver(void); 86 | }; 87 | } 88 | } 89 | 90 | #endif /* __PUREMVC_INTERFACES_IOBSERVER_HPP__ */ 91 | -------------------------------------------------------------------------------- /testsuite/src/MacroCommandTest.cpp: -------------------------------------------------------------------------------- 1 | // MacroCommandTest.cpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if defined(_MSC_VER) 10 | #pragma warning( disable : 4250 ) // Disable: 'class1' : inherits 'class2::member' via dominance 11 | #pragma warning( disable : 4355 ) // The this pointer is valid only within nonstatic member functions. It cannot be used in the initializer list for a base class.ck(16) 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include "MacroCommandTestCommand.hpp" 19 | #include "MacroCommandTestVO.hpp" 20 | #include "MacroCommandTestSub1Command.hpp" 21 | #include "MacroCommandTestSub2Command.hpp" 22 | 23 | namespace data 24 | { 25 | struct MacroCommandTest 26 | { }; 27 | } 28 | 29 | namespace testgroup 30 | { 31 | typedef tut::test_group macro_command_test_t; 32 | typedef macro_command_test_t::object object; 33 | macro_command_test_t macro_command_test("MacroCommandTest"); 34 | } 35 | 36 | namespace tut 37 | { 38 | using namespace testgroup; 39 | 40 | using PureMVC::Interfaces::INotification; 41 | using PureMVC::Interfaces::ICommand; 42 | using PureMVC::Patterns::MacroCommand; 43 | using PureMVC::Patterns::Notification; 44 | 45 | template<> template<> 46 | void object::test<1>(void) 47 | { 48 | set_test_name("testMacroCommandExecute"); 49 | 50 | data::MacroCommandTestVO vo(5); 51 | Notification note("MacroCommandTest", &vo); 52 | data::MacroCommandTestCommand command; 53 | 54 | command.execute((INotification&)note); 55 | 56 | ensure_equals( "Expecting vo.result1 == 10", vo.result1, 10); 57 | ensure_equals( "Expecting vo.result2 == 25", vo.result2, 25); 58 | } 59 | 60 | template<> template<> 61 | void object::test<2>(void) 62 | { 63 | set_test_name("testMacroCommandListCommandExecute"); 64 | 65 | data::MacroCommandTestVO vo(7); 66 | Notification note("MacroCommandListTest", &vo); 67 | 68 | 69 | std::list command_list; 70 | command_list.push_back(new data::MacroCommandTestSub1Command()); 71 | command_list.push_back(new data::MacroCommandTestSub2Command()); 72 | 73 | MacroCommand command(command_list); 74 | 75 | command.execute((INotification&)note); 76 | 77 | ensure_equals( "Expecting vo.result1 == 10", vo.result1, 14); 78 | ensure_equals( "Expecting vo.result2 == 49", vo.result2, 49); 79 | } 80 | 81 | template 82 | inline std::size_t getSize(_Type(&)[_Size]) { return _Size; } 83 | 84 | template<> template<> 85 | void object::test<3>(void) 86 | { 87 | set_test_name("testMacroCommandListCommandExecute"); 88 | 89 | data::MacroCommandTestVO vo(8); 90 | Notification note("MacroCommandListTest", &vo); 91 | 92 | 93 | ICommand* command_array[] = { 94 | new data::MacroCommandTestSub1Command(), 95 | new data::MacroCommandTestSub2Command() 96 | }; 97 | 98 | MacroCommand command(command_array, command_array + getSize(command_array)); 99 | 100 | command.execute((INotification&)note); 101 | 102 | ensure_equals( "Expecting vo.result1 == 10", vo.result1, 16); 103 | ensure_equals( "Expecting vo.result2 == 49", vo.result2, 64); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /autoconf/bk-deps: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script is part of Bakefile (http://www.bakefile.org) autoconf 4 | # script. It is used to track C/C++ files dependencies in portable way. 5 | # 6 | # Permission is given to use this file in any way. 7 | 8 | DEPSMODE=@DEPSMODE@ 9 | DEPSFLAG="@DEPSFLAG@" 10 | DEPSDIRBASE=.deps 11 | 12 | if test $DEPSMODE = gcc ; then 13 | $* ${DEPSFLAG} 14 | status=$? 15 | 16 | # determine location of created files: 17 | while test $# -gt 0; do 18 | case "$1" in 19 | -o ) 20 | shift 21 | objfile=$1 22 | ;; 23 | -* ) 24 | ;; 25 | * ) 26 | srcfile=$1 27 | ;; 28 | esac 29 | shift 30 | done 31 | objfilebase=`basename $objfile` 32 | builddir=`dirname $objfile` 33 | depfile=`basename $srcfile | sed -e 's/\..*$/.d/g'` 34 | depobjname=`echo $depfile |sed -e 's/\.d/.o/g'` 35 | depsdir=$builddir/$DEPSDIRBASE 36 | mkdir -p $depsdir 37 | 38 | # if the compiler failed, we're done: 39 | if test ${status} != 0 ; then 40 | rm -f $depfile 41 | exit ${status} 42 | fi 43 | 44 | # move created file to the location we want it in: 45 | if test -f $depfile ; then 46 | sed -e "s,$depobjname:,$objfile:,g" $depfile >${depsdir}/${objfilebase}.d 47 | rm -f $depfile 48 | else 49 | # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d 50 | depfile=`echo "$objfile" | sed -e 's/\..*$/.d/g'` 51 | if test ! -f $depfile ; then 52 | # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++) 53 | depfile="$objfile.d" 54 | fi 55 | if test -f $depfile ; then 56 | sed -e "\,^$objfile,!s,$depobjname:,$objfile:,g" $depfile >${depsdir}/${objfilebase}.d 57 | rm -f $depfile 58 | fi 59 | fi 60 | exit 0 61 | 62 | elif test $DEPSMODE = mwcc ; then 63 | $* || exit $? 64 | # Run mwcc again with -MM and redirect into the dep file we want 65 | # NOTE: We can't use shift here because we need $* to be valid 66 | prevarg= 67 | for arg in $* ; do 68 | if test "$prevarg" = "-o"; then 69 | objfile=$arg 70 | else 71 | case "$arg" in 72 | -* ) 73 | ;; 74 | * ) 75 | srcfile=$arg 76 | ;; 77 | esac 78 | fi 79 | prevarg="$arg" 80 | done 81 | 82 | objfilebase=`basename $objfile` 83 | builddir=`dirname $objfile` 84 | depsdir=$builddir/$DEPSDIRBASE 85 | mkdir -p $depsdir 86 | 87 | $* $DEPSFLAG >${depsdir}/${objfilebase}.d 88 | exit 0 89 | 90 | elif test $DEPSMODE = unixcc; then 91 | $* || exit $? 92 | # Run compiler again with deps flag and redirect into the dep file. 93 | # It doesn't work if the '-o FILE' option is used, but without it the 94 | # dependency file will contain the wrong name for the object. So it is 95 | # removed from the command line, and the dep file is fixed with sed. 96 | cmd="" 97 | while test $# -gt 0; do 98 | case "$1" in 99 | -o ) 100 | shift 101 | objfile=$1 102 | ;; 103 | * ) 104 | eval arg$#=\$1 105 | cmd="$cmd \$arg$#" 106 | ;; 107 | esac 108 | shift 109 | done 110 | 111 | objfilebase=`basename $objfile` 112 | builddir=`dirname $objfile` 113 | depsdir=$builddir/$DEPSDIRBASE 114 | mkdir -p $depsdir 115 | 116 | eval "$cmd $DEPSFLAG" | sed "s|.*:|$objfile:|" >${depsdir}/${objfilebase}.d 117 | exit 0 118 | 119 | else 120 | $* 121 | exit $? 122 | fi 123 | -------------------------------------------------------------------------------- /testsuite/src/DelegateCommandTest.cpp: -------------------------------------------------------------------------------- 1 | // DelegateCommandTest.cpp 2 | // PureMVC_C++ Test suite 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if defined(_MSC_VER) 10 | #pragma warning( disable : 4250 ) // Disable: 'class1' : inherits 'class2::member' via dominance 11 | #pragma warning( disable : 4355 ) // The this pointer is valid only within nonstatic member functions. It cannot be used in the initializer list for a base class.ck(16) 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include "SimpleCommandTestCommand.hpp" 19 | #include "SimpleCommandTestVO.hpp" 20 | #include "SimpleCommandTestFirstCommand.hpp" 21 | #include "SimpleCommandTestSecondCommand.hpp" 22 | 23 | namespace data 24 | { 25 | struct DelegateCommandTest 26 | { }; 27 | } 28 | 29 | namespace testgroup 30 | { 31 | typedef tut::test_group delegate_command_test_t; 32 | typedef delegate_command_test_t::object object; 33 | delegate_command_test_t delegate_command_test("DelegateCommandTest"); 34 | } 35 | 36 | namespace tut 37 | { 38 | using namespace testgroup; 39 | 40 | using PureMVC::Interfaces::INotification; 41 | using PureMVC::Interfaces::IFacade; 42 | using PureMVC::Patterns::Notification; 43 | using PureMVC::Patterns::Facade; 44 | using PureMVC::Patterns::DelegateCommand; 45 | 46 | template<> template<> 47 | void delegate_command_test_t::object::test<1>(void) 48 | { 49 | set_test_name("testDelegateCommandExecute"); 50 | 51 | data::SimpleCommandTestVO vo(5); 52 | Notification note("SimpleCommandTestNote", &vo); 53 | 54 | struct Executer { 55 | static void execute(INotification const& note) { 56 | data::SimpleCommandTestVO& vo= *(data::SimpleCommandTestVO*)note.getBody(); 57 | // Fabricate a result 58 | vo.result = 2 * vo.input; 59 | } 60 | }; 61 | 62 | DelegateCommand command(&Executer::execute); 63 | 64 | command.execute((INotification&)note); 65 | 66 | ensure_equals( "Expecting vo.result == 10", vo.result, 10 ); 67 | } 68 | 69 | template<> template<> 70 | void delegate_command_test_t::object::test<2>(void) 71 | { 72 | set_test_name("testRegisterDelegateCommand"); 73 | 74 | // create dummy facade. 75 | IFacade &facade = Facade::getInstance(); 76 | 77 | // create test value object 78 | // vo.input = 10; 79 | // v.result = 0; 80 | data::SimpleCommandTestVO vo(10); 81 | 82 | struct Executer { 83 | static void execute(INotification const& note) { 84 | data::SimpleCommandTestVO& vo= *(data::SimpleCommandTestVO*)note.getBody(); 85 | // Fabricate a result 86 | vo.result += 2 * vo.input; 87 | } 88 | }; 89 | 90 | DelegateCommand command(&Executer::execute); 91 | 92 | // Register simple test command first. 93 | facade.registerCommand("delegateCommandTest", &command); 94 | 95 | // activating command first. 96 | facade.sendNotification("delegateCommandTest", &vo); 97 | 98 | // The result should be 50 99 | // vo.result += 2 * vo.input; 100 | // vo.result += 3 * vo.input; 101 | ensure_equals( "Expecting vo.result == 20", vo.result, 20 ); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /include/PureMVC/Patterns/Proxy/Proxy.hpp: -------------------------------------------------------------------------------- 1 | // Proxy.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_PATTERNS_PROXY_PROXY_HPP__) 10 | #define __PUREMVC_PATTERNS_PROXY_PROXY_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | #include "../../Interfaces/IProxy.hpp" 21 | #include "../Observer/Notifier.hpp" 22 | 23 | namespace PureMVC 24 | { 25 | namespace Patterns 26 | { 27 | using Interfaces::IProxy; 28 | using Interfaces::INotifier; 29 | 30 | /** 31 | * A base IProxy implementation. 32 | * 33 | *

34 | * In PureMVC, Proxy classes are used to manage parts of the 35 | * application's data model.

36 | * 37 | *

38 | * A Proxy might simply manage a reference to a local data object, 39 | * in which case interacting with it might involve setting and 40 | * getting of its data in synchronous fashion.

41 | * 42 | *

43 | * Proxy classes are also used to encapsulate the application's 44 | * interaction with remote services to save or retrieve data, in which case, 45 | * we adopt an asyncronous idiom; setting data (or calling a method) on the 46 | * Proxy and listening for a Notification to be sent 47 | * when the Proxy has retrieved the data from the service.

48 | * 49 | * @see Core/Model.hpp PureMVC::Core::Model 50 | */ 51 | class PUREMVC_API Proxy 52 | : public virtual IProxy 53 | , public virtual INotifier 54 | , public Notifier 55 | { 56 | public: 57 | /** 58 | * Copy constructor. 59 | */ 60 | explicit Proxy(Proxy const& arg); 61 | 62 | public: 63 | /** 64 | * Constructor. 65 | */ 66 | explicit Proxy(std::string const& proxy_name = Proxy::NAME, void const* data = NULL); 67 | 68 | /** 69 | * Get the proxy name. 70 | */ 71 | virtual std::string const& getProxyName(void) const; 72 | 73 | /** 74 | * Set the data object. 75 | */ 76 | virtual void setData(void const* data); 77 | 78 | /** 79 | * Get the data object. 80 | */ 81 | virtual void const* getData(void) const; 82 | 83 | /** 84 | * Called by the Model when the Proxy is registered. 85 | */ 86 | virtual void onRegister(void); 87 | 88 | /** 89 | * Called by the Model when the Proxy is removed. 90 | */ 91 | virtual void onRemove(void); 92 | 93 | /** 94 | * Assignment operator. 95 | */ 96 | Proxy& operator=(Proxy const& arg); 97 | 98 | /** 99 | * Virtual destructor. 100 | */ 101 | virtual ~Proxy(void); 102 | protected: 103 | // the proxy name 104 | std::string _proxy_name; 105 | // the data object 106 | void const* _data; 107 | public: 108 | static char const* const NAME; 109 | }; 110 | } 111 | } 112 | 113 | #endif /* __PUREMVC_PATTERNS_PROXY_PROXY_HPP__ */ 114 | -------------------------------------------------------------------------------- /src/PureMVC/Resource/PureMVC.rc: -------------------------------------------------------------------------------- 1 | 1 VERSIONINFO 2 | FILEVERSION 1,0,0,0 3 | PRODUCTVERSION 1,0,0,0 4 | FILEFLAGSMASK 0X3FL 5 | FILEFLAGS 0L 6 | FILEOS 0X40004L 7 | FILETYPE 0X2 8 | FILESUBTYPE 0 9 | BEGIN 10 | BLOCK "StringFileInfo" 11 | BEGIN 12 | BLOCK "040904B0" 13 | BEGIN 14 | VALUE "FileVersion", "1.0.0.0" "\0" 15 | VALUE "ProductVersion", "1.0.0.0" "\0" 16 | #if defined(DEBUG) 17 | VALUE "OriginalFilename", "PureMVCd.dll" "\0" 18 | #if defined(__CODEGEARC__) || defined(__BORLANDC__) 19 | VALUE "InternalName", "PureMVC (Debug - Embarcadero C++ Builder)" "\0" 20 | VALUE "ProductName", "PureMVC (Debug - Embarcadero C++ Builder)" "\0" 21 | #elif defined(_MSC_VER) 22 | VALUE "InternalName", "PureMVC (Debug - Microsoft Visual C++)" "\0" 23 | VALUE "ProductName", "PureMVC (Debug - Microsoft Visual C++)" "\0" 24 | #elif defined(__INTEL_COMPILER) 25 | VALUE "InternalName", "PureMVC (Debug - Intel C++)" "\0" 26 | VALUE "ProductName", "PureMVC (Debug - Intel C++)" "\0" 27 | #elif defined(__MINGW32__) 28 | VALUE "InternalName", "PureMVC (Debug - MinGW32)" "\0" 29 | VALUE "ProductName", "PureMVC (Debug - MinGW32)" "\0" 30 | #elif defined(__GNUC__) 31 | VALUE "InternalName", "PureMVC (Debug - GCC)" "\0" 32 | VALUE "ProductName", "PureMVC (Debug - GCC)" "\0" 33 | #elif defined(__DMC__) 34 | VALUE "InternalName", "PureMVC (Debug - Digital Mars C++)" "\0" 35 | VALUE "ProductName", "PureMVC (Debug - Digital Mars C++)" "\0" 36 | #else 37 | VALUE "InternalName", "PureMVC (Debug - Unknown compiler)" "\0" 38 | VALUE "ProductName", "PureMVC (Debug)" "\0" 39 | #endif 40 | #else 41 | VALUE "OriginalFilename", "PureMVC.dll" "\0" 42 | #if defined(__CODEGEARC__) || defined(__BORLANDC__) 43 | VALUE "InternalName", "PureMVC (Release - Embarcadero C++ Builder)" "\0" 44 | VALUE "ProductName", "PureMVC (Release - Embarcadero C++ Builder)" "\0" 45 | #elif defined(_MSC_VER) 46 | VALUE "InternalName", "PureMVC (Release - Microsoft Visual C++)" "\0" 47 | VALUE "ProductName", "PureMVC (Release - Microsoft Visual C++)" "\0" 48 | #elif defined(__INTEL_COMPILER) 49 | VALUE "InternalName", "PureMVC (Release - Intel C++)" "\0" 50 | VALUE "ProductName", "PureMVC (Release - Intel C++)" "\0" 51 | #elif defined(__MINGW32__) 52 | VALUE "InternalName", "PureMVC (Release - MinGW32)" "\0" 53 | VALUE "ProductName", "PureMVC (Release - MinGW32)" "\0" 54 | #elif defined(__GNUC__) 55 | VALUE "InternalName", "PureMVC (Release - GCC)" "\0" 56 | VALUE "ProductName", "PureMVC (Release - GCC)" "\0" 57 | #elif defined(__DMC__) 58 | VALUE "InternalName", "PureMVC (Release - Digital Mars C++)" "\0" 59 | VALUE "ProductName", "PureMVC (Release - Digital Mars C++)" "\0" 60 | #else 61 | VALUE "InternalName", "PureMVC (Release - Unknown compiler)" "\0" 62 | VALUE "ProductName", "PureMVC (Release)" "\0" 63 | #endif 64 | #endif 65 | VALUE "CompanyName", "Futurescale, Inc. (http://futurescale.com)" "\0" 66 | VALUE "FileDescription", "PureMVC library for C++ language" "\0" 67 | VALUE "LegalCopyright", "Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved." "\0" 68 | VALUE "PrivateBuild", "1.0.0.0" "\0" 69 | VALUE "Authors", "Tang Khai Phuong - phuong.tang@puremvc.org" "\0" 70 | END 71 | END 72 | BLOCK "VarFileInfo" 73 | BEGIN 74 | VALUE "Translation", 0x0409, 0x04B0 75 | END 76 | END 77 | -------------------------------------------------------------------------------- /include/PureMVC/Interfaces/IModel.hpp: -------------------------------------------------------------------------------- 1 | // IModel.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_INTERFACES_IMODEL_HPP__) 10 | #define __PUREMVC_INTERFACES_IMODEL_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | #include "IProxy.hpp" 21 | #include "IAggregate.hpp" 22 | 23 | namespace PureMVC 24 | { 25 | namespace Interfaces 26 | { 27 | /** 28 | * The interface definition for a PureMVC Model. 29 | * 30 | *

31 | * In PureMVC, IModel implementors provide 32 | * access to IProxy objects by named lookup.

33 | * 34 | *

35 | * An IModel assumes these responsibilities:

36 | * 37 | *
    38 | *
  • Maintain a cache of IProxy instances
  • 39 | *
  • Provide methods for registering, retrieving, and removing IProxy instances
  • 40 | *
41 | * 42 | * @see Interfaces/IIterator.hpp PureMVC::Interfaces::IIterator 43 | * @see Interfaces/IAggregate.hpp PureMVC::Interfaces::IAggregate 44 | */ 45 | struct PUREMVC_API IModel 46 | { 47 | #if defined(PUREMVC_USES_TR1) 48 | typedef std::unique_ptr > ProxyNames; 49 | #else 50 | typedef std::auto_ptr > ProxyNames; 51 | #endif 52 | 53 | /** 54 | * Register an IProxy instance with the Model. 55 | * 56 | * @param proxy an object reference to be held by the Model. 57 | */ 58 | virtual void registerProxy(IProxy* proxy) = 0; 59 | 60 | /** 61 | * Retrieve an IProxy instance from the Model. 62 | * 63 | * @param proxy_name 64 | * @return the IProxy instance previously registered with the given proxy_name. 65 | */ 66 | virtual IProxy const& retrieveProxy(std::string const& proxy_name) const = 0; 67 | 68 | /** 69 | * Retrieve an IProxy instance from the Model. 70 | * 71 | * @param proxy_name 72 | * @return the IProxy instance previously registered with the given proxy_name. 73 | */ 74 | virtual IProxy& retrieveProxy(std::string const& proxy_name) = 0; 75 | 76 | /** 77 | * Remove an IProxy instance from the Model. 78 | * 79 | * @param proxy_name name of the IProxy instance to be removed. 80 | * @return the IProxy that was removed from the Model 81 | */ 82 | virtual IProxy* removeProxy(std::string const& proxy_name) = 0; 83 | 84 | /** 85 | * Check if a Proxy is registered 86 | * 87 | * @param proxy_name 88 | * @return whether a Proxy is currently registered with the given proxy_name. 89 | */ 90 | virtual bool hasProxy(std::string const& proxy_name) const = 0; 91 | 92 | /** 93 | * Fetch all names of proxy 94 | * 95 | * @return the aggregate container of proxy_name. 96 | */ 97 | virtual ProxyNames listProxyNames(void) const = 0; 98 | 99 | /** 100 | * Virtual destructor. 101 | */ 102 | virtual ~IModel(void); 103 | }; 104 | } 105 | } 106 | 107 | #endif /* __PUREMVC_INTERFACES_IMODEL_HPP__ */ 108 | -------------------------------------------------------------------------------- /autoconf/bakefilize: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This file is part of Bakefile (http://www.bakefile.org) 4 | # 5 | # Copyright (C) 2003-2007 Vaclav Slavik 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | # 25 | # $Id: bakefilize 1218 2008-05-16 17:05:52Z vadz $ 26 | # 27 | # This script copies support files required by Autoconf if used with 28 | # Bakefile from Automake (don't ask...) directory. 29 | # 30 | 31 | 32 | # ------------------------------------------------------------------ 33 | # configuration 34 | # ------------------------------------------------------------------ 35 | 36 | AUTOMAKE_DIRS="/usr/local/share /usr/share" 37 | NEEDED_FILES="INSTALL config.guess config.sub install-sh" 38 | 39 | # ------------------------------------------------------------------ 40 | # script code 41 | # ------------------------------------------------------------------ 42 | 43 | # Handle command line arguments: 44 | 45 | symlink=1 46 | dry_run=0 47 | force=0 48 | verbose=0 49 | 50 | give_help_and_exit() { 51 | cat >&2 <&2 87 | give_help_and_exit 1 88 | esac 89 | done 90 | 91 | 92 | # Find Automake directory: 93 | 94 | automake="" 95 | for dir in $AUTOMAKE_DIRS ; do 96 | if test -n $automake ; then 97 | latest=`ls $dir | grep '^automake' | sort -r | head -n 1` 98 | if test -n $latest ; then 99 | automake=$dir/$latest 100 | fi 101 | fi 102 | done 103 | if test -z $automake ; then 104 | echo "Couldn't find automake files, aborting." >&2 105 | echo "Searched in: $AUTOMAKE_DIRS" >&2 106 | exit 1 107 | fi 108 | if test $verbose = 1 ; then 109 | echo "using automake from $automake" 110 | fi 111 | 112 | 113 | # Copy files: 114 | 115 | for f in $NEEDED_FILES ; do 116 | if test -f $f -a $force = 0 ; then 117 | if test $verbose = 1 ; then 118 | echo "file $f exists, skipping" 119 | fi 120 | else 121 | if test $verbose = 1 ; then 122 | echo "copying file $automake/$f to $f" 123 | fi 124 | if test $symlink = 1 ; then 125 | cmd="ln -s $automake/$f $f" 126 | else 127 | cmd="cp $automake/$f $f" 128 | fi 129 | if test $dry_run = 1 ; then 130 | echo rm -f $f 131 | echo $cmd 132 | else 133 | rm -f $f 134 | $cmd 135 | fi 136 | fi 137 | done 138 | -------------------------------------------------------------------------------- /bakefile-intel-format-support/rules/intelw.bkl: -------------------------------------------------------------------------------- 1 | 2 | 30 | 31 | 32 | ic 33 | intelw 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | $(BUILDDIR) 44 | 45 | -if exist $(__builddir)\*$(OBJEXT) del $(__builddir)\*$(OBJEXT) 46 | -if exist $(__builddir)\*.res del $(__builddir)\*.res 47 | -if exist $(__builddir)\*.pch del $(__builddir)\*.pch 48 | 49 | 50 | 51 | 52 | 53 | $(ref('__targetdir',id))$(ref('__name',id)).ilk 54 | 55 | 56 | $(ref('__targetdir',id))$(ref('__name',id)).pdb 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | $(sources2objects(value, id, '.res')) 68 | 69 | $(__restmp) 70 | $(__restmp) 71 | 72 | 73 | 74 | 75 | 80 | 81 | $(targets[value].__win32rc_flags) 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | __targetdir __targetname __deps __command 93 | 94 | 95 | 96 | 97 | 98 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /include/PureMVC/Interfaces/INotification.hpp: -------------------------------------------------------------------------------- 1 | // INotification.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_INTERFACES_INOTIFICATION_HPP__) 10 | #define __PUREMVC_INTERFACES_INOTIFICATION_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | namespace PureMVC 21 | { 22 | namespace Interfaces 23 | { 24 | /** 25 | * The interface definition for a PureMVC Notification. 26 | * 27 | *

28 | * PureMVC does not rely upon underlying event models such 29 | * as the one provided with Flash, and ActionScript 3 does 30 | * not have an inherent event model.

31 | * 32 | *

33 | * The Observer Pattern as implemented within PureMVC exists 34 | * to support event-driven communication between the 35 | * application and the actors of the MVC triad.

36 | * 37 | *

38 | * Notifications are not meant to be a replacement for Events 39 | * in Flex/Flash/AIR. Generally, IMediator implementors 40 | * place event listeners on their view components, which they 41 | * then handle in the usual way. This may lead to the broadcast of Notifications to 42 | * trigger ICommands or to communicate with other IMediators. IProxy and ICommand 43 | * instances communicate with each other and IMediators 44 | * by broadcasting INotifications.

45 | * 46 | *

47 | * A key difference between Flash Events and PureMVC 48 | * Notifications is that Events follow the 49 | * 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy 50 | * until some parent component handles the Event, while 51 | * PureMVC Notifications follow a 'Publish/Subscribe' 52 | * pattern. PureMVC classes need not be related to each other in a 53 | * parent/child relationship in order to communicate with one another 54 | * using Notifications. 55 | * 56 | * @see Interfaces/IView.hpp PureMVC::Interfaces::IView 57 | * @see Interfaces/IObserver.hpp PureMVC::Interfaces::IObserver 58 | */ 59 | 60 | struct PUREMVC_API INotification 61 | { 62 | /** 63 | * Get the name of the INotification instance. 64 | * No setter, should be set by constructor only 65 | */ 66 | virtual std::string const& getName(void) const = 0; 67 | 68 | /** 69 | * Set the body of the INotification instance 70 | */ 71 | virtual void setBody(void const* body) = 0; 72 | 73 | /** 74 | * Get the body of the INotification instance 75 | */ 76 | virtual void const* getBody(void) const = 0; 77 | 78 | /** 79 | * Set the type of the INotification instance 80 | */ 81 | virtual void setType(std::string const& type) = 0; 82 | 83 | /** 84 | * Get the type of the INotification instance 85 | */ 86 | virtual std::string const& getType(void) const = 0; 87 | 88 | /** 89 | * Get the string representation of the INotification instance 90 | */ 91 | virtual std::string toString(void) const = 0; 92 | 93 | /** 94 | * Get the string representation of the INotification instance 95 | */ 96 | virtual void toString(std::string& arg) const = 0; 97 | 98 | /** 99 | * Virtual destructor. 100 | */ 101 | virtual ~INotification(void); 102 | }; 103 | } 104 | } 105 | 106 | #endif /* __PUREMVC_INTERFACES_INOTIFICATION_HPP__ */ 107 | -------------------------------------------------------------------------------- /include/PureMVC/Patterns/Command/DelegateCommand.hpp: -------------------------------------------------------------------------------- 1 | // SimpleCommand.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_PATTERNS_COMMAND_DELEGATE_COMMAND_HPP__) 10 | #define __PUREMVC_PATTERNS_COMMAND_DELEGATE_COMMAND_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | #include "../../Interfaces/ICommand.hpp" 21 | #include "../Observer/Notifier.hpp" 22 | 23 | namespace PureMVC 24 | { 25 | namespace Patterns 26 | { 27 | using Interfaces::ICommand; 28 | using Interfaces::INotifier; 29 | 30 | template 31 | class DelegateCommand 32 | : public virtual ICommand 33 | , public virtual INotifier 34 | , public Notifier 35 | { 36 | protected: 37 | _Action _action; 38 | public: 39 | /** 40 | * Constructor. 41 | */ 42 | explicit DelegateCommand(_Action action) 43 | : INotifier() 44 | , ICommand() 45 | , Notifier() 46 | , _action(action) 47 | { } 48 | 49 | /** 50 | * Copy constructor. 51 | */ 52 | explicit DelegateCommand(DelegateCommand const& arg) 53 | : INotifier() 54 | , ICommand() 55 | , Notifier(arg) 56 | , _action(arg._action) 57 | { } 58 | 59 | #if defined(PUREMVC_USES_RVALUE) 60 | /** 61 | * Move constructor. 62 | * 63 | * @param arg The iterator. 64 | */ 65 | explicit DelegateCommand(DelegateCommand&& arg) 66 | : INotifier() 67 | , ICommand() 68 | , Notifier(arg) 69 | , _action(std::move(arg._action)) 70 | { } 71 | #endif 72 | public: 73 | /** 74 | * Fulfill the use-case initiated by the given INotification. 75 | * 76 | *

77 | * In the Command Pattern, an application use-case typically 78 | * begins with some user action, which results in an INotification being broadcast, which 79 | * is handled by business logic in the execute method of an 80 | * ICommand.

81 | * 82 | * @param notification the INotification to handle. 83 | */ 84 | virtual void execute(INotification const& notification) 85 | { 86 | _action(notification); 87 | } 88 | 89 | /** 90 | * Copy operator. 91 | */ 92 | DelegateCommand& operator=(DelegateCommand const& arg) 93 | { 94 | _action = arg._action; 95 | return *this; 96 | } 97 | 98 | #if defined(PUREMVC_USES_RVALUE) 99 | /** 100 | * Move operator. 101 | */ 102 | DelegateCommand& operator=(DelegateCommand&& arg) 103 | { 104 | _action = std::move(arg._action); 105 | return *this; 106 | } 107 | #endif 108 | /** 109 | * Virtual destructor. 110 | */ 111 | virtual ~DelegateCommand(void) 112 | { } 113 | }; 114 | 115 | /** 116 | * Create new command. 117 | */ 118 | template 119 | inline ICommand* createCommand(_Action action) 120 | { 121 | return new DelegateCommand<_Action>(action); 122 | } 123 | 124 | /** 125 | * Make a command. 126 | */ 127 | template 128 | inline DelegateCommand<_Action> makeCommand(_Action action) 129 | { 130 | return DelegateCommand<_Action>(action); 131 | } 132 | } 133 | } 134 | 135 | #endif /* __PUREMVC_PATTERNS_COMMAND_DELEGATE_COMMAND_HPP__ */ 136 | -------------------------------------------------------------------------------- /autoconf_inc.m4: -------------------------------------------------------------------------------- 1 | dnl ### begin block 00_header[makefile.bkl] ### 2 | dnl 3 | dnl This macro was generated by 4 | dnl Bakefile 0.2.9 (http://www.bakefile.org) 5 | dnl Do not modify, all changes will be overwritten! 6 | 7 | BAKEFILE_AUTOCONF_INC_M4_VERSION="0.2.9" 8 | 9 | dnl ### begin block 20_COND_DEBUG_0[makefile.bkl] ### 10 | COND_DEBUG_0="#" 11 | if test "x$DEBUG" = "x0" ; then 12 | COND_DEBUG_0="" 13 | fi 14 | AC_SUBST(COND_DEBUG_0) 15 | dnl ### begin block 20_COND_DEBUG_1[makefile.bkl] ### 16 | COND_DEBUG_1="#" 17 | if test "x$DEBUG" = "x1" ; then 18 | COND_DEBUG_1="" 19 | fi 20 | AC_SUBST(COND_DEBUG_1) 21 | dnl ### begin block 20_COND_DEPS_TRACKING_0[makefile.bkl] ### 22 | COND_DEPS_TRACKING_0="#" 23 | if test "x$DEPS_TRACKING" = "x0" ; then 24 | COND_DEPS_TRACKING_0="" 25 | fi 26 | AC_SUBST(COND_DEPS_TRACKING_0) 27 | dnl ### begin block 20_COND_DEPS_TRACKING_1[makefile.bkl] ### 28 | COND_DEPS_TRACKING_1="#" 29 | if test "x$DEPS_TRACKING" = "x1" ; then 30 | COND_DEPS_TRACKING_1="" 31 | fi 32 | AC_SUBST(COND_DEPS_TRACKING_1) 33 | dnl ### begin block 20_COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1[makefile.bkl] ### 34 | COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1="#" 35 | if test "x$PLATFORM_MACOSX" = "x0" -a "x$USE_SOVERCYGWIN" = "x0" -a "x$USE_SOVERSION" = "x1" ; then 36 | COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1="" 37 | fi 38 | AC_SUBST(COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1) 39 | dnl ### begin block 20_COND_PLATFORM_MACOSX_0_USE_SOVERSION_1[makefile.bkl] ### 40 | COND_PLATFORM_MACOSX_0_USE_SOVERSION_1="#" 41 | if test "x$PLATFORM_MACOSX" = "x0" -a "x$USE_SOVERSION" = "x1" ; then 42 | COND_PLATFORM_MACOSX_0_USE_SOVERSION_1="" 43 | fi 44 | AC_SUBST(COND_PLATFORM_MACOSX_0_USE_SOVERSION_1) 45 | dnl ### begin block 20_COND_PLATFORM_MACOSX_1[makefile.bkl] ### 46 | COND_PLATFORM_MACOSX_1="#" 47 | if test "x$PLATFORM_MACOSX" = "x1" ; then 48 | COND_PLATFORM_MACOSX_1="" 49 | fi 50 | AC_SUBST(COND_PLATFORM_MACOSX_1) 51 | dnl ### begin block 20_COND_PLATFORM_MACOSX_1_USE_SOVERSION_1[makefile.bkl] ### 52 | COND_PLATFORM_MACOSX_1_USE_SOVERSION_1="#" 53 | if test "x$PLATFORM_MACOSX" = "x1" -a "x$USE_SOVERSION" = "x1" ; then 54 | COND_PLATFORM_MACOSX_1_USE_SOVERSION_1="" 55 | fi 56 | AC_SUBST(COND_PLATFORM_MACOSX_1_USE_SOVERSION_1) 57 | dnl ### begin block 20_COND_PLATFORM_OS2_1[makefile.bkl] ### 58 | COND_PLATFORM_OS2_1="#" 59 | if test "x$PLATFORM_OS2" = "x1" ; then 60 | COND_PLATFORM_OS2_1="" 61 | fi 62 | AC_SUBST(COND_PLATFORM_OS2_1) 63 | dnl ### begin block 20_COND_USE_SOTWOSYMLINKS_1[makefile.bkl] ### 64 | COND_USE_SOTWOSYMLINKS_1="#" 65 | if test "x$USE_SOTWOSYMLINKS" = "x1" ; then 66 | COND_USE_SOTWOSYMLINKS_1="" 67 | fi 68 | AC_SUBST(COND_USE_SOTWOSYMLINKS_1) 69 | dnl ### begin block 20_COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1[makefile.bkl] ### 70 | COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1="#" 71 | if test "x$USE_SOVERCYGWIN" = "x1" -a "x$USE_SOVERSION" = "x1" ; then 72 | COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1="" 73 | fi 74 | AC_SUBST(COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1) 75 | dnl ### begin block 20_COND_USE_SOVERLINUX_1[makefile.bkl] ### 76 | COND_USE_SOVERLINUX_1="#" 77 | if test "x$USE_SOVERLINUX" = "x1" ; then 78 | COND_USE_SOVERLINUX_1="" 79 | fi 80 | AC_SUBST(COND_USE_SOVERLINUX_1) 81 | dnl ### begin block 20_COND_USE_SOVERSION_0[makefile.bkl] ### 82 | COND_USE_SOVERSION_0="#" 83 | if test "x$USE_SOVERSION" = "x0" ; then 84 | COND_USE_SOVERSION_0="" 85 | fi 86 | AC_SUBST(COND_USE_SOVERSION_0) 87 | dnl ### begin block 20_COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1[makefile.bkl] ### 88 | COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1="#" 89 | if test "x$USE_SOVERSION" = "x1" -a "x$USE_SOVERSOLARIS" = "x1" ; then 90 | COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1="" 91 | fi 92 | AC_SUBST(COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1) 93 | dnl ### begin block 20_COND_USE_SOVERSOLARIS_1[makefile.bkl] ### 94 | COND_USE_SOVERSOLARIS_1="#" 95 | if test "x$USE_SOVERSOLARIS" = "x1" ; then 96 | COND_USE_SOVERSOLARIS_1="" 97 | fi 98 | AC_SUBST(COND_USE_SOVERSOLARIS_1) 99 | dnl ### begin block 20_COND_WINDOWS_IMPLIB_1[makefile.bkl] ### 100 | COND_WINDOWS_IMPLIB_1="#" 101 | if test "x$WINDOWS_IMPLIB" = "x1" ; then 102 | COND_WINDOWS_IMPLIB_1="" 103 | fi 104 | AC_SUBST(COND_WINDOWS_IMPLIB_1) 105 | -------------------------------------------------------------------------------- /include/PureMVC/Patterns/Mediator/Mediator.hpp: -------------------------------------------------------------------------------- 1 | // Mediator.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_PATTERNS_MEDIATOR_MEDIATOR_HPP__) 10 | #define __PUREMVC_PATTERNS_MEDIATOR_MEDIATOR_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | #include "../../Interfaces/ICommand.hpp" 21 | #include "../Observer/Notifier.hpp" 22 | 23 | namespace PureMVC 24 | { 25 | namespace Patterns 26 | { 27 | using Interfaces::IMediator; 28 | using Interfaces::INotifier; 29 | 30 | /** 31 | * A base IMediator implementation. 32 | * 33 | * @see Core/View.hpp PureMVC::Core::View 34 | */ 35 | class PUREMVC_API Mediator 36 | : public virtual IMediator 37 | , public virtual INotifier 38 | , public Notifier 39 | { 40 | public: 41 | /** 42 | * Copy constructor. 43 | */ 44 | explicit Mediator(Mediator const& arg); 45 | 46 | public: 47 | /** 48 | * Constructor. 49 | */ 50 | Mediator(std::string const& mediator_name = Mediator::NAME, void const* view_component = NULL); 51 | 52 | /** 53 | * Get the name of the Mediator. 54 | */ 55 | virtual std::string const& getMediatorName(void) const; 56 | 57 | /** 58 | * Set the IMediator's view component. 59 | * 60 | * @param view_component the view component. 61 | */ 62 | virtual void setViewComponent(void const* view_component); 63 | 64 | /** 65 | * Get the Mediator's view component. 66 | * 67 | *

68 | * Additionally, an implicit getter will usually 69 | * be defined in the subclass that casts the view 70 | * object to a type

71 | * 72 | * @return the view component. 73 | */ 74 | virtual void const* getViewComponent(void) const; 75 | 76 | /** 77 | * List the INotification names this 78 | * Mediator is interested in being notified of. 79 | * 80 | * @return Array the list of INotification names. 81 | */ 82 | virtual Mediator::NotificationNames listNotificationInterests(void) const; 83 | 84 | /** 85 | * Handle INotifications. 86 | * 87 | *

88 | * Typically this will be handled in a switch statement, 89 | * with one 'case' entry per INotification 90 | * the Mediator is interested in. 91 | */ 92 | virtual void handleNotification(INotification const& notification); 93 | 94 | /** 95 | * Called by the View when the Mediator is registered. 96 | */ 97 | virtual void onRegister(void); 98 | 99 | /** 100 | * Called by the View when the Mediator is removed. 101 | */ 102 | virtual void onRemove(void); 103 | 104 | /** 105 | * Copy operator 106 | */ 107 | Mediator& operator=(Mediator const& arg); 108 | 109 | /** 110 | * Virtual destructor. 111 | */ 112 | virtual ~Mediator(void); 113 | 114 | /** 115 | * The name of the Mediator. 116 | * 117 | *

118 | * Typically, a Mediator will be written to serve 119 | * one specific control or group controls and so, 120 | * will not have a need to be dynamically named.

121 | */ 122 | protected: 123 | // the mediator name 124 | std::string _mediator_name; 125 | // The view component 126 | void const* _view_component; 127 | public: 128 | static char const* const NAME; 129 | }; 130 | } 131 | } 132 | 133 | #endif /* __PUREMVC_PATTERNS_MEDIATOR_MEDIATOR_HPP__ */ 134 | -------------------------------------------------------------------------------- /admin/py-compile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # py-compile - Compile a Python program 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2008, 2009 Free Software 7 | # Foundation, Inc. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | # This file is maintained in Automake, please report 28 | # bugs to or send patches to 29 | # . 30 | 31 | if [ -z "$PYTHON" ]; then 32 | PYTHON=python 33 | fi 34 | 35 | basedir= 36 | destdir= 37 | files= 38 | while test $# -ne 0; do 39 | case "$1" in 40 | --basedir) 41 | basedir=$2 42 | if test -z "$basedir"; then 43 | echo "$0: Missing argument to --basedir." 1>&2 44 | exit 1 45 | fi 46 | shift 47 | ;; 48 | --destdir) 49 | destdir=$2 50 | if test -z "$destdir"; then 51 | echo "$0: Missing argument to --destdir." 1>&2 52 | exit 1 53 | fi 54 | shift 55 | ;; 56 | -h|--h*) 57 | cat <<\EOF 58 | Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..." 59 | 60 | Byte compile some python scripts FILES. Use --destdir to specify any 61 | leading directory path to the FILES that you don't want to include in the 62 | byte compiled file. Specify --basedir for any additional path information you 63 | do want to be shown in the byte compiled file. 64 | 65 | Example: 66 | py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py 67 | 68 | Report bugs to . 69 | EOF 70 | exit $? 71 | ;; 72 | -v|--v*) 73 | echo "py-compile $scriptversion" 74 | exit $? 75 | ;; 76 | *) 77 | files="$files $1" 78 | ;; 79 | esac 80 | shift 81 | done 82 | 83 | if test -z "$files"; then 84 | echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 85 | exit 1 86 | fi 87 | 88 | # if basedir was given, then it should be prepended to filenames before 89 | # byte compilation. 90 | if [ -z "$basedir" ]; then 91 | pathtrans="path = file" 92 | else 93 | pathtrans="path = os.path.join('$basedir', file)" 94 | fi 95 | 96 | # if destdir was given, then it needs to be prepended to the filename to 97 | # byte compile but not go into the compiled file. 98 | if [ -z "$destdir" ]; then 99 | filetrans="filepath = path" 100 | else 101 | filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)" 102 | fi 103 | 104 | $PYTHON -c " 105 | import sys, os, py_compile 106 | 107 | files = '''$files''' 108 | 109 | sys.stdout.write('Byte-compiling python modules...\n') 110 | for file in files.split(): 111 | $pathtrans 112 | $filetrans 113 | if not os.path.exists(filepath) or not (len(filepath) >= 3 114 | and filepath[-3:] == '.py'): 115 | continue 116 | sys.stdout.write(file) 117 | sys.stdout.flush() 118 | py_compile.compile(filepath, filepath + 'c', path) 119 | sys.stdout.write('\n')" || exit $? 120 | 121 | # this will fail for python < 1.5, but that doesn't matter ... 122 | $PYTHON -O -c " 123 | import sys, os, py_compile 124 | 125 | files = '''$files''' 126 | sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n') 127 | for file in files.split(): 128 | $pathtrans 129 | $filetrans 130 | if not os.path.exists(filepath) or not (len(filepath) >= 3 131 | and filepath[-3:] == '.py'): 132 | continue 133 | sys.stdout.write(file) 134 | sys.stdout.flush() 135 | py_compile.compile(filepath, filepath + 'o', path) 136 | sys.stdout.write('\n')" 2>/dev/null || : 137 | 138 | # Local Variables: 139 | # mode: shell-script 140 | # sh-indentation: 2 141 | # eval: (add-hook 'write-file-hooks 'time-stamp) 142 | # time-stamp-start: "scriptversion=" 143 | # time-stamp-format: "%:y-%02m-%02d.%02H" 144 | # time-stamp-time-zone: "UTC" 145 | # time-stamp-end: "; # UTC" 146 | # End: 147 | -------------------------------------------------------------------------------- /admin/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltsugar.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 | 15 | 16 | # lt_join(SEP, ARG1, [ARG2...]) 17 | # ----------------------------- 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 | # associated separator. 20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 | # versions in m4sugar had bugs. 22 | m4_define([lt_join], 23 | [m4_if([$#], [1], [], 24 | [$#], [2], [[$2]], 25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 | m4_define([_lt_join], 27 | [m4_if([$#$2], [2], [], 28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 | 30 | 31 | # lt_car(LIST) 32 | # lt_cdr(LIST) 33 | # ------------ 34 | # Manipulate m4 lists. 35 | # These macros are necessary as long as will still need to support 36 | # Autoconf-2.59 which quotes differently. 37 | m4_define([lt_car], [[$1]]) 38 | m4_define([lt_cdr], 39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 | [$#], 1, [], 41 | [m4_dquote(m4_shift($@))])]) 42 | m4_define([lt_unquote], $1) 43 | 44 | 45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 | # ------------------------------------------ 47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 | # than defined and empty). 52 | # 53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 | m4_define([lt_append], 56 | [m4_define([$1], 57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 | 59 | 60 | 61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 | # ---------------------------------------------------------- 63 | # Produce a SEP delimited list of all paired combinations of elements of 64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 | # has the form PREFIXmINFIXSUFFIXn. 66 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 67 | m4_define([lt_combine], 68 | [m4_if(m4_eval([$# > 3]), [1], 69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 | [[m4_foreach([_Lt_prefix], [$2], 71 | [m4_foreach([_Lt_suffix], 72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 | 75 | 76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 | # ----------------------------------------------------------------------- 78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 | m4_define([lt_if_append_uniq], 81 | [m4_ifdef([$1], 82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 | [lt_append([$1], [$2], [$3])$4], 84 | [$5])], 85 | [lt_append([$1], [$2], [$3])$4])]) 86 | 87 | 88 | # lt_dict_add(DICT, KEY, VALUE) 89 | # ----------------------------- 90 | m4_define([lt_dict_add], 91 | [m4_define([$1($2)], [$3])]) 92 | 93 | 94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 | # -------------------------------------------- 96 | m4_define([lt_dict_add_subkey], 97 | [m4_define([$1($2:$3)], [$4])]) 98 | 99 | 100 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 | # ---------------------------------- 102 | m4_define([lt_dict_fetch], 103 | [m4_ifval([$3], 104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 | 107 | 108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 | # ----------------------------------------------------------------- 110 | m4_define([lt_if_dict_fetch], 111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 | [$5], 113 | [$6])]) 114 | 115 | 116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 | # -------------------------------------------------------------- 118 | m4_define([lt_dict_filter], 119 | [m4_if([$5], [], [], 120 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 | ]) 124 | -------------------------------------------------------------------------------- /src/PureMVC/Core/Model.cpp: -------------------------------------------------------------------------------- 1 | // Model.cpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #include "../Common.hpp" 10 | 11 | char const* const Model::MULTITON_MSG = 12 | "Model instance for this Multiton key already constructed!"; 13 | 14 | char const* const Model::DEFAULT_KEY = "PureMVC"; 15 | 16 | inline Model::ProxyMap::key_type const& 17 | Model::IteratorConverter::operator() 18 | (Model::ProxyMap::const_iterator const& iterator) const 19 | { 20 | return iterator->first; 21 | } 22 | 23 | inline Model::ProxyMap::const_iterator 24 | Model::IteratorRange::begin(Model::ProxyMap const* const& iterator) const 25 | { 26 | return iterator->begin(); 27 | } 28 | 29 | inline Model::ProxyMap::const_iterator 30 | Model::IteratorRange::end(Model::ProxyMap const* const& iterator) const 31 | { 32 | return iterator->end(); 33 | } 34 | 35 | IModel* Model::find(std::string const& key) 36 | { 37 | return puremvc_model_instance_map.find(key); 38 | } 39 | 40 | void Model::insert(std::string const& key, IModel* model) 41 | { 42 | puremvc_model_instance_map.insert(key, model); 43 | } 44 | 45 | Model::Model(std::string const& key) 46 | : _multiton_key(key) 47 | { 48 | if (puremvc_model_instance_map.find(_multiton_key)) 49 | throw std::runtime_error(MULTITON_MSG); 50 | puremvc_model_instance_map.insert(_multiton_key, this); 51 | initializeModel(); 52 | } 53 | 54 | inline void Model::initializeModel(void) 55 | { } 56 | 57 | IModel& Model::getInstance(std::string const& key) 58 | { 59 | IModel* result = puremvc_model_instance_map.find(key) ; 60 | if (result == NULL) 61 | { 62 | result = new Model(key); 63 | puremvc_model_instance_map.insert(std::make_pair(key, result)); 64 | } 65 | return *result; 66 | } 67 | 68 | void Model::registerProxy(IProxy* proxy) 69 | { 70 | proxy->initializeNotifier(_multiton_key); 71 | do 72 | { 73 | PureMVC::FastMutex::ScopedLock lock(_synchronous_access); 74 | ProxyMap::iterator result = _proxy_map.find(proxy->getProxyName()); 75 | _proxy_map.insert(std::make_pair(proxy->getProxyName(), (proxy))); 76 | }while (false); 77 | proxy->onRegister(); 78 | } 79 | 80 | IProxy const& Model::retrieveProxy(std::string const& proxy_name) const 81 | { 82 | PureMVC::FastMutex::ScopedLock lock(_synchronous_access); 83 | 84 | ProxyMap::const_iterator result = _proxy_map.find(proxy_name); 85 | if (result == _proxy_map.end()) 86 | throwException("Cannot find any proxy with name: [%s].", proxy_name.c_str()); 87 | 88 | return *result->second; 89 | } 90 | 91 | inline IProxy& Model::retrieveProxy(std::string const& proxy_name) 92 | { 93 | return const_cast(static_cast(*this).retrieveProxy(proxy_name)); 94 | } 95 | 96 | inline bool Model::hasProxy(std::string const& proxy_name) const 97 | { 98 | PureMVC::FastMutex::ScopedLock lock(_synchronous_access); 99 | return _proxy_map.find(proxy_name) != _proxy_map.end(); 100 | } 101 | 102 | IProxy* Model::removeProxy(std::string const& proxy_name) 103 | { 104 | ProxyMap::value_type::second_type proxy = NULL; 105 | 106 | do 107 | { 108 | PureMVC::FastMutex::ScopedLock lock(_synchronous_access); 109 | // Retrieve the named mediator 110 | ProxyMap::iterator result = _proxy_map.find(proxy_name); 111 | 112 | if (result == _proxy_map.end() ) 113 | break; 114 | 115 | // get mediator 116 | proxy = result->second; 117 | // remove the mediator from the map 118 | _proxy_map.erase(result); 119 | }while (false); 120 | 121 | if (proxy != NULL) proxy->onRemove(); 122 | return proxy; 123 | } 124 | 125 | void Model::removeModel(std::string const& key) 126 | { 127 | puremvc_model_instance_map.remove(key); 128 | } 129 | 130 | Model::ProxyNames Model::listProxyNames(void) const 131 | { 132 | typedef StdContainerAggregate result_t; 137 | #if defined(PUREMVC_USES_TR1) 138 | return std::unique_ptr >(new result_t(&_proxy_map)); 139 | #else 140 | return std::auto_ptr >(new result_t(&_proxy_map)); 141 | #endif 142 | } 143 | 144 | Model::~Model(void) 145 | { 146 | removeModel(_multiton_key); 147 | _proxy_map.clear(); 148 | } 149 | -------------------------------------------------------------------------------- /bakefile-intel-format-support/rules/FORMATS.bkmanifest: -------------------------------------------------------------------------------- 1 | 2 | 30 | 31 | 32 | 33 | GNU autoconf Makefile.in files 34 | Makefile.in 35 | 36 | 37 | 38 | OpenWatcom makefiles 39 | makefile.wat 40 | 41 | 42 | 43 | Borland C/C++ makefiles 44 | makefile.bcc 45 | 46 | 47 | 48 | MinGW makefiles (mingw32-make) 49 | makefile.gcc 50 | 51 | 52 | 53 | MS Visual C++ nmake makefiles 54 | makefile.vc 55 | 56 | 57 | 58 | MS Visual C++ 6.0 project files 59 | 60 | $(os.path.splitext(os.path.basename(INPUT_FILE))[0]).dsw 61 | 62 | 63 | 64 | 65 | MS eMbedded Visual C++ 4 project files 66 | 67 | $(os.path.splitext(os.path.basename(INPUT_FILE))[0]).vcw 68 | 69 | 70 | 71 | 72 | MS Visual Studio 2003 project files 73 | 74 | $(os.path.splitext(os.path.basename(INPUT_FILE))[0]).sln 75 | 76 | 77 | 78 | 79 | MS Visual Studio 2005 project files 80 | 81 | $(os.path.splitext(os.path.basename(INPUT_FILE))[0]).sln 82 | 83 | 84 | 85 | 86 | MS Visual Studio 2008 project files 87 | 88 | $(os.path.splitext(os.path.basename(INPUT_FILE))[0]).sln 89 | 90 | 91 | 92 | 93 | Digital Mars makefiles 94 | makefile.dmc 95 | 96 | 97 | 98 | Digital Mars makefiles for SMAKE 99 | makefile.dms 100 | 101 | 102 | 103 | GNU toolchain makefiles (Unix) 104 | GNUmakefile 105 | 106 | 107 | 108 | Xcode 2.4 project files 109 | 110 | $(os.path.splitext(os.path.basename(INPUT_FILE))[0]).xcodeproj 111 | 112 | 113 | 114 | 115 | Symbian development files 116 | bld.inf 117 | 118 | 119 | 120 | GNU makefiles for Sun CC compiler 121 | Makefile.suncc 122 | 123 | 124 | 125 | Intel C++ nmake makefiles base on MSVC 126 | makefile.icw 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /testsuite/include/tut/tut_assert.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TUT_ASSERT_H_GUARD 2 | #define TUT_ASSERT_H_GUARD 3 | 4 | #include "tut_exception.hpp" 5 | #include 6 | #include 7 | 8 | #if defined(TUT_USE_POSIX) 9 | #include 10 | #include 11 | #endif 12 | 13 | namespace tut 14 | { 15 | 16 | namespace detail 17 | { 18 | template 19 | std::ostream &msg_prefix(std::ostream &str, const M &msg) 20 | { 21 | std::stringstream ss; 22 | ss << msg; 23 | 24 | if(!ss.str().empty()) 25 | { 26 | str << ss.rdbuf() << ": "; 27 | } 28 | 29 | return str; 30 | } 31 | } 32 | 33 | 34 | namespace 35 | { 36 | 37 | /** 38 | * Tests provided condition. 39 | * Throws if false. 40 | */ 41 | void ensure(bool cond) 42 | { 43 | if (!cond) 44 | { 45 | // TODO: default ctor? 46 | throw failure(""); 47 | } 48 | } 49 | 50 | /** 51 | * Tests provided condition. 52 | * Throws if true. 53 | */ 54 | void ensure_not(bool cond) 55 | { 56 | ensure(!cond); 57 | } 58 | 59 | /** 60 | * Tests provided condition. 61 | * Throws if false. 62 | */ 63 | template 64 | void ensure(const M& msg, bool cond) 65 | { 66 | if (!cond) 67 | { 68 | throw failure(msg); 69 | } 70 | } 71 | 72 | /** 73 | * Tests provided condition. 74 | * Throws if true. 75 | */ 76 | template 77 | void ensure_not(const M& msg, bool cond) 78 | { 79 | ensure(msg, !cond); 80 | } 81 | 82 | /** 83 | * Tests two objects for being equal. 84 | * Throws if false. 85 | * 86 | * NB: both T and Q must have operator << defined somewhere, or 87 | * client code will not compile at all! 88 | */ 89 | template 90 | void ensure_equals(const M& msg, const LHS& actual, const RHS& expected) 91 | { 92 | if (expected != actual) 93 | { 94 | std::stringstream ss; 95 | detail::msg_prefix(ss,msg) 96 | << "expected '" 97 | << expected 98 | << "' actual '" 99 | << actual 100 | << '\''; 101 | throw failure(ss.str()); 102 | } 103 | } 104 | 105 | template 106 | void ensure_equals(const LHS& actual, const RHS& expected) 107 | { 108 | ensure_equals("Values are not equal", actual, expected); 109 | } 110 | 111 | template 112 | void ensure_equals(const M& msg, const double& actual, const double& expected, 113 | const double& epsilon = std::numeric_limits::epsilon()) 114 | { 115 | const double diff = actual - expected; 116 | 117 | if ( !((diff <= epsilon) && (diff >= -epsilon )) ) 118 | { 119 | std::stringstream ss; 120 | detail::msg_prefix(ss,msg) 121 | << std::scientific 122 | << std::showpoint 123 | << std::setprecision(16) 124 | << "expected " << expected 125 | << " actual " << actual 126 | << " with precision " << epsilon; 127 | throw failure(ss.str()); 128 | } 129 | } 130 | /** 131 | * Tests two objects for being at most in given distance one from another. 132 | * Borders are excluded. 133 | * Throws if false. 134 | * 135 | * NB: T must have operator << defined somewhere, or 136 | * client code will not compile at all! Also, T shall have 137 | * operators + and -, and be comparable. 138 | * 139 | * TODO: domains are wrong, T - T might not yield T, but Q 140 | */ 141 | template 142 | void ensure_distance(const M& msg, const T& actual, const T& expected, const T& distance) 143 | { 144 | if (expected-distance >= actual || expected+distance <= actual) 145 | { 146 | std::stringstream ss; 147 | detail::msg_prefix(ss,msg) 148 | << " expected (" 149 | << expected-distance 150 | << " - " 151 | << expected+distance 152 | << ") actual '" 153 | << actual 154 | << '\''; 155 | throw failure(ss.str()); 156 | } 157 | } 158 | 159 | template 160 | void ensure_distance(const T& actual, const T& expected, const T& distance) 161 | { 162 | ensure_distance<>("Distance is wrong", actual, expected, distance); 163 | } 164 | 165 | template 166 | void ensure_errno(const M& msg, bool cond) 167 | { 168 | if(!cond) 169 | { 170 | #if defined(TUT_USE_POSIX) 171 | char e[512]; 172 | std::stringstream ss; 173 | detail::msg_prefix(ss,msg) 174 | << strerror_r(errno, e, sizeof(e)); 175 | throw failure(ss.str()); 176 | #else 177 | throw failure(msg); 178 | #endif 179 | } 180 | } 181 | 182 | /** 183 | * Unconditionally fails with message. 184 | */ 185 | void fail(const char* msg = "") 186 | { 187 | throw failure(msg); 188 | } 189 | 190 | template 191 | void fail(const M& msg) 192 | { 193 | throw failure(msg); 194 | } 195 | 196 | } // end of namespace 197 | 198 | } 199 | 200 | #endif 201 | 202 | -------------------------------------------------------------------------------- /include/PureMVC/Interfaces/IMediator.hpp: -------------------------------------------------------------------------------- 1 | // IMediator.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_INTERFACES_IMEDIATOR_HPP__) 10 | #define __PUREMVC_INTERFACES_IMEDIATOR_HPP__ 11 | 12 | // STL include 13 | #include 14 | // PureMVC include 15 | #if !defined(__PUREMVC_HPP__) 16 | #define __PUREMVC_INCLUDE__ 17 | #include "../PureMVC.hpp" 18 | #endif /* __PUREMVC_HPP__ */ 19 | 20 | #include "INotifier.hpp" 21 | #include "IAggregate.hpp" 22 | 23 | namespace PureMVC 24 | { 25 | namespace Interfaces 26 | { 27 | /** 28 | * The interface definition for a PureMVC Mediator. 29 | * 30 | *

31 | * In PureMVC, IMediator implementors assume these responsibilities:

32 | *
    33 | *
  • Implement a common method which returns a list of all INotifications 34 | * the IMediator has interest in.
  • 35 | *
  • Implement a notification callback method.
  • 36 | *
  • Implement methods that are called when the IMediator is registered or removed from the View.
  • 37 | *
38 | *

39 | * Additionally, IMediators typically: 40 | *

    41 | *
  • Act as an intermediary between one or more view components such as text boxes or 42 | * list controls, maintaining references and coordinating their behavior.
  • 43 | *
  • In Flash-based apps, this is often the place where event listeners are 44 | * added to view components, and their handlers implemented.
  • 45 | *
  • Respond to and generate INotifications, interacting with of 46 | * the rest of the PureMVC app. 47 | *

48 | *

49 | * When an IMediator is registered with the IView, 50 | * the IView will call the IMediator's 51 | * listNotificationInterests method. The IMediator will 52 | * return an Array of INotification names which 53 | * it wishes to be notified about.

54 | * 55 | *

56 | * The IView will then create an Observer object 57 | * encapsulating that IMediator's (handleNotification) method 58 | * and register it as an Observer for each INotification name returned by 59 | * listNotificationInterests.

60 | * 61 | * @see Interfaces/INotification.hpp PureMVC::Interfaces::INotification 62 | */ 63 | struct PUREMVC_API IMediator : public virtual INotifier 64 | { 65 | #if defined(PUREMVC_USES_TR1) 66 | typedef std::unique_ptr > NotificationNames; 67 | #else 68 | typedef std::auto_ptr > NotificationNames; 69 | #endif 70 | 71 | /** 72 | * Get the IMediator instance name 73 | * 74 | * @return the IMediator instance name 75 | */ 76 | virtual std::string const& getMediatorName(void) const = 0; 77 | 78 | /** 79 | * Get the IMediator's view component. 80 | * 81 | * @return the view component 82 | */ 83 | virtual void const* getViewComponent(void) const = 0; 84 | 85 | /** 86 | * Set the IMediator's view component. 87 | * 88 | * @param view_component the void const* view component 89 | */ 90 | virtual void setViewComponent(void const* view_component) = 0; 91 | 92 | /** 93 | * List INotification interests. 94 | * 95 | * @return an std::list of the INotification names this IMediator has an interest in. 96 | */ 97 | virtual NotificationNames listNotificationInterests(void) const = 0; 98 | 99 | /** 100 | * Handle an INotification. 101 | * 102 | * @param notification the INotification to be handled 103 | */ 104 | virtual void handleNotification(INotification const& notification) = 0; 105 | 106 | /** 107 | * Called by the View when the Mediator is registered 108 | */ 109 | virtual void onRegister(void) = 0; 110 | 111 | /** 112 | * Called by the View when the Mediator is removed 113 | */ 114 | virtual void onRemove(void) = 0; 115 | 116 | /** 117 | * Virtual destructor. 118 | */ 119 | virtual ~IMediator(void); 120 | }; 121 | } 122 | } 123 | 124 | #endif /* __PUREMVC_INTERFACES_IMEDIATOR_HPP__ */ 125 | -------------------------------------------------------------------------------- /include/PureMVC/Patterns/Observer/Observer.hpp: -------------------------------------------------------------------------------- 1 | // Observer.hpp 2 | // PureMVC_C++ 3 | // 4 | // PureMVC Port to C++ by Tang Khai Phuong 5 | // PureMVC - Copyright(c) 2006-2011 Futurescale, Inc., Some rights reserved. 6 | // Your reuse is governed by the Creative Commons Attribution 3.0 License 7 | // 8 | 9 | #if !defined(__PUREMVC_PATTERNS_OBSERVER_OBSERVER_HPP__) 10 | #define __PUREMVC_PATTERNS_OBSERVER_OBSERVER_HPP__ 11 | 12 | // STL include 13 | #include 14 | #include 15 | // PureMVC include 16 | #if !defined(__PUREMVC_HPP__) 17 | #define __PUREMVC_INCLUDE__ 18 | #include "../../PureMVC.hpp" 19 | #endif /* __PUREMVC_HPP__ */ 20 | 21 | #include "../../Interfaces/IObserver.hpp" 22 | 23 | namespace PureMVC 24 | { 25 | namespace Patterns 26 | { 27 | using Interfaces::IObserver; 28 | 29 | /** 30 | * A base IObserver implementation. 31 | * 32 | *

33 | * An Observer is an object that encapsulates information 34 | * about an interested object with a method that should 35 | * be called when a particular INotification is broadcast.

36 | * 37 | *

38 | * In PureMVC, the Observer class assumes these responsibilities: 39 | *

    40 | *
  • Encapsulate the notification (callback) method of the interested object.
  • 41 | *
  • Encapsulate the notification context (this) of the interested object.
  • 42 | *
  • Provide methods for setting the notification method and context.
  • 43 | *
  • Provide a method for notifying the interested object.
  • 44 | *
45 | * 46 | * @see Core/View.hpp View 47 | * @see Patterns/Observer/Notification.hpp Notification 48 | */ 49 | template 50 | class Observer : public IObserver 51 | { 52 | private: 53 | Observer(void); 54 | public: 55 | /** 56 | * Copy constructor 57 | */ 58 | explicit Observer(Observer const& arg) 59 | : IObserver() 60 | , _notify_method(arg._notify_method) 61 | , _notify_context(arg._notify_context) 62 | { } 63 | 64 | public: 65 | /** 66 | * Constructor. 67 | * 68 | *

69 | * The notification method on the interested object should take 70 | * one parameter of type INotification

71 | * 72 | * @param notify_method the notification method of the interested object 73 | * @param notify_context the notification context of the interested object 74 | */ 75 | explicit Observer(_Method notify_method, _Context* notify_context) 76 | : IObserver() 77 | , _notify_method(notify_method) 78 | , _notify_context(notify_context) 79 | { } 80 | 81 | /** 82 | * Notify the interested object. 83 | * 84 | * @param notification the INotification to pass to the interested object's notification method. 85 | */ 86 | virtual void notifyObserver(INotification const& notification) 87 | { 88 | if (_notify_context == NULL) 89 | throw std::runtime_error("Notify context is null."); 90 | if (_notify_method == NULL) 91 | throw std::runtime_error("Notify method is null."); 92 | (*_notify_context.*_notify_method)(notification); 93 | } 94 | 95 | /** 96 | * Compare an object to the notification context. 97 | * 98 | * @param object the object to compare. 99 | * @return boolean indicating if the object and the notification context are the same. 100 | */ 101 | virtual bool compareNotifyContext(void const* object) const 102 | { 103 | return _notify_context == object; 104 | } 105 | 106 | /** 107 | * Copy operator. 108 | */ 109 | Observer& operator=(Observer const& arg) 110 | { 111 | _notify_method = arg._notify_method; 112 | _notify_context = arg._notify_context; 113 | return *this; 114 | } 115 | 116 | /** 117 | * Virtual destructor. 118 | */ 119 | virtual ~Observer(void) 120 | { } 121 | private: 122 | _Method _notify_method; 123 | _Context* _notify_context; 124 | }; 125 | 126 | /** 127 | * Create new observer. 128 | */ 129 | template 130 | inline IObserver* createObserver(_Method notify_method, _Context* notify_context) 131 | { 132 | return new Observer<_Method, _Context>(notify_method, notify_context); 133 | } 134 | 135 | /** 136 | * Make an observer. 137 | */ 138 | template 139 | inline Observer<_Method, _Context> makeObserver(_Method notify_method, _Context* notify_context) 140 | { 141 | return Observer<_Method, _Context>(notify_method, notify_context); 142 | } 143 | } 144 | } 145 | 146 | #endif /* __PUREMVC_PATTERNS_OBSERVER_OBSERVER_HPP__ */ 147 | --------------------------------------------------------------------------------