[Design mode] Command design mode in NETD, listener mode in Networkmanagementservice

Source: Internet
Author: User

The following roles are available in the command pattern:

(1) Caller (invoker)

(2) Command receiver (receiver)

(3) clients (client)

(4) Command object

1  Public InterfaceCommand {2      Public voidexecute ();3 }4  Public classConcretecommandImplementsCommand {5 6     PrivateReceiver receiver =NULL;7     PrivateString State;8 9      PublicConcretecommand (receiver receiver) {Ten         This. Receiver =receiver; One     }   A      Public voidExecute () { - receiver.action (); -     } the } -  -  -  Public classReceiver { +      Public voidaction () { -        //function code that actually executes the command operation +     } A } at  -  Public classInvoker { -     PrivateCommand command =NULL; -  -      Public voidsetcommand (Command command) { -         This. Command =command; in     } -  to      Public voidRunCommand () { + Command.Execute (); -     } the } *  $  Public classClient {Panax Notoginseng      Public voidAssemble () { -        //Create a recipient theReceiver receiver =NewReceiver (); +        //Create a Command object, set its recipient ACommand command =NewConcretecommand (receiver); the        //Create a invoker and set the Command object in +Invoker Invoker =NewInvoker (); - invoker.setcommand (command); $     } $}

In netd command mode, both the client role and the invoker role are Commandlistener

Receiver is a variety of controllers in the Commandlistener, including

Firewallcontroller *commandlistener::sfirewallctrl = NULL;

Unlike the command pattern above, the various commands are Commandlistener internal classes that can be used directly with receiver without passing receiver to the Command object. A different point is that the various controllers here as receiver do not have the same action function as the example, but are directly in the RunCommand function (example is the Execute function of the command Class) Use the controller to implement various actions.

The various command distribution paths for NETD are as follows:

Socketlistener::runlistener

->fameworklistener::ondataavailable

-Fameworklistener::d Ispatchcommand

-Commandlistener:: Various Cmd::runcommand

(All rights reserved, reprint please inform)

[Design mode] Command design mode in NETD, listener mode in Networkmanagementservice

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.