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 #include "ResetNode.h"
15 #include "Parameter.h"
16
17 #if 0 // We get everything from ToggleNode
18 //
19 // The following define the mapping of parameter indices to parameter
20 // functionality in the module that is used to 'data-drive' the
21 // ResetNode class and Nodes derived from it.
22 // These MUST match the entries in the ui.mdf file for the interactors
23 // that expect to be implemented by the ResetInteractor class.
24 //
25 #define ID_PARAM_NUM 1 // Id used for UI messages
26 #define DATA_PARAM_NUM 2 // A list of the 2 set/reset values
27 #define CVAL_PARAM_NUM 3 // Current output value
28 #define LABEL_PARAM_NUM 4 // Label
29 #define EXPECTED_SELECTOR_INPUTS LABEL_PARAM_NUM
30 #endif
31
32 //
33 // Constructor
34 //
ResetNode(NodeDefinition * nd,Network * net,int instance)35 ResetNode::ResetNode(NodeDefinition *nd,
36 Network *net, int instance) :
37 ToggleNode(nd, net, instance)
38 {
39 }
~ResetNode()40 ResetNode::~ResetNode()
41 {
42 }
43 //
44 // Called after allocation is complete.
45 // The work done here is to assigned default values to the InteractorNode inputs
46 // so that we can use them later when setting the attributes for the
47 // Interactor.
48 //
initialize()49 boolean ResetNode::initialize()
50 {
51 return this->ToggleNode::initialize();
52 }
53 //
54 // Define the token that we install in the message handler to receive messages
55 // for this module. We redefine this method to return the name of the output
56 // as the executive knows it. It uses the name of the output, to send a message
57 // back to the ui (i.e. 'outputname: reset').
58 //
getModuleMessageIdString()59 const char *ResetNode::getModuleMessageIdString()
60 {
61 if (!this->moduleMessageId)
62 this->moduleMessageId = this->getNetworkOutputNameString(1);
63
64 return (const char*)this->moduleMessageId;
65 }
66 //
67 // Look for the "'oneshotname': Resetting oneshot" message.
68 //
handleInteractorMsgInfo(const char * line)69 int ResetNode::handleInteractorMsgInfo(const char *line)
70 {
71 int vals = 0;
72
73 if (strstr(line,"Resetting oneshot")) {
74 this->reset(FALSE); // Don't send value
75 this->clearOutputDirty(1); // Don't send it later either
76 vals++;
77 }
78 return vals;
79 }
expectingModuleMessage()80 boolean ResetNode::expectingModuleMessage()
81 {
82 return TRUE;
83 }
84
85 //
86 // Reset output lvalues contain the '[oneshot:value]' attribute if the
87 // output is currently set. So, we first call the super class method and
88 // then if this is the #1 output an it is set, then we append the attribute.
89 //
strcatParameterNameLvalue(char * s,Parameter * p,const char * prefix,int index)90 int ResetNode::strcatParameterNameLvalue(char *s, Parameter *p,
91 const char *prefix, int index)
92 {
93 int cnt = ToggleNode::strcatParameterNameLvalue(s,p,prefix,index);
94
95 if ((index == 1) && !p->isInput() && this->isSet()) {
96 char *reset = this->getResetValue();
97 char *p = s;
98 p += STRLEN(s);
99 sprintf(p,"[oneshot:%s]",reset);
100 cnt += STRLEN(p);
101 delete reset;
102 }
103
104 return cnt;
105 }
106
107 //
108 // Determine if this node is of the given class.
109 //
isA(Symbol classname)110 boolean ResetNode::isA(Symbol classname)
111 {
112 Symbol s = theSymbolManager->registerSymbol(ClassResetNode);
113 if (s == classname)
114 return TRUE;
115 else
116 return this->ToggleNode::isA(classname);
117 }
118