home *** CD-ROM | disk | FTP | other *** search
/ ftptest.leeds.ac.uk / 2015.02.ftptest.leeds.ac.uk.tar / ftptest.leeds.ac.uk / bionet / CAE-GROUP / SCL-WIN3x / SCL.EXE / CMDMGR.H < prev    next >
C/C++ Source or Header  |  1994-08-06  |  5KB  |  192 lines

  1. #ifndef cmdmgr_h
  2. #define cmdmgr_h
  3.  
  4. /*
  5. * NIST STEP Editor Class Library
  6. * cleditor/cmdmgr.h
  7. * February, 1994
  8. * David Sauder
  9. * K. C. Morris
  10.  
  11. * Development of this software was funded by the United States Government,
  12. * and is not subject to copyright.
  13. */
  14.  
  15. /* $Id: cmdmgr.h,v 2.0.1.2 1994/04/05 16:41:40 sauderd Exp $ */ 
  16.  
  17.  
  18.  
  19. #include <gennode.h>
  20. #include <gennodel.h>
  21. #include <gennodei.h>
  22. #include <gennodea.h>
  23.  
  24. #include <editordefines.h>
  25. #include <mgrnode.h>
  26. #include <mgrnodelist.h>
  27. #include <dispnode.h>
  28. #include <dispnodlist.h>
  29. #include <List.h>
  30.  
  31. typedef unsigned short BOOLEAN;
  32.  
  33. //#define NUM_CMDMGR_CMDS 9
  34.     // this is the number of columns that contain cmds (as opposed
  35.     // to state info)
  36. #define NUM_CMD_COLUMNS 3
  37.  
  38. // **** each of CMD_CHAR must be a unique char.
  39. #define SAVE_COMPLETE_CMD_CHAR        's'
  40. #define SAVE_COMPLETE_CMD_COL         0
  41. #define SAVE_COMPLETE_STATE_CHAR    ' '
  42. #define SAVE_COMPLETE_STATE_COL         4
  43.  
  44. #define SAVE_INCOMPLETE_CMD_CHAR    'i'
  45. #define SAVE_INCOMPLETE_CMD_COL         0
  46. #define SAVE_INCOMPLETE_STATE_CHAR    'I'
  47. #define SAVE_INCOMPLETE_STATE_COL     4
  48.  
  49. // backup to last save
  50. //#define CANCEL_CMD_CHAR            'c'
  51. //#define CANCEL_CMD_COL             0
  52.  
  53. #define NEW_STATE_CHAR            'N'
  54. #define NEW_STATE_COL             4
  55.  
  56. #define DELETE_CMD_CHAR            'd'
  57. #define DELETE_CMD_COL             0
  58. #define DELETE_STATE_CHAR        'D'
  59. #define DELETE_STATE_COL         4
  60.  
  61.     // close will try to save it to its previous status
  62. #define CLOSE_CMD_CHAR            'c'
  63. #define CLOSE_CMD_COL             2
  64.  
  65. #define MODIFY_CMD_CHAR            'm'
  66. #define MODIFY_CMD_COL             2
  67. #define MODIFY_STATE_CHAR         'M'
  68. #define MODIFY_STATE_COL         3
  69.  
  70. #define VIEW_CMD_CHAR             'v'
  71. #define VIEW_CMD_COL             2
  72. #define VIEW_STATE_CHAR            'V'
  73. #define VIEW_STATE_COL             3
  74.  
  75. #define REPLICATE_CMD_CHAR         'r'
  76. #define REPLICATE_CMD_COL         1
  77.  
  78. #define EXECUTE_CMD_CHAR        'x'
  79. #define EXECUTE_CMD_COL             5
  80.  
  81. #define UNMARK_CMD_CHAR            'u'
  82. #define UNMARK_CMD_COL             5
  83.  
  84. ///////////////////////////////////////////////////////////////////////////////
  85.  
  86. class ReplicateLinkNode : public SingleLinkNode {
  87.   private:
  88.   protected:
  89.     MgrNode * _repNode;
  90.   public:
  91.     ReplicateLinkNode() { _repNode = 0; }
  92.     ~ReplicateLinkNode() { }
  93.  
  94.     char *ClassName () { return "ReplicateLinkNode"; }
  95.  
  96.     MgrNode *ReplicateNode() { return _repNode; }
  97.     void ReplicateNode(MgrNode *rn) { _repNode = rn; }
  98. };
  99.  
  100. class ReplicateList : public SingleLinkList {
  101.   private:
  102.   protected:
  103.   public:
  104.     ReplicateList()  { }
  105.     ~ReplicateList() { }
  106.  
  107.     virtual SingleLinkNode * NewNode () { return new ReplicateLinkNode; }
  108.  
  109.     BOOLEAN IsOnList(MgrNode *mn);
  110.     ReplicateLinkNode *FindNode(MgrNode *mn);
  111.     
  112.     ReplicateLinkNode * AddNode (MgrNode * rn) { 
  113.     ReplicateLinkNode *node = (ReplicateLinkNode *) NewNode();
  114.     node->ReplicateNode(rn);
  115.     SingleLinkList::AppendNode(node);
  116.     return node;
  117.     }    
  118.  
  119.     BOOLEAN Remove(ReplicateLinkNode *rln);
  120.     BOOLEAN Remove(MgrNode *rn);
  121.  
  122.     char *ClassName () { return "ReplicateList"; }
  123. };
  124.  
  125. ///////////////////////////////////////////////////////////////////////////////
  126.  
  127. class CmdMgr 
  128. {
  129. protected:
  130.     MgrNodeList *completeList;
  131.     MgrNodeList *incompleteList;
  132.     MgrNodeList *cancelList;
  133.     MgrNodeList *deleteList;
  134.  
  135.     DisplayNodeList *mappedWriteList;
  136.     DisplayNodeList *mappedViewList;
  137.     DisplayNodeList *closeList;
  138.  
  139.     ReplicateList *replicateList;
  140.   public:
  141.  
  142.     CmdMgr();
  143.  
  144. // STATE LIST OPERATIONS
  145.     MgrNode     *GetHead(stateEnum listType);
  146.     DisplayNode *GetHead(displayStateEnum listType);
  147.     ReplicateLinkNode    *GetReplicateHead()
  148.     { return (ReplicateLinkNode *)(replicateList->GetHead()); }
  149.  
  150.     void ClearEntries(stateEnum listType);
  151.     void ClearEntries(displayStateEnum listType);
  152.     void ClearReplicateEntries() { replicateList->Empty(); } 
  153.     ReplicateList *RepList() { return replicateList; } 
  154.  
  155.             // searches current list for fileId
  156.     MgrNode *StateFindFileId(stateEnum s, int fileId);
  157.             // returns stateNext or statePrev member variables
  158.             // i.e. next or previous node on curr state list
  159.  
  160.     int SaveCompleteCmdList(MgrNode *mn)
  161.     { return mn->ChangeList(completeList); }
  162.     int SaveIncompleteCmdList(MgrNode *mn)
  163.     { return mn->ChangeList(incompleteList); }
  164.     int CancelCmdList(MgrNode *mn)
  165.     { return mn->ChangeList(cancelList); }
  166.     int DeleteCmdList(MgrNode *mn)
  167.     { return mn->ChangeList(deleteList); }
  168.     int ModifyCmdList(MgrNode *mn)
  169.     { return mn->ChangeList(mappedWriteList); }
  170.     int ViewCmdList(MgrNode *mn)
  171.     { return mn->ChangeList(mappedViewList); }
  172.     int CloseCmdList(MgrNode *mn)
  173.     { return ( ( mn->DisplayState() == mappedWrite ) || 
  174.            ( mn->DisplayState() == mappedView ) ) ?
  175.                mn->ChangeList(closeList) : 0;
  176.     }
  177. /*
  178. //    { if(mn->DisplayState() == mappedWrite || 
  179. //         mn->DisplayState() == mappedView)
  180. //         return mn->ChangeList(closeList); 
  181. //      else return 0;
  182. //    }
  183. */
  184.     int ReplicateCmdList(MgrNode *mn);
  185.  
  186.     void ClearInstances();
  187. protected:
  188.  
  189. };
  190.  
  191. #endif
  192.