Mapping Dialogs

From OO Lab
Jump to: navigation, search

Back

GRADE F : Miss the point and do not follow the template

Author: chinhao

Mapping Dialog

This page will introduce Mapping Dialog, the view part of DIVA for user interaction. Based on Win32 APIs.

Dialog Description

The Dialogs is as follow:

1. Ari Select Dialog

2. ASCII Dialog

3. Dynamic Layout Dialog

4. DynDlgProc?

5. Exp Dialog

6. Layout Menu Dialog

7. Make VM Dialog

8. Math Dialog

9. Neo Dialog

This is the main dialog, most of the implementation is in NeoManager?.

It use the buttonCommandHandler method to open other dialog.

10. Port Setting Dialog

11. Set Gates name Proc

12. Static Layout Dialog

13. String Composer Dialog

14. VM Select Dialog

Trace Entry

First, we start at DIVA_Main.cpp with the method createSever

This method will receive the command from Minerva, and call the Command_Agent instance to do the visualize and other stuff.

unsigned __stdcall createSever(void*) { 
/// 建立server thread port 2000, 容許同時5連線 SocketServer in(2000,5);
/// 接收連線 Socket* s=in.Accept();
while (1) { std::string r = s->ReceiveLine(); assert(r.length() > 0);
/// 先以換行為分隔 再以空格為分隔 std::vector<std::string> returnMsg = Command_Agent::getInstance()->stringSplit(r,NEWLINE); returnMsg = Command_Agent::getInstance()->stringSplit(*(returnMsg.begin()),BLANK);
/// 取得指令 std::vector<std::string>::iterator itr = returnMsg.begin();
if ((*itr).find(CMD_VISUALIZE)  != (*itr).npos) /// visualize { DIVA_Manager::getInstance()->lock(); Command_Agent::getInstance()->visualize(*(itr+1)); DIVA_Manager::getInstance()->release(); } else if (((*itr).find(CMD_UNFOLD3D)  != (*itr).npos) || ((*itr).find(CMD_UNFOLD2D)  != (*itr).npos) || ((*itr).find(CMD_UNFOLD1D)  != (*itr).npos) )/// unfold array { DIVA_Manager::getInstance()->lock(); Command_Agent::getInstance()->unfoldArray(r); DIVA_Manager::getInstance()->release(); } else if ((*itr).find(CMD_UNFOLD) != (*itr).npos) /// unfoldRef { DIVA_Manager::getInstance()->lock(); Command_Agent::getInstance()->unfoldRef(*(itr+1)); DIVA_Manager::getInstance()->release(); } else if ((*itr).find(CMD_FOLD)  != (*itr).npos) Command_Agent::getInstance()->fold(*(++itr)); /// fold else if ((*itr).find(CMD_UPDATE)  != (*itr).npos) { DIVA_Manager::getInstance()->lock(); Command_Agent::getInstance()->update(); /// update DIVA_Manager::getInstance()->release(); } } return 0; }

Let's take CMD_VISUALIZE for example, it will call Command_Agent::getInstance()->visualize(*(itr+1));

So we take a closer look in the visualize method:

WOP_Entry * Command_Agent::visualize(std::string _visualItem) {
       return visualize(_visualItem, NULL);
}

It self called the overloading visualize method with two parameters. In this method we notice that if it can't found the MDS file, then it will call the setVM method from xMappingTree, else it will load the MDS file to xMappingTree.

setVM is called by commmand agent when a new wop entry is created the setVM typically invoke a mapping GUI dialog which return a mapping tree.

WOP_Entry * Command_Agent::visualize(std::string _visualItem, WOP_Entry *parent){ 
WOP_Entry *en ; en = retrieveWOP(_visualItem, parent, NULL, true); // call the setVM to setup the default VM
xMappingTree xmt  ; string mds = MappingEngine::getInstance()->searchMDString(en->getVarType()) ; // search existing MDS string if (mds == "") { vmLibrary::getInstance()->get_vm_no(); xmt = en->setVM();
} else { xmt = xMappingTree::fromMDStoXMappingTree(mds,en); }
MappingEngine::getInstance()->xCreateMappedObject(xmt); MappingEngine::getInstance()->add_wop_xmt_pair(en, xmt);
MappingEngine::getInstance()->add_wop_vm_mapping_pair(en, xmt.getRootVM()); // find the VM representing the wop_entry en MappingEngine::getInstance()->sweep_to_collect_vmentry_pairs(xmt); MappingEngine::getInstance()->addxMappingTree(xmt); // add all the nodes to be managed by mapping engine
return en ; }

WOP_Entry provides the virtual method for setVM, and WOP_Entry is the root class of all the WOP family. That is, all the WOP class is a subclass of WOP_Entry.

Let's take WOP_Array_Entry for example, which is one of the WOP family. the setVM method will make a DialogBox? which type is NEO_DIALOG.

xMappingTree WOP_Array_Entry::setVM(){
       currentEntry=this;
       DialogBox( _hInst, "NEO_DIALOG", _hWnd, (DLGPROC)CompArrProc);
       return *mTree;
}

We can see that all the WOP will bump up NEO_DIALOG to user.

Personal tools