cmCableData.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #ifndef cmCableData_h
  12. #define cmCableData_h
  13. #include "cmStandardIncludes.h"
  14. #include "cmCommand.h"
  15. class cmCableCommand;
  16. class cmCablePackageCommand;
  17. /** \class cmCableData
  18. * \brief Hold data in one location for all cmCableCommand subclasses.
  19. */
  20. class cmCableData
  21. {
  22. public:
  23. cmCableData(const cmCableCommand*, const std::string&);
  24. ~cmCableData();
  25. /**
  26. * Returns true if the given cmCableCommand is the owner of this
  27. * cmCableData.
  28. */
  29. bool OwnerIs(const cmCableCommand* owner) const
  30. { return (owner == m_Owner); }
  31. std::ostream& GetOutputStream()
  32. { return m_OutputFile; }
  33. void InitializeOutputFile();
  34. void CloseOutputFile();
  35. void WriteConfigurationHeader();
  36. void WriteConfigurationFooter();
  37. /**
  38. * Class to simplify indentation printing.
  39. */
  40. class Indentation
  41. {
  42. public:
  43. Indentation(int indent): m_Indent(indent) {}
  44. void Print(std::ostream& os) const;
  45. Indentation Next() const { return Indentation(m_Indent+2); }
  46. Indentation Previous() const { return Indentation(m_Indent-2); }
  47. private:
  48. int m_Indent;
  49. };
  50. void Indent() { m_Indentation = m_Indentation.Next(); }
  51. void Unindent() { m_Indentation = m_Indentation.Previous(); }
  52. const Indentation& GetIndentation() const { return m_Indentation; }
  53. void OpenNamespace(const std::string&);
  54. void CloseNamespace(const std::string&);
  55. void BeginPackage(cmCablePackageCommand*);
  56. void EndPackage();
  57. void SetPackageClassIndex(int index) { m_PackageClassIndex = index; }
  58. int GetPackageClassIndex() const { return m_PackageClassIndex; }
  59. private:
  60. /**
  61. * The cmCableCommand which created this instance of cmCableCommand.
  62. */
  63. const cmCableCommand* m_Owner;
  64. /**
  65. * The name of the output file opened as m_OutputFile.
  66. */
  67. std::string m_OutputFileName;
  68. /**
  69. * The output file to which the configuration is written.
  70. */
  71. std::ofstream m_OutputFile;
  72. /**
  73. * Current indentation for output.
  74. */
  75. Indentation m_Indentation;
  76. /**
  77. * The stack of namespaces.
  78. */
  79. std::list<std::string> m_NamespaceStack;
  80. /**
  81. * The command that created the package currently being defined.
  82. */
  83. cmCablePackageCommand* m_Package;
  84. /**
  85. * The namespace level at which the current package was created.
  86. * This must be the level when the package is ended.
  87. */
  88. unsigned int m_PackageNamespaceDepth;
  89. /**
  90. * During the final pass, this maintains the index into a cmMakefile's
  91. * m_Classes corresponding to the cmClassFile for this package's generated
  92. * file.
  93. */
  94. int m_PackageClassIndex;
  95. };
  96. std::ostream& operator<<(std::ostream&, const cmCableData::Indentation&);
  97. #endif