1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 #include "../base/defines.h"
11 
12 
13 
14 
15 #include <string.h>
16 
17 #include "GlobalLocalNode.h"
18 #include "StandIn.h"
19 #include "Network.h"
20 #include "Parameter.h"
21 
GlobalLocalNode(NodeDefinition * nd,Network * net,int instnc)22 GlobalLocalNode::GlobalLocalNode(NodeDefinition *nd, Network *net, int instnc) :
23 					Node(nd, net, instnc)
24 {
25     this->isGlobal = UNDEFINED;
26     this->myNodeNameSymbol = 0;
27 }
28 
~GlobalLocalNode()29 GlobalLocalNode::~GlobalLocalNode()
30 {
31     this->clearMyNodeName();
32 }
setAsLocalNode()33 void GlobalLocalNode::setAsLocalNode()
34 {
35     this->isGlobal = FALSE;
36     this->clearMyNodeName();
37     if (this->getStandIn())
38 	this->getStandIn()->notifyLabelChange();
39     this->markForResend();
40 }
setAsGlobalNode()41 void GlobalLocalNode::setAsGlobalNode()
42 {
43     this->isGlobal = TRUE;
44     this->clearMyNodeName();
45     if (this->getStandIn())
46 	this->getStandIn()->notifyLabelChange();
47     this->markForResend();
48 }
isLocalNode()49 boolean GlobalLocalNode::isLocalNode() { return this->isGlobal == FALSE; }
isGlobalNode()50 boolean GlobalLocalNode::isGlobalNode() { return this->isGlobal == TRUE; }
51 
52 //
53 // Mark the net dirty so that it will a) be sent prior to the next execution,
54 // b) produce a "want to save?" prompt prior to deletion.  Mark inputs dirty
55 // so that they'll be resent, causing the module to run with the correct inputs.
56 // Otherwise the dxexec has uninitialized values for the modules outputs.
57 //
markForResend()58 void GlobalLocalNode::markForResend()
59 {
60     this->getNetwork()->setFileDirty();
61     this->getNetwork()->setDirty();
62     int cnt = this->getInputCount();
63     int i;
64     for (i=1; i<=cnt; i++) {
65 	Parameter* prm = this->getInputParameter(i);
66 	if ((prm->isConnected() == FALSE) && (prm->isDefaulting() == FALSE))
67 	    prm->setDirty();
68     }
69 }
70 
clearMyNodeName()71 void GlobalLocalNode::clearMyNodeName()
72 {
73     this->myNodeNameSymbol = 0;
74 
75 }
setMyNodeNameIfNecessary()76 void GlobalLocalNode::setMyNodeNameIfNecessary()
77 {
78 
79     // FIXME: should change Symbol for the name
80 
81     const char *suffix = NULL;
82     if (this->isGlobalNode())
83 	suffix = "Global";
84     else if (this->isLocalNode())
85 	suffix = "Local";
86 
87     if (suffix) {
88 	char newname[1024];
89 	Symbol nameSym = this->Node::getNameSymbol();
90 	const char *name = theSymbolManager->getSymbolString(nameSym);
91 	SPRINTF(newname,"%s%s",name,suffix);
92 	this->myNodeNameSymbol = theSymbolManager->registerSymbol(newname);
93 
94 	//
95 	// This resets the text in the notation field in the cdb
96 	//
97 	this->setLabelString(newname);
98     } else {
99 	this->clearMyNodeName();
100     }
101 
102 }
getNameSymbol()103 Symbol GlobalLocalNode::getNameSymbol()
104 {
105     if (this->myNodeNameSymbol)
106 	return this->myNodeNameSymbol;
107 
108     this->setMyNodeNameIfNecessary();
109 
110     if (this->myNodeNameSymbol)
111 	return this->myNodeNameSymbol;
112     else
113 	return this->Node::getNameSymbol();
114 
115 
116 }
117 
118 //
119 // Determine if this node is of the given class.
120 //
isA(Symbol classname)121 boolean GlobalLocalNode::isA(Symbol classname)
122 {
123     Symbol s = theSymbolManager->registerSymbol(ClassGlobalLocalNode);
124     if (s == classname)
125 	return TRUE;
126     else
127 	return this->Node::isA(classname);
128 }
129 
getExecModuleNameString()130 const char *GlobalLocalNode::getExecModuleNameString()
131 {
132     Symbol s = this->getNameSymbol();
133     return theSymbolManager->getSymbolString(s);
134 }
135