summaryrefslogtreecommitdiffstats
path: root/Source/cmCableCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2001-02-26 23:00:49 (GMT)
committerBrad King <brad.king@kitware.com>2001-02-26 23:00:49 (GMT)
commitb908149828f060186cb9c240e505b865ad31494f (patch)
tree5987dad0bed3478fb5377a6aa0bf59cc34fe999c /Source/cmCableCommand.cxx
parent8859bd5ac835c639622e169192cbc571d90a3f4c (diff)
downloadCMake-b908149828f060186cb9c240e505b865ad31494f.zip
CMake-b908149828f060186cb9c240e505b865ad31494f.tar.gz
CMake-b908149828f060186cb9c240e505b865ad31494f.tar.bz2
ENH: Added CABIL commands for configuration file generation.
Diffstat (limited to 'Source/cmCableCommand.cxx')
-rw-r--r--Source/cmCableCommand.cxx91
1 files changed, 91 insertions, 0 deletions
diff --git a/Source/cmCableCommand.cxx b/Source/cmCableCommand.cxx
new file mode 100644
index 0000000..f7a28ea
--- /dev/null
+++ b/Source/cmCableCommand.cxx
@@ -0,0 +1,91 @@
+/*=========================================================================
+
+ Program: Insight Segmentation & Registration Toolkit
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+
+ Copyright (c) 2000 National Library of Medicine
+ All rights reserved.
+
+ See COPYRIGHT.txt for copyright details.
+
+=========================================================================*/
+#include "cmCabilCommand.h"
+#include "cmCacheManager.h"
+
+// cmCabilCommand
+
+
+/**
+ * Constructor initializes to empty m_CabilData.
+ */
+cmCabilCommand::cmCabilCommand(): m_CabilData(0)
+{
+}
+
+
+/**
+ * Destructor frees the cmCabilData only if this command is its owner.
+ */
+cmCabilCommand::~cmCabilCommand()
+{
+ if(m_CabilData && m_CabilData->OwnerIs(this))
+ {
+ delete m_CabilData;
+ }
+}
+
+
+/**
+ * Write a CABIL configuration file header.
+ */
+void cmCabilCommand::WriteConfigurationHeader(std::ostream& os) const
+{
+ os << "<?xml version=\"1.0\"?>" << std::endl
+ << "<CabilConfiguration>" << std::endl;
+}
+
+
+/**
+ * Write a CABIL configuration file footer.
+ */
+void cmCabilCommand::WriteConfigurationFooter(std::ostream& os) const
+{
+ os << "</CabilConfiguration>" << std::endl;
+}
+
+
+/**
+ * Ensure that this cmCabilCommand has a valid m_CabilData pointer.
+ */
+void cmCabilCommand::SetupCabilData()
+{
+ // Only do something if the pointer is invalid.
+ if(m_CabilData)
+ { return; }
+
+ // Look through the vector of commands from the makefile.
+ const std::vector<cmCommand*>& usedCommands =
+ m_Makefile->GetUsedCommands();
+ for(std::vector<cmCommand*>::const_iterator commandIter =
+ usedCommands.begin(); commandIter != usedCommands.end(); ++commandIter)
+ {
+ // If this command is a cmCabilCommand, see if it has a cmCabilData
+ // instance.
+ cmCabilCommand* command = cmCabilCommand::SafeDownCast(*commandIter);
+ if(command)
+ { m_CabilData = command->m_CabilData; }
+
+ // If we found an instance of cmCabilData, then we are done.
+ if(m_CabilData)
+ { return; }
+ }
+
+ // We didn't find another cmCabilCommand with a valid cmCabilData.
+ // We must allocate the new cmCabilData ourselves, and with this
+ // command as its owner.
+ m_CabilData = new cmCabilData(this);
+}