亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pat5b.htm

?? java設計范式.rar
?? HTM
?? 第 1 頁 / 共 2 頁
字號:
any other object.  Somewhere in between these extremes are commandsthat have enough knowledge to find their receiver dynamically.</LI><A NAME="auto1052"></A><P></P><A NAME="supp-undo-redo"></A><LI><EM>Supporting undo and redo.</EM>Commands can support undo and redo capabilities if they provide a wayto reverse their execution (e.g., an Unexecute or Undo operation).  AConcreteCommand class might need to store additional state to do so.  Thisstate can include</LI><A NAME="auto1053"></A><P></P><UL><A NAME="receive-part-command2"></A><LI>the Receiver object, which actually carries out operations inresponse to the request,</LI><A NAME="auto1054"></A><P></P><A NAME="auto1055"></A><LI>the arguments to the operation performed on the receiver, and</LI><A NAME="auto1056"></A><P></P><A NAME="auto1057"></A><LI>any original values in the receiver that can changeas a result of handling the request.  The receiver must provideoperations that let the command return the receiver to its prior state.</LI></UL><A NAME="auto1058"></A><P></P><A NAME="auto1059"></A><P>To support one level of undo, an application needs to store only thecommand that was executed last.  For multiple-level undo and redo, theapplication needs a <STRONG>history list</STRONG> of commands that havebeen executed, where the maximum length of the list determines thenumber of undo/redo levels.  The history list stores sequences ofcommands that have been executed.  Traversing backward through thelist and reverse-executing commands cancels their effect; traversingforward and executing commands reexecutes them.</P><A NAME="auto1060"></A><P>An undoable command might have to be copied before it can be placed onthe history list.  That's because the command object that carried outthe original request, say, from a MenuItem, will perform otherrequests at later times.  Copying is required to distinguish differentinvocations of the same command if its state can vary acrossinvocations.</P><A NAME="proto-w-command"></A><P>For example, a DeleteCommand that deletes selected objects must storedifferent sets of objects each time it's executed.  Therefore theDeleteCommand object must be copied following execution, and the copyis placed on the history list.  If the command's state never changeson execution, then copying is not required&#151;only a reference to thecommand need be placed on the history list.  Commands that must becopied before being placed on the history list act as prototypes (see<A HREF="pat3dfs.htm" TARGET="_mainDisplayFrame">Prototype (117)</A>).</P><A NAME="avoid-error"></A><LI><EM>Avoiding error accumulation in the undo process.</EM>Hysteresis can be a problem in ensuring a reliable,semantics-preserving undo/redo mechanism.  Errors can accumulate ascommands are executed, unexecuted, and reexecuted repeatedly so thatan application's state eventually diverges from original values.  Itmay be necessary therefore to store more information in the command toensure that objects are restored to their original state.  The<A HREF="pat5ffs.htm" TARGET="_mainDisplayFrame">Memento (283)</A> pattern can be applied to give the commandaccess to this information without exposing the internals of otherobjects.</LI><A NAME="auto1061"></A><P></P><A NAME="template-implement"></A><LI><EM>Using C++ templates.</EM>For commands that (1) aren't undoable and (2) don't require arguments,we can use C++ templates to avoid creating a Command subclass forevery kind of action and receiver.  We show how to do this in the SampleCode section.</LI></OL><A NAME="samplecode"><A><H2><A HREF="#knownuses"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Known Uses"></A> Sample Code</H2> <A NAME="auto1062"></A><P>The C++ code shown here sketches the implementation of the Command classesin the Motivation section.  We'll define <CODE>OpenCommand</CODE>,<CODE>PasteCommand</CODE>, and <CODE>MacroCommand</CODE>.  First theabstract <CODE>Command</CODE> class:</P><A NAME="auto1063"></A><PRE>    class Command {    public:        virtual ~Command();            virtual void Execute() = 0;    protected:        Command();    };</PRE><A NAME="auto1064"></A><P><CODE>OpenCommand</CODE> opens a document whose name is supplied by theuser.  An <CODE>OpenCommand</CODE> must be passed an<CODE>Application</CODE> object in its constructor.  <CODE>AskUser</CODE> is animplementation routine that prompts the user for the name of thedocument to open.</P><A NAME="auto1065"></A><PRE>    class OpenCommand : public Command {    public:        OpenCommand(Application*);            virtual void Execute();    protected:        virtual const char* AskUser();    private:        Application* _application;        char* _response;    };        OpenCommand::OpenCommand (Application* a) {        _application = a;    }        void OpenCommand::Execute () {        const char* name = AskUser();            if (name != 0) {            Document* document = new Document(name);            _application->Add(document);            document->Open();        }    }</PRE><A NAME="auto1066"></A><P>A <CODE>PasteCommand</CODE> must be passed a <CODE>Document</CODE> object asits receiver.  The receiver is given as a parameter to <CODE>PasteCommand</CODE>'sconstructor.</P><A NAME="auto1067"></A><PRE>    class PasteCommand : public Command {    public:        PasteCommand(Document*);            virtual void Execute();    private:        Document* _document;    };        PasteCommand::PasteCommand (Document* doc) {        _document = doc;    }        void PasteCommand::Execute () {        _document->Paste();    }</PRE><A NAME="auto1068"></A><P>For simple commands that aren't undoable and don't require arguments,we can use a class template to parameterize the command's receiver.We'll define a template subclass <CODE>SimpleCommand</CODE> for suchcommands. <CODE>SimpleCommand</CODE> is parameterized by the<CODE>Receiver</CODE> type and maintains a binding between a receiver objectand an action stored as a pointer to a member function.</P><A NAME="auto1069"></A><PRE>    template &lt;class Receiver>    class SimpleCommand : public Command {    public:        typedef void (Receiver::* Action)();            SimpleCommand(Receiver* r, Action a) :            _receiver(r), _action(a) { }            virtual void Execute();    private:        Action _action;        Receiver* _receiver;    };</PRE><A NAME="auto1070"></A><P>The constructor stores the receiver and the action in the correspondinginstance variables. <CODE>Execute</CODE> simply applies the action to thereceiver.</P><A NAME="auto1071"></A><PRE>    template &lt;class Receiver>    void SimpleCommand&ltReceiver>::Execute () {        (_receiver->*_action)();    }</PRE><A NAME="auto1072"></A><P>To create a command that calls <CODE>Action</CODE>on an instance of class <CODE>MyClass</CODE>, a client simply writes</P><A NAME="auto1073"></A><PRE>    MyClass* receiver = new MyClass;    // ...    Command* aCommand =        new SimpleCommand&lt;MyClass>(receiver, &amp;MyClass::Action);    // ...    aCommand->Execute();</PRE><A NAME="auto1074"></A><P>Keep in mind that this solution only works for simple commands.  Morecomplex commands that keep track of not only their receivers but alsoarguments and/or undo state require a <CODE>Command</CODE> subclass.</P><A NAME="macrocommand2"></A><P>A <CODE>MacroCommand</CODE> manages a sequence of subcommands and providesoperations for adding and removing subcommands.  No explicit receiveris required, because the subcommands already define their receiver.</P><A NAME="auto1075"></A><PRE>    class MacroCommand : public Command {    public:        MacroCommand();        virtual ~MacroCommand();            virtual void Add(Command*);        virtual void Remove(Command*);            virtual void Execute();    private:        List&lt;Command*>* _cmds;    };</PRE><A NAME="auto1076"></A><P>The key to the <CODE>MacroCommand</CODE> is its <CODE>Execute</CODE> memberfunction. This traverses all the subcommands and performs<CODE>Execute</CODE> on each of them.</P><A NAME="auto1077"></A><PRE>    void MacroCommand::Execute () {        ListIterator&lt;Command*> i(_cmds);            for (i.First(); !i.IsDone(); i.Next()) {            Command* c = i.CurrentItem();            c->Execute();        }    }</PRE><A NAME="auto1078"></A><P>Note that should the <CODE>MacroCommand</CODE> implement an<CODE>Unexecute</CODE> operation, then its subcommands must beunexecuted in <EM>reverse</EM> order relative to <CODE>Execute</CODE>'simplementation.</P><A NAME="auto1079"></A><P>Finally, <CODE>MacroCommand</CODE> must provide operations to manage itssubcommands.  The <CODE>MacroCommand</CODE> is also responsible fordeleting its subcommands.</P><A NAME="auto1080"></A><PRE>    void MacroCommand::Add (Command* c) {        _cmds->Append(c);    }        void MacroCommand::Remove (Command* c) {        _cmds->Remove(c);    }</PRE><A NAME="knownuses"><A><H2><A HREF="#relatedpatterns"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Related Patterns"></A> Known Uses</H2> <A NAME="unidraw-use-comm"></A><P>Perhaps the first example of the Command pattern appears in a paper byLieberman [<A HREF="bibfs.htm#lieberman_menus" TARGET="_mainDisplayFrame">Lie85</A>].  MacApp [<A HREF="bibfs.htm#macapp" TARGET="_mainDisplayFrame">App89</A>] popularizedthe notion of commands for implementing undoable operations.ET++ [<A HREF="bibfs.htm#et++" TARGET="_mainDisplayFrame">WGM88</A>], InterViews [<A HREF="bibfs.htm#InterViews3.1" TARGET="_mainDisplayFrame">LCI+92</A>], andUnidraw [<A HREF="bibfs.htm#unidraw_framework" TARGET="_mainDisplayFrame">VL90</A>] also define classes that follow theCommand pattern. InterViews defines an Action abstract class thatprovides command functionality. It also defines an ActionCallbacktemplate, parameterized by action method, that can instantiate commandsubclasses automatically.</P><A NAME="think-use-comm"></A><P>The THINK class library [<A HREF="bibfs.htm#think" TARGET="_mainDisplayFrame">Sym93b</A>] also uses commands to supportundoable actions.  Commands in THINK are called "Tasks."  Taskobjects are passed along a <A HREF="pat5afs.htm" TARGET="_mainDisplayFrame">Chain of Responsibility (223)</A>for consumption.</P><A NAME="auto1081"></A><P>Unidraw's command objects are unique in that they can behave likemessages.  A Unidraw command may be sent to another object forinterpretation, and the result of the interpration varies with thereceiving object.  Moreover, the receiver may delegate theinterpretation to another object, typically the receiver's parent in alarger structure as in a Chain of Responsibility.  The receiver of aUnidraw command is thus computed rather than stored.  Unidraw'sinterpretation mechanism depends on run-time type information.</P><A NAME="functor"></A><P>Coplien describes how to implement <STRONG>functors</STRONG>, objects thatare functions, in C++ [<A HREF="bibfs.htm#coplien_idioms" TARGET="_mainDisplayFrame">Cop92</A>].  He achieves a degree oftransparency in their use by overloading the function call operator(<CODE>operator()</CODE>).  The Command pattern is different; its focusis on maintaining a <EM>binding between</EM> a receiver and a function(i.e., action), not just maintaining a function.</P><A NAME="relatedpatterns"></A><H2><A HREF="#last"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: navigation"></A> Related Patterns</H2> <A NAME="auto1082"></A><P>A <A HREF="pat4cfs.htm" TARGET="_mainDisplayFrame">Composite (163)</A>can be used to implement MacroCommands.</P><A NAME="auto1083"></A><P>A <A HREF="pat5ffs.htm" TARGET="_mainDisplayFrame">Memento (283)</A>can keep state the command requires to undo its effect.</P><A NAME="auto1084"></A><P>A command that must be copied before being placed on the historylist acts as a <A HREF="pat3dfs.htm"TARGET="_mainDisplayFrame">Prototype (117)</A>.</P><A NAME="last"></A><P><A HREF="#intent"><IMG SRC="gifsb/up3.gif" BORDER=0></A><BR><A HREF="pat5cfs.htm" TARGET="_mainDisplayFrame"><IMG SRC="gifsb/rightar3.gif"        ALIGN=TOP BORDER=0></A> <A HREF="pat5cfs.htm"        TARGET="_mainDisplayFrame">Interpreter</A><BR><A HREF="pat5afs.htm" TARGET="_mainDisplayFrame"><IMG SRC="gifsb/leftarr3.gif"        ALIGN=TOP BORDER=0></A> <A HREF="pat5afs.htm"        TARGET="_mainDisplayFrame">Chain of Responsibility</A></P></BODY></HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合视频在线观看| 精品av久久707| 日韩欧美123| 中文字幕亚洲电影| 久久疯狂做爰流白浆xx| 91在线精品一区二区| 精品成人私密视频| 亚洲国产成人av网| 成人av高清在线| 精品粉嫩超白一线天av| 亚洲国产精品麻豆| 91麻豆swag| 久久精品亚洲乱码伦伦中文| 日韩精品久久久久久| 在线视频你懂得一区二区三区| 精品国产免费一区二区三区香蕉| 亚洲制服丝袜av| 99久久综合色| 国产精品欧美一区喷水| 国产一区二区在线视频| 日韩一卡二卡三卡四卡| 午夜精品一区在线观看| 色欧美片视频在线观看| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 国产91色综合久久免费分享| 日韩视频一区二区| 日韩电影免费在线观看网站| 欧美男同性恋视频网站| 亚洲444eee在线观看| 欧美羞羞免费网站| 亚洲欧美一区二区三区极速播放| www.欧美精品一二区| 中文字幕一区二区视频| 91美女片黄在线观看91美女| 亚洲天堂a在线| 色综合天天综合网国产成人综合天| 国产精品少妇自拍| 成人午夜激情片| 亚洲视频一区在线观看| 日本精品一级二级| 亚洲午夜精品一区二区三区他趣| 91国偷自产一区二区使用方法| 怡红院av一区二区三区| 色av综合在线| 免费在线观看视频一区| 精品免费国产一区二区三区四区| 久久99精品久久久久| 国产日韩综合av| 本田岬高潮一区二区三区| 亚洲欧美一区二区三区极速播放 | 成人欧美一区二区三区视频网页| 99久久精品99国产精品| 亚洲精品成人天堂一二三| 在线一区二区观看| 裸体健美xxxx欧美裸体表演| 国产亚洲一本大道中文在线| 成人中文字幕电影| 亚洲一区二区精品久久av| 欧美一区二区人人喊爽| 国产精品影视网| 夜夜亚洲天天久久| 日韩欧美资源站| av资源站一区| 亚洲国产欧美日韩另类综合 | 国产精品丝袜一区| 色菇凉天天综合网| 免费在线看成人av| 亚洲免费观看高清完整版在线观看 | 国产精品免费视频网站| 在线亚洲一区观看| 另类小说欧美激情| 亚洲欧洲精品天堂一级| 欧美电影影音先锋| 岛国精品在线观看| 麻豆一区二区99久久久久| 国产精品天干天干在线综合| 欧美丰满嫩嫩电影| 99久久99久久综合| 蜜臀国产一区二区三区在线播放| 日本一区二区三区视频视频| 欧美精品在线一区二区三区| 成人va在线观看| 激情综合网av| 亚洲www啪成人一区二区麻豆 | 欧美电影免费观看高清完整版在线 | 欧美日韩和欧美的一区二区| 国产九九视频一区二区三区| 亚洲不卡在线观看| 1区2区3区国产精品| 久久精品一区二区三区四区| 911精品产国品一二三产区| 99r精品视频| 国产98色在线|日韩| 日韩成人免费电影| 一区二区三区精品| 中文字幕一区在线观看| 久久婷婷成人综合色| 日韩一区二区视频在线观看| 欧洲日韩一区二区三区| 99re在线视频这里只有精品| 国产成a人无v码亚洲福利| 韩国中文字幕2020精品| 青椒成人免费视频| 天天色图综合网| 亚洲自拍与偷拍| 亚洲人妖av一区二区| 日本一区二区动态图| 久久在线免费观看| 欧美成人video| 日韩免费看的电影| 精品对白一区国产伦| 精品国产乱码久久久久久久久| 日韩三级伦理片妻子的秘密按摩| 欧美高清视频一二三区 | 色综合久久88色综合天天6 | 欧美久久久久中文字幕| 欧美综合视频在线观看| 在线观看一区二区精品视频| 一本大道久久a久久精品综合| 99re成人精品视频| 99精品桃花视频在线观看| 色偷偷88欧美精品久久久| 一本色道久久综合亚洲91| 日本精品裸体写真集在线观看| 欧美在线啊v一区| 欧美性猛片xxxx免费看久爱| 欧美精品自拍偷拍| 欧美va天堂va视频va在线| 久久久三级国产网站| 中文成人av在线| 亚洲视频在线一区观看| 一级精品视频在线观看宜春院 | 777亚洲妇女| 日韩欧美视频一区| 亚洲精品一区二区三区精华液 | 国产精品色哟哟| 亚洲视频资源在线| 日韩极品在线观看| 国产一区二区三区国产| 成人黄色在线网站| 在线观看一区日韩| 欧美一区二区三区爱爱| 国产精品素人一区二区| 午夜一区二区三区在线观看| 久久国产精品99精品国产| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 亚洲成av人片观看| 国产精品白丝jk黑袜喷水| 97久久精品人人做人人爽50路| 在线看一区二区| www精品美女久久久tv| 亚洲欧美激情在线| 奇米影视一区二区三区| 成人h精品动漫一区二区三区| 在线观看国产日韩| 久久精品免视看| 亚洲成人免费电影| 国产成人av电影在线| 这里只有精品电影| 国产精品国产三级国产普通话99| 一区二区三区精品在线观看| 国产精品资源网| 制服丝袜亚洲精品中文字幕| 国产精品女同一区二区三区| 五月婷婷综合激情| zzijzzij亚洲日本少妇熟睡| 国产欧美一区二区精品性色| 夜夜精品视频一区二区 | 欧美成人a∨高清免费观看| 国产免费成人在线视频| 蜜臀av一区二区在线观看| 91麻豆产精品久久久久久| 欧美成人猛片aaaaaaa| 亚洲国产精品自拍| 成人午夜电影网站| 精品国产自在久精品国产| 亚洲一区二区三区视频在线| jiyouzz国产精品久久| 精品国产免费久久| 婷婷开心久久网| 在线亚洲欧美专区二区| 国产精品国产三级国产专播品爱网| 秋霞影院一区二区| 色综合天天综合网天天看片| 国产精品久久久久影院色老大| 日本三级韩国三级欧美三级| 在线观看www91| 亚洲精品免费视频| 成人精品视频一区| 久久人人爽爽爽人久久久| 日本特黄久久久高潮| 666欧美在线视频| 天天爽夜夜爽夜夜爽精品视频| 91福利在线免费观看| 一区二区三区中文字幕电影| 国产99一区视频免费| 国产欧美1区2区3区| 国产成a人亚洲精品| 国产女主播一区| 菠萝蜜视频在线观看一区|