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 #ifndef _Node_h 15 #define _Node_h 16 17 #include <stdio.h> 18 #include <Xm/Xm.h> 19 20 #include "enums.h" 21 #include "Base.h" 22 #include "List.h" 23 #include "SymbolManager.h" 24 #include "DXPacketIF.h" 25 #include "NodeDefinition.h" 26 #include "DXType.h" 27 #include "SIAllocatorDictionary.h" 28 #include "CDBAllocatorDictionary.h" 29 #include "Cacheability.h" 30 #if WORKSPACE_PAGES 31 #include "GroupedObject.h" 32 #endif 33 34 // 35 // Class name definition: 36 // 37 #define ClassNode "Node" 38 39 // 40 // Referenced classes: 41 // 42 class Ark; 43 class List; 44 class NodeDefinition; 45 class DXPacketIF; 46 class DXWindow; 47 class Parameter; 48 class Network; 49 class StandIn; 50 class ConfigurationDialog; 51 52 #if WORKSPACE_PAGES 53 class GroupRecord; 54 class GroupManager; 55 #endif 56 57 typedef long NodeStatusChange; // For the enums below 58 typedef long NodeParameterStatusChange; // For the enums below 59 60 #define FOR_EACH_NODE_INPUT(node, param, iterator) \ 61 for ( iterator.setList(node->inputParameters) ; \ 62 (param = (Parameter*)iterator.getNext()) ; ) 63 64 #define FOR_EACH_NODE_OUTPUT(node, param, iterator) \ 65 for ( iterator.setList(node->outputParameters) ; \ 66 (param = (Parameter*)iterator.getNext()) ; ) 67 68 69 // 70 // Node class definition: 71 // 72 #if WORKSPACE_PAGES 73 class Node : public Base, public GroupedObject 74 #else 75 class Node : public Base 76 #endif 77 { 78 //friend StandIn::setNodePosition(Node *n, int x,int y); 79 friend class StandIn; // FIXME: use the above 80 81 private: 82 // 83 // Private member data: 84 // 85 86 // 87 // Used only be the Network for sorting, graph analysis, etc. 88 // See isMarked(), setMarked() and clearMarked(). 89 // 90 boolean marked; 91 92 // 93 // This dispatches messages to this->execModuleMessageHandler(). 94 // Messages are not noticed unless this handler is installed 95 // (in this->updateModuleMessageProtocol() via this->netPrintNode()). 96 // 97 static void ExecModuleMessageHandler(void *clientData, int id, void *line); 98 99 // Should the executive cache the module's state. 100 Cacheability nodeCacheability; 101 102 // The symbol for the node label (contained in theSymbolTable). 103 Symbol labelSymbol; 104 105 // The instance number, allocated from the definition. 106 int instanceNumber; 107 108 #if WORKSPACE_PAGES 109 #else 110 // The Group name. 111 Symbol groupNameSymbol; 112 #endif 113 114 // The network this node belongs to 115 Network *network; 116 117 // Pointer into a table of definitions generated by the MDF file 118 NodeDefinition *definition; 119 120 // Current values and definitions for inputs and outputs 121 List inputParameters; 122 List outputParameters; 123 124 // Pointer to the UI standin for this node. 125 StandIn *standin; 126 127 // Pointer to the UI standin for this node. 128 ConfigurationDialog *cdb; // CD box 129 130 // Upper left-hand corner of standin for this module. 131 int vpe_xpos, vpe_ypos; 132 133 // 134 // Let the Configuration dialog box know that the parameter has changed. 135 // Assumes that the node currently has a cdb. 136 // 137 void notifyCDBParameterChanged(Parameter *p, int index); 138 139 // 140 // Set the index'th parameter value of the parameter list given by io 141 // to the given value of type t. if t==DXType::UndefinedType, then 142 // be sure it can be assigned to one of the allowed types in the 143 // ParameterDefinition. If 'value' is NULL, then clear the value (and 144 // handle as a successful setting) and return the default type for the 145 // given parameter. 146 // We you the Parameter methods to try and help certain values become 147 // the given type (i.e. by adding "'s, {}'s, []'s and so on). 148 // If send is true (the default), the results will be sent to the server 149 // if possible. 150 // If notify is TRUE, then call ioParameterStatusChanged() with one of 151 // Node::ParameterSetValueChanged and Node::ParameterValueChanged. 152 // index is 1 based. 153 // 154 Type setIOValue(List *io, int index, const char *value, 155 Type t = DXType::UndefinedType, 156 boolean send = TRUE, 157 boolean notify = TRUE); 158 159 // This is the same as setIOValue, but it sends the value to the 160 // executive without causing an executive execution in execute on change. 161 Type setIOValueQuietly(List *io, int index, const char *value, 162 Type t = DXType::UndefinedType); 163 // 164 // Mark the given parameter as clean. 165 // 166 void setIODirty(List *io, int index, boolean dirty); 167 168 #if WORKSPACE_PAGES 169 #else 170 // 171 // Parse the process group info. 172 // 173 boolean netParsePgrpComment(const char* comment, 174 const char* filename, int lineno); 175 #endif 176 177 // 178 // Determine if the index'th parameter in the give list is connected 179 // (i.e. has an arc) to another parameter. 180 // 181 boolean isIOConnected(List *io, int index); 182 183 // 184 // Get the default value of the index'th parameter in the given list. 185 // 186 const char *getIODefaultValueString(List *io, int index); 187 188 // 189 // Set/Get the cacheability of the index'th parameter in the given list. 190 // 191 Cacheability getIOCacheability(List *io, int index); 192 virtual void setIOCacheability(List *io, int index, Cacheability c); 193 boolean isIOCacheabilityWriteable(List *io, int index); 194 195 // 196 // Get the currently set value of the index'th parameter in the given 197 // list. Ignores the defaulting stuff. 198 // 199 const char *getIOSetValueString(List *io, int index); 200 // 201 // Get the default value of the index'th parameter in the given list. 202 // 203 boolean isIODefaulting(List *io, int index); 204 // 205 // Determine if the value of the index'th parameter in the given list 206 // has been set, independent of whether it's defaulting or not. 207 // 208 boolean isIOSet(List *io, int index); 209 // 210 // Get the value of the index'th parameter in the given list. 211 // 212 const char *getIOValueString(List *io, int index); 213 // 214 // Get the type of the set value of the index'th parameter in the list. 215 // 216 Type getIOSetValueType(List *io, int index); 217 218 // 219 // Get the name of the input as specified in the network 220 // (i.e. main_Display_1_in_3) 221 // 222 char *getNetworkIONameString(int index, 223 boolean input, char *buffer); 224 225 // 226 // Get the name of the index'th parameter in the given list. 227 // If buf is provided, then the name is placed there, otherwise a 228 // new string is created for the return value which must be deleted 229 // by the caller. 230 // 231 char *getIONameString(List *io, int index, char *buf = NULL); 232 // 233 // Get the description of the index'th parameter in the given list. 234 // 235 const char *getIODescription(List *io, int index); 236 237 // 238 // Return a readonly list of strings that represent the types for 239 // the given parameter. 240 // 241 const char* const *getIOTypeStrings(List *io, int index); 242 243 // 244 // Return a readonly list of types for the given parameter. 245 // The List is readonly and must not be deleted by the caller. 246 // 247 List *getIOTypes(List *io, int index); 248 249 // 250 // Return a readonly list of Arks for the given parameter. 251 // 252 public: 253 const List *getIOArks(List *io, int index); 254 255 private: 256 // 257 // Determine if the index'th parameter from the given list has visible tab. 258 // 259 boolean isIOVisible(List *io, int index); 260 261 // 262 // Set the index'th parameter from the given list to be visible. 263 // 264 void setIOVisibility(List *io, int index, boolean v); 265 266 // 267 // Set all unconnected, defaulting params to be either visible or not. 268 // 269 void setAllIOVisibility(List *io, boolean v); 270 271 // 272 // Determine if the index'th parameter from the given list is viewable 273 // 274 boolean isIOViewable(List *io, int index); 275 276 // 277 // Print 'name = value' for the index'th parameter in the given list. 278 // 279 char *ioValueString(List *io, int index, const char *prefix); 280 281 // 282 // Determine if the index'th parameter in the given list is required. 283 // 284 boolean isIORequired(List *io, int index); 285 286 // 287 // Determine if the given parameter list contains parameters which 288 // can be exposed, implying that there are some that are hidden. 289 // 290 boolean hasExposableIO(List *io); 291 // 292 // Determine if the given parameter list contains parameters which 293 // can be hidden, implying that there are some that are exposed. 294 // 295 boolean hasHideableIO(List *io); 296 297 // 298 // On behalf of automatic graph layout we need to store information 299 // on a per-node basis. No one outside of the layout class will 300 // ever access this information, but it's natural to keep in 301 // associated with the Node for fast lookup. 302 // Perhaps a better way to track this information would be to make 303 // Node multiply inherit from a class that represents the information. 304 // I like that way of doing it however that would require an additional 305 // #include inside Node.h. Since the included .h file would be 306 // changing often, that would in turn require rebuilding the world 307 // very often. Maybe after the code stabilizes I'll try that 308 // approach. 309 // 310 Base* layout_information; 311 312 protected: 313 // 314 // Protected member data: 315 // 316 317 // 318 // Used as a unique identifier for this instance of this Node when 319 // installing the Module message handler. 320 // 321 char *moduleMessageId; 322 setInstanceNumber(int inst)323 void setInstanceNumber(int inst) { instanceNumber = inst; } appendInput(Parameter * p)324 boolean appendInput(Parameter *p) 325 { return inputParameters.appendElement((const void*)p); } appendOutput(Parameter * p)326 boolean appendOutput(Parameter *p) 327 { return outputParameters.appendElement((const void*)p); } 328 329 // 330 // Add an Ark to the index'th parameter of parameter list 'io'. 331 // 332 virtual boolean addIOArk(List *io, int indx, Ark *a); 333 virtual boolean removeIOArk(List *io, int index, Ark *a); 334 removeInputArk(int index,Ark * a)335 boolean removeInputArk(int index, Ark *a) 336 { return this->removeIOArk(&this->inputParameters, index, a); } removeOutputArk(int index,Ark * a)337 boolean removeOutputArk(int index, Ark *a) 338 { return this->removeIOArk(&this->outputParameters, index, a); } 339 340 341 // 342 // Add/remove a set of repeatable input or output parameters to the 343 // this node. An error ocurrs if the parameter list indicated does 344 // not have repeatable parameters. 345 // 346 virtual boolean addRepeats(boolean input); 347 virtual boolean removeRepeats(boolean input); 348 getInputParameter(int i)349 Parameter *getInputParameter(int i) 350 { 351 return (Parameter*)inputParameters.getElement(i); 352 } getOutputParameter(int i)353 Parameter *getOutputParameter(int i) 354 { 355 return (Parameter*)outputParameters.getElement(i); 356 } 357 358 virtual int strcatParameterNameLvalue(char *s, Parameter *p, 359 const char *prefix, int index); 360 int strcatParameterValueString(char *s, Parameter *p, int index); 361 362 // 363 // Parse either on input or an output comment, setting the value of 364 // the indicated parameter with the value and type found in the comment. 365 // (Made virtual 9/95 in order to peek at comments inside SelectionNode.) 366 // 367 virtual boolean parseIOComment(boolean input, const char* comment, 368 const char* filename, int lineno, boolean valueOnly = FALSE); 369 370 // 371 // These are called when a 'node' comment is found in the .net. 372 // 373 boolean netParseNodeComment(const char* comment, 374 const char *file, int lineno); 375 // 376 // These are called to parse any comments after the 'node', 'input', 377 // 'output' and 'pgrp' comments in the .net file. 378 // 379 virtual boolean netParseAuxComment(const char* comment, 380 const char *file, int lineno); 381 // 382 // Create the invocation of the script language Node call. 383 // The string that is returned should be deleted by the caller. 384 // 385 virtual char *netNodeString(const char *prefix); 386 387 // 388 // Create the invocation of any script language that is 389 // to occur at the beginning or end of the containing macro. 390 // The string that is returned should be deleted by the caller. 391 // 392 virtual char *netBeginningOfMacroNodeString(const char *prefix); 393 virtual char *netEndOfMacroNodeString(const char *prefix); 394 395 // 396 // Put a parameter name/value ('name = value;') pair into a string if 397 // the parameter is a value. They may return NULL if no strings are 398 // to be printed. 399 // The strings returned should be deleted by the caller. 400 // inputValueString(int i,const char * prefix)401 virtual char *inputValueString(int i, const char *prefix) 402 { return ioValueString(&this->inputParameters,i,prefix); } outputValueString(int i,const char * prefix)403 virtual char *outputValueString(int i, const char *prefix) 404 { return ioValueString(&this->outputParameters,i,prefix); } 405 virtual char *valuesString(const char *prefix); 406 407 // 408 // Set the index'th i/o parameter to use either the default value 409 // or the assigned valued. if notify is TRUE then call 410 // ioParameterStatusChanged() with Node::ParameterSetValueToDefaulting. 411 // If there is a connection to the executive, then send the change. 412 // 413 void setIODefaultingStatus(int index, 414 boolean input, 415 boolean defaulting, 416 boolean send = TRUE, 417 boolean notify = TRUE); 418 419 // 420 // Notify anybody that needs to know that a parameter has changed its 421 // value or arcs. 422 // 423 #if 0 424 virtual void ioParameterValueChanged(boolean input, int index); 425 virtual void ioParameterArkChanged(boolean input, int index,boolean added); 426 427 void inputParameterValueChanged(int index) 428 { this->ioParameterValueChanged(TRUE, index); } 429 void outputParameterValueChanged(int index) 430 { this->ioParameterValueChanged(FALSE, index); } 431 void inputParameterArkAdded(int index) 432 { this->ioParameterArkChanged(TRUE, index, ); } 433 void inputParameterArkRemoved(int index) 434 { this->ioParameterArkChanged(TRUE, index, FALSE); } 435 void outputParameterArkAdded(int index) 436 { this->ioParameterArkChanged(FALSE, index, TRUE); } 437 void outputParameterArkRemoved(int index) 438 { this->ioParameterArkChanged(FALSE, index, FALSE); } 439 #endif 440 virtual void ioParameterStatusChanged(boolean input, int index, 441 NodeParameterStatusChange status); 442 // notifyIo is the same as io sort of. notifyIo adds a check to see 443 // if the network is in the process of going away. That avoids useless work. 444 void notifyIoParameterStatusChanged(boolean input, int index, 445 NodeParameterStatusChange status); 446 447 // 448 // Used by netPrintNode() to print the Names of it's input and output 449 // parameters. In the case of inputs, if the input is taking output 450 // from another source (i.e it has an arc), then we print the name 451 // of that output instead. 452 // 453 virtual char *inputParameterNamesString(const char *varprefix, 454 const char *indent = NULL); 455 virtual char *outputParameterNamesString(const char *prefix); 456 457 // 458 // Print the comment section that precedes the Node invocation. 459 // 460 boolean netPrintCommentHeader(FILE *f); 461 virtual boolean printIOComment(FILE *f, boolean input, int index, 462 const char *indent = NULL, 463 boolean valueOnly = FALSE); 464 boolean netPrintPgrpComment(FILE *f); 465 virtual boolean netPrintAuxComment(FILE *f); 466 467 468 // 469 // Called when a message is received from the executive after 470 // this->ExecModuleMessageHandler() is registered in 471 // this->Node::netPrintNode() to receive messages for this node. 472 // The format of the message coming back is defined by the derived class. 473 // 474 virtual void execModuleMessageHandler(int id, const char *line); 475 476 // 477 // Update the state of message handling for a module/UI message. 478 // This is called only when we send a Node's module call to the executive 479 // and the node has a module messaging protocol as defined by 480 // this->hasModuleMessageProtocol(). 481 // 482 virtual void updateModuleMessageProtocol(DXPacketIF *pif); 483 484 // 485 // Return TRUE/FALSE, indicating whether or not we support a message 486 // protocol between the executive module that runs for this node and the 487 // UI. By default Nodes do not have message protocols. 488 // 489 virtual boolean hasModuleMessageProtocol(); 490 491 // 492 // Return TRUE/FALSE, indicating whether or not we expect to receive 493 // a message from the UI when our module executes in the executive. 494 // Be default Nodes do not expect messages. 495 // 496 virtual boolean expectingModuleMessage(); 497 498 // 499 // Returns a string that is used to register 500 // this->ExecModuleMessageHandler() when this->hasModuleMessageProtocol() 501 // return TRUE. This version, returns an id that is unique to this 502 // instance of this node. 503 // 504 // IMPORTANT: this must set this->moduleMessageId so that Node::~Node() 505 // can know the id string. 506 // 507 virtual const char *getModuleMessageIdString(); 508 509 // 510 // Do any work that must be done before sending the macro/network 511 // that this node belongs to to the server. 512 // Be default, Nodes do not have any work that needs to be done 513 // before sending. 514 // 515 virtual void prepareToSendNode(); 516 517 // 518 // Do any work that must be done before sending the given parameter value 519 // to the server. 520 // Be default, Nodes do not have any work that needs to be done 521 // before sending parameter values. 522 // 523 virtual void prepareToSendValue(int index, Parameter *p); 524 525 // 526 // See if the given string is a viable label to be used as an identifier. 527 // Also make sure it is not a reserved script language word. 528 // Return TRUE if ok, FALSE otherwise and issue and error message. 529 // 530 boolean verifyRestrictedLabel(const char *label); 531 532 // 533 // Print/parse the 'node %s[%d]:' comment. 534 // Not all nodes have cfg info, but it is provided for those that do. 535 // 536 boolean cfgPrintNodeLeader(FILE *f); 537 boolean cfgParseNodeLeader(const char *comment, 538 const char *file, int lineno); 539 540 541 public: 542 // 543 // Constructor: 544 // Node that a node should ONLY be allocated by its definition! 545 // 546 Node(NodeDefinition *nd, Network *net, int inst); 547 548 // 549 // Destructor: 550 // 551 virtual ~Node(); 552 553 // 554 // The following are used to give notification of Node's change in 555 // status. Currently, notification is done through the Node's network. 556 // Node selection notification is handled by the StandIn for the node. 557 // 558 enum { // NodeStatusChange 559 NodeSelected = 1, // Node was just selected. 560 NodeDeselected = 2 // Node was just unselected. 561 }; 562 563 564 // 565 // The following are used to give notification of Node's parameter 566 // change in status and is an argument to ioParameterStatusChanged. 567 // 568 #define PARAMETER_VALUE_CHANGED 0x100000 569 #define PARAMETER_VISIBILITY_CHANGED 0x200000 570 #define PARAMETER_ARC_CHANGED 0x400000 571 enum { // NodeParameterStatusChange 572 ParameterValueChanged = PARAMETER_VALUE_CHANGED, 573 ParameterSetValueChanged = 0x000001 | PARAMETER_VALUE_CHANGED, 574 ParameterSetValueToDefaulting = 0x000002 | PARAMETER_VALUE_CHANGED, 575 ParameterVisibilityChanged = PARAMETER_VISIBILITY_CHANGED, 576 ParameterBecomesVisible = 0x000003 | PARAMETER_VISIBILITY_CHANGED, 577 ParameterBecomesInvisible = 0x000004 | PARAMETER_VISIBILITY_CHANGED, 578 ParameterArkChanged = PARAMETER_ARC_CHANGED, 579 ParameterArkRemoved = 0x000008 | PARAMETER_ARC_CHANGED, 580 ParameterArkAdded = 0x000010 | PARAMETER_ARC_CHANGED 581 }; 582 583 584 585 // 586 // Generate a new instance number for this node. We notify the 587 // standIn and mark the network and the node dirty. 588 // The new instance number is returned. 589 // 590 virtual int assignNewInstanceNumber(); 591 592 // 593 // Used by ONLY Network for sorting and graph analysis. 594 // isMarked()595 boolean isMarked() { return this->marked; } setMarked()596 void setMarked() { this->marked = TRUE; } clearMarked()597 void clearMarked() { this->marked = FALSE; } 598 599 600 // FIXME: these should not be public. They are called by the newNode 601 // function of the NodeDefinition class. 602 virtual void setDefinition(NodeDefinition *nd); 603 virtual void updateDefinition(); 604 // 605 // Build a Node's input and output parameter lists based on this 606 // node definition. 607 // 608 boolean buildParameterLists(); 609 610 611 // 612 // Perform any additional initializations that were not performed 613 // in the constrctor. If this returns TRUE initialization was 614 // successful, otherwise FALSE. If FALSE, then it is assumed that 615 // initialize() will issue the error/warning message. 616 // initialize() is called before the Node is actually added to the 617 // Network. 618 // 619 virtual boolean initialize(); 620 621 // 622 // initializeAfterNodeMember() is called after initialize() but after the 623 // Node is actually added to the Network. 624 // initializeAfterNetworkMember()625 virtual void initializeAfterNetworkMember() {} 626 627 628 // Get the name of this module getNameSymbol()629 virtual Symbol getNameSymbol() 630 { return this->definition->getNameSymbol(); } getNameString()631 const char *getNameString() 632 //{ return (const char *) this->definition->getNameString(); } 633 { return theSymbolManager->getSymbolString( 634 this->getNameSymbol()); } getExecModuleNameString()635 virtual const char *getExecModuleNameString() 636 { return this->definition->getExecModuleNameString(); } getDescription()637 const char *getDescription() 638 { return this->definition->getDescription(); } getDefinition()639 NodeDefinition *getDefinition() { return this->definition; } 640 641 642 // Get the label of this module. 643 virtual boolean setLabelString(const char *label); 644 virtual const char *getLabelString(); 645 getInputCount()646 int getInputCount() { return inputParameters.getSize(); } getOutputCount()647 int getOutputCount() { return outputParameters.getSize(); } 648 void setVpePosition(int x, int y); 649 650 651 #if WORKSPACE_PAGES 652 #else 653 // 654 // Process group calls. 655 // 656 virtual void setGroupName(const char* name); 657 const char *getGroupName(); 658 void addToGroup(const char *group); 659 #endif 660 661 // 662 // Add/remove a set of input our output parameters to the give model. 663 // addInputRepeats()664 boolean addInputRepeats() { return addRepeats(TRUE); } removeInputRepeats()665 boolean removeInputRepeats() { return removeRepeats(TRUE); } addOutputRepeats()666 boolean addOutputRepeats() { return addRepeats(FALSE); } removeOutputRepeats()667 boolean removeOutputRepeats() { return removeRepeats(FALSE); } 668 669 hasExposableInput()670 boolean hasExposableInput() 671 { return this->hasExposableIO(&this->inputParameters); } hasExposableOutput()672 boolean hasExposableOutput() 673 { return this->hasExposableIO(&this->outputParameters); } hasHideableInput()674 boolean hasHideableInput() 675 { return this->hasHideableIO(&this->inputParameters); } hasHideableOutput()676 boolean hasHideableOutput() 677 { return this->hasHideableIO(&this->outputParameters); } 678 679 boolean hasRemoveableInput(); 680 boolean hasRemoveableOutput(); 681 boolean isInputRepeatable(); 682 boolean isOutputRepeatable(); getInputRepeatCount()683 int getInputRepeatCount() { return this->definition->getInputRepeatCount(); } getOutputRepeatCount()684 int getOutputRepeatCount() { return this->definition->getOutputRepeatCount(); } 685 686 // 687 // Get the network this node belongs to. 688 // getNetwork()689 Network *getNetwork() { return network; } 690 691 692 // 693 // Manage inputs. 694 // addInputArk(Ark * a,int index)695 boolean addInputArk(Ark *a, int index) 696 { return addIOArk(&inputParameters, index, a); } addOutputArk(Ark * a,int index)697 boolean addOutputArk(Ark *a, int index) 698 { return addIOArk(&outputParameters, index, a); } 699 getInputArks(int index)700 const List *getInputArks(int index) 701 { return getIOArks(&inputParameters, index); } getOutputArks(int index)702 const List *getOutputArks(int index) 703 { return getIOArks(&outputParameters, index); } 704 705 virtual boolean deleteArk(Ark *a); 706 707 // If these get virtualized, you must replace p->getValue() with 708 // this->getInputValueString(i) in Node.C getInputValueString(int index)709 const char *getInputValueString(int index) 710 { return getIOValueString(&inputParameters, index); } getOutputValueString(int index)711 const char *getOutputValueString(int index) 712 { return getIOValueString(&outputParameters, index); } getInputSetValueType(int index)713 Type getInputSetValueType(int index) 714 { return getIOSetValueType(&inputParameters, index); } getOutputSetValueType(int index)715 Type getOutputSetValueType(int index) 716 { return getIOSetValueType(&outputParameters, index); } 717 718 // 719 // If buf is provided, then the name is placed there, otherwise a 720 // new string is created for the return value which must be deleted 721 // by the caller. 722 // 723 char *getInputNameString(int index, char *buf = NULL) 724 { return getIONameString(&inputParameters, index, buf); } 725 char *getOutputNameString(int index, char *buf = NULL) 726 { return getIONameString(&outputParameters, index, buf); } 727 728 // 729 // Get the name of the input as specified in the network 730 // (i.e. main_Display_1_in_3) 731 // If buf is not provided the returned string must be deleted 732 // by the caller. 733 // 734 char *getNetworkInputNameString(int index, char *buf = NULL) 735 { return getNetworkIONameString(index, TRUE, buf); } 736 char *getNetworkOutputNameString(int index, char *buf = NULL) 737 { return getNetworkIONameString(index, FALSE, buf); } 738 getInputTypeStrings(int index)739 const char* const *getInputTypeStrings(int index) 740 { return getIOTypeStrings(&inputParameters, index); } getOutputTypeStrings(int index)741 const char* const *getOutputTypeStrings(int index) 742 { return getIOTypeStrings(&outputParameters, index); } 743 744 // The List is readonly and must not be deleted by the caller. getInputTypes(int index)745 List* getInputTypes(int index) 746 { return getIOTypes(&inputParameters, index); } getOutputTypes(int index)747 List* getOutputTypes(int index) 748 { return getIOTypes(&outputParameters, index); } 749 getInputDescription(int index)750 const char *getInputDescription(int index) 751 { return getIODescription(&this->inputParameters, index); } getOutputDescription(int index)752 const char *getOutputDescription(int index) 753 { return getIODescription(&this->outputParameters, index); } 754 getInputDefaultValueString(int index)755 const char *getInputDefaultValueString(int index) 756 { return getIODefaultValueString(&inputParameters, index); } 757 getInputSetValueString(int index)758 const char *getInputSetValueString(int index) 759 { return getIOSetValueString(&inputParameters, index); } 760 isInputRequired(int index)761 boolean isInputRequired(int index) 762 { return isIORequired(&inputParameters, index); } isOutputRequired(int index)763 boolean isOutputRequired(int index) 764 { return isIORequired(&outputParameters, index); } 765 isInputConnected(int index)766 boolean isInputConnected(int index) 767 { return isIOConnected(&inputParameters, index); } isOutputConnected(int index)768 boolean isOutputConnected(int index) 769 { return isIOConnected(&outputParameters, index); } isParameterConnected(int index,boolean input)770 boolean isParameterConnected(int index, boolean input) 771 { return (input ? isIOConnected(&inputParameters, index) 772 : isIOConnected(&outputParameters, index)); } 773 setInputVisibility(int index,boolean v)774 void setInputVisibility(int index, boolean v) 775 { this->setIOVisibility(&inputParameters, index, v); } setOutputVisibility(int index,boolean v)776 void setOutputVisibility(int index, boolean v) 777 { this->setIOVisibility(&outputParameters, index, v); } 778 setAllInputsVisibility(boolean v)779 void setAllInputsVisibility(boolean v) 780 { this->setAllIOVisibility(&inputParameters, v); } setAllOutputsVisibility(boolean v)781 void setAllOutputsVisibility(boolean v) 782 { this->setAllIOVisibility(&outputParameters, v); } 783 clearInputDirty(int index)784 void clearInputDirty(int index) 785 { this->setIODirty(&inputParameters, index, FALSE); } setInputDirty(int index)786 void setInputDirty(int index) 787 { this->setIODirty(&inputParameters, index, TRUE); } clearOutputDirty(int index)788 void clearOutputDirty(int index) 789 { this->setIODirty(&outputParameters, index, FALSE); } setOutputDirty(int index)790 void setOutputDirty(int index) 791 { this->setIODirty(&outputParameters, index, TRUE); } 792 isInputVisible(int index)793 boolean isInputVisible(int index) 794 { return isIOVisible(&inputParameters, index); } isOutputVisible(int index)795 boolean isOutputVisible(int index) 796 { return isIOVisible(&outputParameters, index); } isParameterVisible(int index,boolean input)797 boolean isParameterVisible(int index, boolean input) 798 { return (input ? isInputVisible(index) : isOutputVisible(index)); } 799 isInputViewable(int index)800 boolean isInputViewable(int index) 801 { return isIOViewable(&inputParameters, index); } isOutputViewable(int index)802 boolean isOutputViewable(int index) 803 { return isIOViewable(&outputParameters, index); } isParameterViewable(int index,boolean input)804 boolean isParameterViewable(int index, boolean input) 805 { return (input ? isInputViewable(index) : isOutputViewable(index)); } 806 getOutputCacheability(int index)807 Cacheability getOutputCacheability(int index) 808 { return this->getIOCacheability(&outputParameters, index); } setOutputCacheability(int index,Cacheability c)809 void setOutputCacheability(int index, Cacheability c) 810 { this->setIOCacheability(&outputParameters, index, c); } isOutputCacheabilityWriteable(int index)811 boolean isOutputCacheabilityWriteable(int index) 812 { return this->isIOCacheabilityWriteable(&outputParameters, index); } 813 isInputDefaulting(int index)814 boolean isInputDefaulting(int index) 815 { return isIODefaulting(&inputParameters, index); } 816 isInputSet(int index)817 boolean isInputSet(int index) 818 { return isIOSet(&inputParameters, index); } 819 hasWriteableCacheability()820 boolean hasWriteableCacheability() 821 { return this->definition->hasWriteableCacheability(); } getNodeCacheability()822 Cacheability getNodeCacheability() { return this->nodeCacheability; } 823 void setNodeCacheability(Cacheability val); 824 isParameterDefaulting(int index,int input)825 boolean isParameterDefaulting(int index, int input) 826 { return (input ? isIODefaulting(&inputParameters, index) 827 : False); } 828 829 // 830 // Match output_index of this node to input_index of n. Returns TRUE 831 // if they can connect. 832 // 833 virtual boolean typeMatchOutputToInput( 834 int output_index, 835 Node *n, 836 int input_index); 837 838 // 839 // Set the stored value. 840 // If the parameter is not defaulting, this is 841 // the same as setValue, but if it is defaulting, then we set the 842 // value but leave the parameter clean and defaulting and ignore send. 843 // 844 virtual Type setInputSetValue(int index, const char *value, 845 Type type = DXType::UndefinedType, 846 boolean send = TRUE); 847 848 virtual Type setInputValue(int index, 849 const char *value, 850 Type t = DXType::UndefinedType, 851 boolean send = TRUE) 852 { return setIOValue(&inputParameters, index, value, t, send); } 853 virtual Type setOutputValue(int index, 854 const char *value, 855 Type t = DXType::UndefinedType, 856 boolean send = TRUE) 857 { return setIOValue(&outputParameters, index, value, t, send); } 858 859 // These are the same as setInputValue and setOutputValue, but they send 860 // the value to the executive without causing an executive execution in 861 // execute on change. 862 virtual Type setInputValueQuietly(int index, 863 const char *value, 864 Type t = DXType::UndefinedType) 865 { return setIOValueQuietly(&inputParameters, index, value, t); } 866 virtual Type setOutputValueQuietly(int index, 867 const char *value, 868 Type t = DXType::UndefinedType) 869 { return setIOValueQuietly(&outputParameters, index, value, t); } 870 871 virtual Type clearOutputValue(int index, 872 boolean send = TRUE) 873 { return setIOValue(&outputParameters, 874 index, 875 NULL, 876 DXType::UndefinedType, 877 send); } 878 879 // 880 // Get this node's instance number (allocated from the definition). 881 // getInstanceNumber()882 int getInstanceNumber() { return instanceNumber; } 883 884 // 885 // Get the x,y positions for the VPE 886 // 887 void getVpePosition(int *x, int *y); 888 // FIXME: these should be removed as soon as StandIn.C uses getVpePosition() getVpeX()889 int getVpeX() { return this->vpe_xpos; } getVpeY()890 int getVpeY() { return this->vpe_ypos; } 891 892 // 893 // Parse routines for a node, called by a Network. 894 // These are called for the comments found in the .net and .cfg files 895 // respectively. 896 // 897 virtual boolean netParseComment(const char* comment, 898 const char *file, int lineno); 899 virtual boolean cfgParseComment(const char* comment, 900 const char *file, int lineno); 901 902 // 903 // Print the stuff that belong in a .cfg file 904 // At this level, there is nothing. 905 // 906 virtual boolean cfgPrintNode(FILE *f, PrintType destination); 907 908 // 909 // Print the invocation of the script language Node call. 910 // LETS TALK IF YOU WANT TO MAKE THIS VIRTUAL (can you use netNodeString()). 911 // 912 boolean netPrintNode(FILE *f, 913 PrintType destination, 914 const char *prefix, 915 PacketIFCallback callback = NUL(PacketIFCallback), 916 void *clientdata = NUL(void*)); 917 918 // 919 // Print the invocation of any script language that is 920 // to occur at the beginning of the containing macro. 921 // 922 boolean netPrintBeginningOfMacroNode(FILE *f, 923 PrintType destination, 924 const char *prefix, 925 PacketIFCallback callback = NUL(PacketIFCallback), 926 void *clientdata = NUL(void*)); 927 928 // 929 // Print the invocation of any script language that is 930 // to occur at the end of the containing macro. 931 // 932 boolean netPrintEndOfMacroNode(FILE *f, 933 PrintType destination, 934 const char *prefix, 935 PacketIFCallback callback = NUL(PacketIFCallback), 936 void *clientdata = NUL(void*)); 937 938 // 939 // Save any other files that relevant to this mode 940 // The name passed in is file name used to save the network (without the 941 // .net extension). 942 // 943 virtual boolean auxPrintNodeFile(); 944 945 // 946 // Print parameter name/value ('name,name = value,value;') pairs. 947 // 948 virtual boolean printValues(FILE *f, const char *prefix, PrintType dest); 949 // 950 // For inputs, outputs or both sets of parameters send the values 951 // for of which do not have arcs. 952 // 953 virtual boolean sendValues(boolean ignoreDirty = TRUE); 954 955 // 956 // Send all dirty input and output values to the executive in the 957 // quiet way using the Executive("assign noexecute",...); call. 958 // 959 void sendValuesQuietly(); 960 961 962 // 963 // Manipulate the standin for this node. 964 // newStandIn(WorkSpace * w)965 StandIn *newStandIn(WorkSpace *w) 966 { this->standin = theSIAllocatorDictionary->allocate( 967 this->getNameSymbol(),w,this); 968 return this->standin; } getStandIn()969 StandIn *getStandIn() { return this->standin; } 970 971 // 972 // Manipulate the configration dialog box for this node. 973 // newConfigurationDialog(Widget w)974 ConfigurationDialog *newConfigurationDialog(Widget w) 975 { 976 if (this->cdb == NULL) 977 this->cdb = theCDBAllocatorDictionary->allocate( 978 this->getNameSymbol(), 979 w,this); 980 return this->cdb; 981 } getConfigurationDialog()982 ConfigurationDialog *getConfigurationDialog() { return this->cdb; } 983 984 // 985 // Perform the default function that is associated with the 986 // StandIn's default event. 987 // 988 virtual void openDefaultWindow(Widget parent); 989 990 // 991 // Let the caller of openDefaultWindow() know what kind of window she's getting. 992 // This is intended for use in EditorWindow so that we can sanity check the number 993 // of cdbs were going to open before kicking off the operation and so that we 994 // don't question the user before opening large numbers of interactors. 995 // A name describing the type of window can be written into window_name in order 996 // to enable nicer warning messages. 997 // 998 virtual boolean defaultWindowIsCDB(char* window_name = NULL) 999 { if (window_name) strcpy (window_name, "Configuration Dialog"); return TRUE; } 1000 1001 // 1002 // Open this node's configuration dialog box. 1003 // 1004 virtual void openConfigurationDialog(Widget parent); 1005 1006 // 1007 // Display help for this node in a window. 1008 // 1009 virtual void openHelpWindow(Widget parent); 1010 1011 // 1012 // Returns FALSE for most nodes and is overridden by InteractorNode and 1013 // MacroNode. 1014 // isAllowedInMacro()1015 virtual boolean isAllowedInMacro() 1016 { 1017 return this->definition->isAllowedInMacro(); 1018 } 1019 1020 // 1021 // Manipulate whether the default value or assigned value is used 1022 // as the value for i/o parameter i. Parameters are indexed from 1. 1023 // 1024 void useDefaultInputValue(int index, boolean send = TRUE) 1025 {this->setIODefaultingStatus(index,TRUE,TRUE,send);} 1026 void useAssignedInputValue(int index, boolean send = TRUE) 1027 {this->setIODefaultingStatus(index,TRUE,FALSE,send);} 1028 void useDefaultOutputValue(int index, boolean send = TRUE) 1029 {this->setIODefaultingStatus(index,FALSE,TRUE,send);} 1030 void useAssignedOutputValue(int index, boolean send = TRUE) 1031 {this->setIODefaultingStatus(index,FALSE,FALSE,send);} 1032 1033 // 1034 // Determine if this node is a node of the given class 1035 // 1036 boolean isA(const char *classname); 1037 virtual boolean isA(Symbol classname); 1038 1039 // 1040 // Reset the node to using the default cfg state (probably before reading 1041 // in a new cfg file). In general, the only state that should be reset 1042 // here is state that is saved in .cfg files. 1043 // 1044 virtual void setDefaultCfgState(); 1045 1046 // 1047 // Return TRUE if this node has state that will be saved in a .cfg file. 1048 // At this level, nodes do not have cfg state. 1049 // 1050 virtual boolean hasCfgState(); 1051 1052 // 1053 // Disconnect all input and output arcs from this node. 1054 // 1055 boolean disconnectArks(); 1056 1057 // 1058 // Return TRUE if the node can be switched (pasted/merged/moved) from 1059 // the 'from' net to the 'to' net. 1060 // 1061 virtual boolean canSwitchNetwork(Network *from, Network *to); 1062 1063 // 1064 // Switch the node's net from 'from' to 'to' 1065 // 'silently' added 11/10/02 to support EditorWindow's undo. We might be 1066 // merging network elements some of which are going to be discarded. We 1067 // do this sometimes when we want to a node's arcs. There are nodes saved 1068 // at the other ends of those arcs however those nodes are just going to 1069 // be thrown away at the end of the merge. 1070 // 1071 virtual void switchNetwork(Network *from, Network *to, boolean silently=FALSE); 1072 1073 // 1074 // Get the selectable values for the n'th input. 1075 // This returns a pointer to a constant array of pointers to 1076 // constant strings which is NOT to be manipulated by the caller. 1077 // The returned array of pointers is NULL terminated. 1078 // 1079 const char * const *getInputValueOptions(int index); 1080 1081 // 1082 // Return the window associated with this node (if one exists) getDXWindow()1083 virtual DXWindow *getDXWindow() {return NULL;} 1084 1085 // 1086 // get the node title (if the node has a title) 1087 // getTitle()1088 virtual const char *getTitle() {return NULL;} 1089 1090 #ifdef DXUI_DEVKIT 1091 // 1092 // Routines to print the module as DX C code. 1093 // 1094 boolean beginDXCallModule(FILE *f); 1095 boolean callDXCallModule(FILE *f); 1096 boolean endDXCallModule(FILE *f); 1097 #endif // DXUI_DEVKIT 1098 1099 // 1100 // Provide a mechanism on behalf of StandIn for getting a small piece of text 1101 // for postscript output. This text will be associated with the standin. I 1102 // chose to stick this into Node rather than virtualizing the postscript 1103 // print func which would be the normal C++ way to handle this. It's just that 1104 // postscript printing is so complicated and so few people want to learn it that 1105 // the benefit of making it virtual seems small. I originally put this here 1106 // on behalf of Compute so that there is a way to print the expression. 1107 // ComputeNode will supply its expression as extra PS text. 1108 // getExtraPSText()1109 virtual const char* getExtraPSText() { return NUL(char*); } 1110 1111 1112 // 1113 // I changed Network::nodeList from List to NodeList in order to provide 1114 // a faster lookup. (Parsing ReceiverNodes is very slow because they 1115 // scan the entire network for a matching TransmitterNode.) Some nodes 1116 // need special handling: Transmitter,Receiver,Display,Image,UniqueNameNode 1117 // because they're frequently looked up. 1118 // needsFastSort()1119 virtual boolean needsFastSort() { return FALSE; } 1120 1121 virtual boolean printAsJava(FILE* ); getJavaNodeName()1122 virtual const char* getJavaNodeName() { return "Node"; } hasJavaRepresentation()1123 virtual boolean hasJavaRepresentation() { return FALSE; } printInputAsJava(int input)1124 virtual boolean printInputAsJava(int input) { return FALSE; } getJavaInputValueString(int index)1125 virtual const char *getJavaInputValueString(int index) 1126 { return getInputValueString(index); } 1127 1128 1129 // 1130 // Java Beans 1131 // printAsBean(FILE *)1132 virtual boolean printAsBean(FILE*) { return TRUE; } printAsBeanInitCall(FILE *)1133 virtual boolean printAsBeanInitCall(FILE*) { return TRUE; } 1134 1135 // 1136 // On behalf of GraphLayout we store layout information on a 1137 // per-node basis. I would prefer not to have this public 1138 // method here because no one outside GraphLayout should ever 1139 // be touching the layout information. I could declare a 1140 // GraphLayout method as a friend but then I would have to 1141 // include another .h file here and that's really bad since 1142 // it would require rebuilding the world quite often. 1143 // getLayoutInformation()1144 Base* getLayoutInformation() { return this->layout_information; } 1145 void setLayoutInformation(Base* li); 1146 1147 // 1148 // Returns a pointer to the class name. 1149 // getClassName()1150 virtual const char* getClassName() { return ClassNode; } 1151 }; 1152 1153 1154 #endif // _Node_h 1155