cmCableData.h 2.6 KB

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