sequence.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // Sequence Header File
  2. #ifndef __SEQUENCE__
  3. #define __SEQUENCE__
  4. class CSequence
  5. {
  6. typedef list < CSequence * > sequence_l;
  7. // typedef map < int, CSequence *> sequenceID_m;
  8. typedef list < CBlock * > block_l;
  9. public:
  10. //Constructors / Destructors
  11. CSequence( void );
  12. ~CSequence( void );
  13. //Creation and deletion
  14. static CSequence *Create( void );
  15. void Delete( CIcarus* icarus );
  16. //Organization functions
  17. void AddChild( CSequence * );
  18. void RemoveChild( CSequence * );
  19. void SetParent( CSequence * );
  20. CSequence *GetParent( void ) const { return m_parent; }
  21. //Block manipulation
  22. CBlock *PopCommand( int );
  23. int PushCommand( CBlock *, int );
  24. //Flag utilties
  25. void SetFlag( int );
  26. void RemoveFlag( int, bool = false );
  27. int HasFlag( int );
  28. int GetFlags( void ) const { return m_flags; }
  29. void SetFlags( int flags ) { m_flags = flags; }
  30. //Various encapsulation utilities
  31. int GetIterations( void ) const { return m_iterations; }
  32. void SetIterations( int it ) { m_iterations = it; }
  33. int GetID( void ) const { return m_id; }
  34. void SetID( int id ) { m_id = id; }
  35. CSequence *GetReturn( void ) const { return m_return; }
  36. void SetReturn ( CSequence *sequence );
  37. int GetNumCommands( void ) const { return m_numCommands; }
  38. int GetNumChildren( void ) const { return m_children.size(); }
  39. CSequence *GetChildByID( int id );
  40. CSequence *GetChildByIndex( int iIndex );
  41. bool HasChild( CSequence *sequence );
  42. int Save();
  43. int Load( CIcarus* icarus );
  44. // Overloaded new operator.
  45. inline void *operator new( size_t size )
  46. { // Allocate the memory.
  47. return IGameInterface::GetGame()->Malloc( size );
  48. }
  49. // Overloaded delete operator.
  50. inline void operator delete( void *pRawData )
  51. { // Free the Memory.
  52. IGameInterface::GetGame()->Free( pRawData );
  53. }
  54. enum
  55. {
  56. SQ_COMMON = 0x00000000, //Common one-pass sequence
  57. SQ_LOOP = 0x00000001, //Looping sequence
  58. SQ_RETAIN = 0x00000002, //Inside a looping sequence list, retain the information
  59. SQ_AFFECT = 0x00000004, //Affect sequence
  60. SQ_RUN = 0x00000008, //A run block
  61. SQ_PENDING = 0x00000010, //Pending use, don't free when flushing the sequences
  62. SQ_CONDITIONAL = 0x00000020, //Conditional statement
  63. SQ_TASK = 0x00000040, //Task block
  64. };
  65. enum
  66. {
  67. POP_FRONT,
  68. POP_BACK,
  69. PUSH_FRONT,
  70. PUSH_BACK
  71. };
  72. protected:
  73. int SaveCommand( CBlock *block );
  74. int LoadCommand( CBlock *block, CIcarus *icarus );
  75. //Organization information
  76. sequence_l m_children;
  77. //sequenceID_m m_childrenMap;
  78. //int m_numChildren;
  79. CSequence *m_parent;
  80. CSequence *m_return;
  81. //Data information
  82. block_l m_commands;
  83. int m_flags;
  84. int m_iterations;
  85. int m_id;
  86. int m_numCommands;
  87. };
  88. #endif //__SEQUENCE__