cmCableData.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. cmCablePackageCommand *GetCurrentPackage() { return m_Package; }
  58. private:
  59. /**
  60. * The cmCableCommand which created this instance of cmCableCommand.
  61. */
  62. const cmCableCommand* m_Owner;
  63. /**
  64. * The name of the output file opened as m_OutputFile.
  65. */
  66. std::string m_OutputFileName;
  67. /**
  68. * The output file to which the configuration is written.
  69. */
  70. std::ofstream m_OutputFile;
  71. /**
  72. * Current indentation for output.
  73. */
  74. Indentation m_Indentation;
  75. /**
  76. * The stack of namespaces.
  77. */
  78. std::list<std::string> m_NamespaceStack;
  79. /**
  80. * The command that created the package currently being defined.
  81. */
  82. cmCablePackageCommand* m_Package;
  83. /**
  84. * The namespace level at which the current package was created.
  85. * This must be the level when the package is ended.
  86. */
  87. unsigned int m_PackageNamespaceDepth;
  88. };
  89. std::ostream& operator<<(std::ostream&, const cmCableData::Indentation&);
  90. #endif