ENH: Removing old-style cable commands related to the instantiation functionality which has now been removed from cable.

This commit is contained in:
Brad King 2001-06-19 12:03:04 -04:00
parent b4339eba05
commit 873c9e7840
23 changed files with 0 additions and 2655 deletions

View File

@ -1,80 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCableCloseNamespaceCommand.h"
#include "cmCacheManager.h"
// cmCableCloseNamespaceCommand
bool cmCableCloseNamespaceCommand::InitialPass(std::vector<std::string>& args)
{
if(args.size() != 1)
{
this->SetError("called with incorrect number of arguments");
return false;
}
// This command needs to access the Cable data.
this->SetupCableData();
// The argument is the namespace name.
m_NamespaceName = args[0];
// Ask the cable data to close the namespace.
m_CableData->CloseNamespace(m_NamespaceName);
// Write the configuration for this command.
this->WriteNamespaceFooter();
return true;
}
/**
* Generate a CABLE Namespace close tag.
*/
void cmCableCloseNamespaceCommand::WriteNamespaceFooter() const
{
m_CableData->Unindent();
std::ostream& os = m_CableData->GetOutputStream();
cmCableData::Indentation indent = m_CableData->GetIndentation();
os << indent << "</Namespace> <!-- \"" << m_NamespaceName.c_str()
<< "\" -->" << std::endl;
}

View File

@ -1,114 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCableCloseNamespaceCommand_h
#define cmCableCloseNamespaceCommand_h
#include "cmStandardIncludes.h"
#include "cmCableCommand.h"
/** \class cmCableCloseNamespaceCommand
* \brief Define a command that closes a CABLE Namespace.
*
* cmCableCloseNamespaceCommand is used to generate CABLE Namespace
* close tags in the configuration file.
*/
class cmCableCloseNamespaceCommand : public cmCableCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmCableCloseNamespaceCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string>& args);
/**
* This determines if the command gets propagated down
* to makefiles located in subdirectories.
*/
virtual bool IsInherited()
{return true;}
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CABLE_CLOSE_NAMESPACE";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Close a CABLE Namespace";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"CABLE_CLOSE_NAMESPACE(namespace_name)\n"
"Close the given namespace in the generated configuration file.\n"
"There must be a matching CABLE_OPEN_NAMESPACE(namespace_name)\n"
"called with the same name.";
}
cmTypeMacro(cmCableCloseNamespaceCommand, cmCableCommand);
private:
void WriteNamespaceFooter() const;
private:
/**
* The name of the namespace to setup.
*/
std::string m_NamespaceName;
};
#endif

View File

@ -1,107 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCableCommand.h"
#include "cmCacheManager.h"
// cmCableCommand
/**
* Constructor initializes to empty m_CableData.
*/
cmCableCommand::cmCableCommand(): m_CableData(0)
{
}
/**
* Destructor frees the cmCableData only if this command is its owner.
*/
cmCableCommand::~cmCableCommand()
{
if(m_CableData && m_CableData->OwnerIs(this))
{
delete m_CableData;
}
}
/**
* Ensure that this cmCableCommand has a valid m_CableData pointer.
*/
void cmCableCommand::SetupCableData()
{
// Only do something if the pointer is invalid.
if(m_CableData)
{ 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 cmCableCommand, see if it has a cmCableData
// instance.
cmCableCommand* command = cmCableCommand::SafeDownCast(*commandIter);
if(command)
{ m_CableData = command->m_CableData; }
// If we found an instance of cmCableData, then we are done.
if(m_CableData)
{ return; }
}
// We must make sure the output directory exists so that the CABLE
// configuration file can be opened by the cmCableData.
std::string pathName = m_Makefile->GetStartOutputDirectory();
if(!cmSystemTools::MakeDirectory(pathName.c_str()))
{
cmSystemTools::Error("Unable to make directory ", pathName.c_str());
}
// We didn't find another cmCableCommand with a valid cmCableData.
// We must allocate the new cmCableData ourselves, and with this
// command as its owner.
pathName += "/cable_config.xml";
m_CableData = new cmCableData(this, pathName);
}

View File

@ -1,78 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCableCommand_h
#define cmCableCommand_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
#include "cmCableData.h"
/** \class cmCableCommand
* \brief Superclass for all cmCable command classes.
*
* cmCableCommand is the superclass for all CABLE-related commands.
* The C++ Automated Bindings for Language Extension (CABLE) tool is
* configured using an XML input file. The input format is quite
* flexible, but XML is hard for humans to write by hand. The CABLE
* commands in CMake are designed to simplify the interface with only
* a small loss in functionality. These commands can be used to
* automatically generate CABLE configuration files.
*/
class cmCableCommand : public cmCommand
{
public:
cmCableCommand();
virtual ~cmCableCommand();
cmTypeMacro(cmCableCommand, cmCommand);
protected:
void SetupCableData();
/**
* The cmCableData holding common information for all cmCableCommand
* instances.
*/
cmCableData* m_CableData;
};
#endif

View File

@ -1,244 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCableData.h"
#include "cmCacheManager.h"
#include "cmCablePackageCommand.h"
/**
* The cmCableData instance is owned by one cmCableCommand, which is given
* to this constructor.
*/
cmCableData::cmCableData(const cmCableCommand* owner,
const std::string& configurationFile):
m_Owner(owner),
m_OutputFileName(configurationFile),
m_OutputFile(configurationFile.c_str()),
m_Indentation(0),
m_Package(NULL),
m_PackageNamespaceDepth(0)
{
this->InitializeOutputFile();
}
/**
* Free all data that was stored here. Also close the output file.
*/
cmCableData::~cmCableData()
{
// End last package, if any.
this->EndPackage();
// Finish up the output file.
this->CloseOutputFile();
}
/**
* Write the configuration header to the output file.
*/
void cmCableData::InitializeOutputFile()
{
if(m_OutputFile)
{
this->WriteConfigurationHeader();
}
else
{
cmSystemTools::Error("Unable to open CABLE config file: ",
m_OutputFileName.c_str());
}
}
/**
* Close the configuration output file. This writes the configuration
* footer.
*/
void cmCableData::CloseOutputFile()
{
if(m_OutputFile)
{
this->WriteConfigurationFooter();
m_OutputFile.close();
}
}
/**
* Write a CABLE configuration file header.
*/
void cmCableData::WriteConfigurationHeader()
{
m_OutputFile << m_Indentation << "<?xml version=\"1.0\"?>" << std::endl
<< m_Indentation << "<CableConfiguration>" << std::endl;
this->Indent();
}
/**
* Write a CABLE configuration file footer.
*/
void cmCableData::WriteConfigurationFooter()
{
this->Unindent();
m_OutputFile << m_Indentation << "</CableConfiguration>" << std::endl;
}
/**
* Print indentation spaces.
*/
void
cmCableData::Indentation
::Print(std::ostream& os) const
{
if(m_Indent <= 0)
{ return; }
// Use blocks of 8 spaces to speed up big indents.
unsigned int blockCount = m_Indent >> 3;
unsigned int singleCount = m_Indent & 7;
while(blockCount-- > 0)
{
os << " ";
}
while(singleCount-- > 0)
{
os << " ";
}
}
/**
* Open a namespace with the given name.
*/
void cmCableData::OpenNamespace(const std::string& name)
{
m_NamespaceStack.push_back(name);
}
/**
* Close the current namespace, checking whether it has the given name.
*/
void cmCableData::CloseNamespace(const std::string& name)
{
if(m_NamespaceStack.empty())
{
cmSystemTools::Error("Unbalanced close-namespace = ", name.c_str());
return;
}
if(m_NamespaceStack.back() != name)
{
cmSystemTools::Error("Wrong name on close-namespace = ", name.c_str());
}
// If this closes the namespace where the current package was opened,
// the package must end as well.
if(m_Package && (m_PackageNamespaceDepth == m_NamespaceStack.size()))
{
this->EndPackage();
}
m_NamespaceStack.pop_back();
}
/**
* Begin a new package definition. If there is a current one, it
* will be ended.
*/
void cmCableData::BeginPackage(cmCablePackageCommand* command)
{
// Close the current package, if any.
this->EndPackage();
// Open this package.
m_Package = command;
// Write out the package's header.
m_Package->WritePackageHeader();
// Save the package's opening namespace depth for later verification
// on the end of the package.
m_PackageNamespaceDepth = m_NamespaceStack.size();
}
/**
* End a package definition.
*/
void cmCableData::EndPackage()
{
// Make sure we have an open package.
if(!m_Package)
{
return;
}
// Make sure the namespace nesting depth matches the opening depth
// of the package.
if(m_PackageNamespaceDepth != m_NamespaceStack.size())
{
cmSystemTools::Error("Package ended at different namespace depth than"
"it was created!", "");
}
// Write out the package's footer.
m_Package->WritePackageFooter();
// Done with the package.
m_Package = NULL;
}
/**
* Simplify indentation printing by allowing Indentation objects to be added
* to streams.
*/
std::ostream& operator<<(std::ostream& os,
const cmCableData::Indentation& indent)
{
indent.Print(os);
return os;
}

View File

@ -1,141 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCableData_h
#define cmCableData_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
class cmCableCommand;
class cmCablePackageCommand;
/** \class cmCableData
* \brief Hold data in one location for all cmCableCommand subclasses.
*/
class cmCableData
{
public:
cmCableData(const cmCableCommand*, const std::string&);
~cmCableData();
/**
* Returns true if the given cmCableCommand is the owner of this
* cmCableData.
*/
bool OwnerIs(const cmCableCommand* owner) const
{ return (owner == m_Owner); }
std::ostream& GetOutputStream()
{ return m_OutputFile; }
void InitializeOutputFile();
void CloseOutputFile();
void WriteConfigurationHeader();
void WriteConfigurationFooter();
/**
* Class to simplify indentation printing.
*/
class Indentation
{
public:
Indentation(int indent): m_Indent(indent) {}
void Print(std::ostream& os) const;
Indentation Next() const { return Indentation(m_Indent+2); }
Indentation Previous() const { return Indentation(m_Indent-2); }
private:
int m_Indent;
};
void Indent() { m_Indentation = m_Indentation.Next(); }
void Unindent() { m_Indentation = m_Indentation.Previous(); }
const Indentation& GetIndentation() const { return m_Indentation; }
void OpenNamespace(const std::string&);
void CloseNamespace(const std::string&);
void BeginPackage(cmCablePackageCommand*);
void EndPackage();
cmCablePackageCommand *GetCurrentPackage() { return m_Package; }
private:
/**
* The cmCableCommand which created this instance of cmCableCommand.
*/
const cmCableCommand* m_Owner;
/**
* The name of the output file opened as m_OutputFile.
*/
std::string m_OutputFileName;
/**
* The output file to which the configuration is written.
*/
std::ofstream m_OutputFile;
/**
* Current indentation for output.
*/
Indentation m_Indentation;
/**
* The stack of namespaces.
*/
std::list<std::string> m_NamespaceStack;
/**
* The command that created the package currently being defined.
*/
cmCablePackageCommand* m_Package;
/**
* The namespace level at which the current package was created.
* This must be the level when the package is ended.
*/
unsigned int m_PackageNamespaceDepth;
};
std::ostream& operator<<(std::ostream&, const cmCableData::Indentation&);
#endif

View File

@ -1,323 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCableDefineSetCommand.h"
#include "cmCacheManager.h"
#include "cmRegularExpression.h"
// cmCableDefineSetCommand
bool cmCableDefineSetCommand::InitialPass(std::vector<std::string>& args)
{
if(args.size() < 2)
{
this->SetError("called with incorrect number of arguments");
return false;
}
// This command needs access to the Cable data.
this->SetupCableData();
std::vector<std::string>::const_iterator arg = args.begin();
// The first argument is the name of the set.
m_SetName = *arg++;
// All arguments until a "SOURCE_FILES" are the elements to be placed in
// the set.
for(; (arg != args.end()) && (*arg != "SOURCE_FILES"); ++arg)
{
// If the element cannot be added, return an error.
// This can occur when a tag is not specified and can't be generated.
if(!this->AddElement(*arg))
{ return false; }
}
// If we are not at the end, the "SOURCE_FILES" keyword has been
// encountered.
if(arg != args.end())
{
// The rest of the arguments are source files to be included in
// any package which references the set.
for(++arg; arg != args.end(); ++arg)
{
if(!this->AddSourceFile(*arg))
{ return false; }
}
}
// Write this command's configuration output.
this->WriteConfiguration();
return true;
}
/**
* Write the CABLE configuration code to define this Set.
*/
void cmCableDefineSetCommand::WriteConfiguration() const
{
cmRegularExpression needCdataBlock("[&<>]");
// Get the ouptut information from the cmCableData.
std::ostream& os = m_CableData->GetOutputStream();
cmCableData::Indentation indent = m_CableData->GetIndentation();
// Output the code.
os << indent << "<" << this->GetXmlTag() << " name=\"" << m_SetName.c_str() << "\">" << std::endl;
for(std::vector<std::string>::const_iterator e = m_SourceHeaders.begin();
e != m_SourceHeaders.end(); ++e)
{
os << indent << " <File name=\"" << e->c_str() << "\"/>" << std::endl;
}
for(std::vector<std::string>::const_iterator e = m_InstantiationSources.begin();
e != m_InstantiationSources.end(); ++e)
{
os << indent << " <File name=\"" << e->c_str()
<< "\" purpose=\"instantiate\"/>" << std::endl;
}
for(Elements::const_iterator e = m_Elements.begin();
e != m_Elements.end(); ++e)
{
os << indent << " <Element";
// Only output the tag if it is not the empty string.
if(e->first.length() > 0)
{
os << " tag=\"" << e->first.c_str() << "\"";
}
os << ">";
if(needCdataBlock.find(e->second.c_str()))
{
os << "<![CDATA[" << e->second.c_str() << "]]>";
}
else
{
os << e->second.c_str();
}
os << "</Element>" << std::endl;
}
os << indent << "</" << this->GetXmlTag() << ">" << std::endl;
}
/**
* Add an element to the set. The given string is the argument to the
* command describing the element. There are two formats allowed:
* "code" = The code describing the element to CABLE is simply given.
* The GenerateTag() method will guess at a good tag for the
* code.
* "tag:code" = The left side of a single colon is text describing the tag.
* GenerateTag() will not be called.
*/
bool cmCableDefineSetCommand::AddElement(const std::string& arg)
{
// A regular expression to match the tagged element specification.
cmRegularExpression tagGiven("^([A-Za-z_0-9]*)[ \t]*:[ \t]*([^:].*|::.*)$");
std::string tag;
std::string code;
if(tagGiven.find(arg.c_str()))
{
// A tag was given. Use it.
tag = tagGiven.match(1);
code = tagGiven.match(2);
}
else
{
// No tag was given. Try to generate one.
if(!this->GenerateTag(arg, tag))
{ return false; }
code = arg;
}
// Add an element with the given tag and code.
m_Elements.push_back(Element(tag, code));
return true;
}
/**
* Given the string representing a set element, automatically generate
* the CABLE element tag for it.
*
* **This function determines how the output language of all
* CABLE-generated wrappers will look!**
*/
bool
cmCableDefineSetCommand::GenerateTag(const std::string& element,
std::string& tag)
{
// Hold the regular expressions for matching against the element.
cmRegularExpression regex;
// If the element's code begins in a $, it is referring to a set name.
// The set's elements have their own tags, so we don't need one.
regex.compile("^[ \t]*\\$");
if(regex.find(element))
{ tag = ""; return true; }
// Test for simple integer
regex.compile("^[ \t]*([0-9]*)[ \t]*$");
if(regex.find(element))
{
tag = "_";
tag.append(regex.match(1));
return true;
}
// Test for basic integer type
regex.compile("^[ \t]*(unsigned[ ]|signed[ ])?[ \t]*(char|short|int|long|long[ ]long)[ \t]*$");
if(regex.find(element))
{
tag = "_";
if(regex.match(1) == "unsigned ")
{ tag.append("u"); }
if(regex.match(2) == "long long")
{ tag.append("llong"); }
else
{ tag.append(regex.match(2)); }
return true;
}
// Test for basic floating-point type
regex.compile("^[ \t]*(long[ ]|)[ \t]*(float|double)[ \t]*$");
if(regex.find(element))
{
tag = "_";
if(regex.match(1) == "long ")
tag.append("l");
tag.append(regex.match(2));
return true;
}
// Test for basic wide-character type
regex.compile("^[ \t]*(wchar_t)[ \t]*$");
if(regex.find(element))
{
tag = "_wchar";
return true;
}
// Test for plain type name (without template arguments).
regex.compile("^[ \t]*([A-Za-z_][A-Za-z0-9_]*)[ \t]*$");
if(regex.find(element))
{
// The tag is the same as the type.
tag = regex.match(1);
return true;
}
// Test for template class instance.
regex.compile("^[ \t]*([A-Za-z_][A-Za-z0-9_]*)<.*[ \t]*$");
if(regex.find(element))
{
// The tag is the type without arguments (the arguments may have
// their own tags).
tag = regex.match(1);
return true;
}
// We can't generate a tag.
std::string err =
("doesn't know how to generate tag for element \""+element+"\" in set \""
+m_SetName+"\"\nPlease specify one with the \"tag:element\" syntax.");
this->SetError(err.c_str());
tag = "";
return false;
}
/**
* Add a source file associated with this set. Any package referencing
* this set will automatically include this source file.
*/
bool cmCableDefineSetCommand::AddSourceFile(const std::string& file)
{
// We must locate the file in the include path so that we can detect
// its extension, and whether there is more than one to find.
std::string header = file+".h";
std::string txx = file+".txx";
m_Makefile->ExpandVariablesInString(header);
m_Makefile->ExpandVariablesInString(txx);
// See if the file just exists here. The compiler's search path will
// locate it.
if(cmSystemTools::FileExists(header.c_str()))
{
m_SourceHeaders.push_back(header);
// See if there is a matching .txx as well.
if(cmSystemTools::FileExists(txx.c_str()))
{
m_InstantiationSources.push_back(txx);
}
return true;
}
// We must look for the file in the include search path.
const std::vector<std::string>& includeDirectories =
m_Makefile->GetIncludeDirectories();
for(std::vector<std::string>::const_iterator dir = includeDirectories.begin();
dir != includeDirectories.end(); ++dir)
{
std::string path = *dir + "/";
m_Makefile->ExpandVariablesInString(path);
if(cmSystemTools::FileExists((path+header).c_str()))
{
m_SourceHeaders.push_back(header);
// See if there is a matching .txx as well.
if(cmSystemTools::FileExists((path+txx).c_str()))
{
m_InstantiationSources.push_back(txx);
}
return true;
}
}
// We couldn't locate the source file. Report the error.
std::string err = "couldn't find source file " + header;
this->SetError(err.c_str());
return false;
}

View File

@ -1,142 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCableDefineSetCommand_h
#define cmCableDefineSetCommand_h
#include "cmStandardIncludes.h"
#include "cmCableCommand.h"
/** \class cmCableDefineSetCommand
* \brief Define a command that adds a CABLE Set definition.
*
* cmCableDefineSetCommand is used to define a named CABLE Set.
* The set can be referenced in other CABLE command arguments
* with a '$' followed by the set name.
*/
class cmCableDefineSetCommand : public cmCableCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmCableDefineSetCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string>& args);
/**
* This determines if the command gets propagated down
* to makefiles located in subdirectories.
*/
virtual bool IsInherited()
{ return true; }
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CABLE_DEFINE_SET";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Define a CABLE Set.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"CABLE_DEFINE_SET(name_of_set [[tag1]:]memeber1 [[tag2]:]member2 ...\n"
" [SOURCE_FILES source1 source2 ...]] )\n"
"Generates a Set definition in the CABLE configuration. The sets are\n"
"referenced in other CABLE commands by a '$' immediately followed by\n"
"the set name (ex. $SetName). If a the \"tag:\" syntax is not used,\n"
"an attempt is made to auto-generate a meaningful tag. If the\n"
"SOURCE_FILES keyword is given, all arguments after it refer to header\n"
"files to be included in any package referencing the set.\n";
}
cmTypeMacro(cmCableDefineSetCommand, cmCableCommand);
protected:
virtual const char* GetXmlTag() const { return "Set"; }
void WriteConfiguration() const;
bool AddElement(const std::string&);
bool GenerateTag(const std::string&, std::string&);
bool AddSourceFile(const std::string&);
private:
typedef std::pair<std::string, std::string> Element;
typedef std::vector<Element> Elements;
/**
* The name of the set.
*/
std::string m_SetName;
/**
* The elements to be defined in the set (before $ expansion).
*/
Elements m_Elements;
/**
* The source headers associated with this set.
*/
std::vector<std::string> m_SourceHeaders;
/**
* The instantiation sources associated with this set.
*/
std::vector<std::string> m_InstantiationSources;
};
#endif

View File

@ -1,74 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCableInstantiateClassCommand.h"
#include "cmCacheManager.h"
#include "cmRegularExpression.h"
/**
* Write the CABLE configuration code to define this InstantiationSet.
* This includes the "class" keyword to do class template instantiations.
*/
void cmCableInstantiateClassCommand::WriteConfiguration() const
{
std::ostream& os = m_CableData->GetOutputStream();
cmCableData::Indentation indent = m_CableData->GetIndentation();
cmRegularExpression needCdataBlock("[&<>]");
os << indent << "<InstantiationSet>" << std::endl;
for(Entries::const_iterator e = m_Entries.begin();
e != m_Entries.end(); ++e)
{
os << indent << " <Element>class ";
if(needCdataBlock.find(e->c_str()))
{
os << "<![CDATA[" << e->c_str() << "]]>";
}
else
{
os << e->c_str();
}
os << "</Element>" << std::endl;
}
os << indent << "</InstantiationSet>" << std::endl;
}

View File

@ -1,100 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCableInstantiateClassCommand_h
#define cmCableInstantiateClassCommand_h
#include "cmStandardIncludes.h"
#include "cmCablePackageEntryCommand.h"
/** \class cmCableInstantiateClassCommand
* \brief Define a command that generates a rule for explicit template
* instantiations of classes.
*
* cmCableInstantiateCommand is used to generate a rule in a CABLE
* configuration file to create explicit template instantiations of
* classes.
*/
class cmCableInstantiateClassCommand : public cmCablePackageEntryCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmCableInstantiateClassCommand;
}
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CABLE_INSTANTIATE_CLASS";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Define CABLE InstantiationSet of classes in a package.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"CABLE_INSTANTIATE_CLASS(package_name member1 member2 ...)\n"
"Generates an InstantiationSet in the CABLE configuration. It is\n"
"assumed that all members of the set are explicit instantiations of\n"
"template classes (not functions, operators, etc).";
}
virtual void WriteConfiguration() const;
cmTypeMacro(cmCableInstantiateClassCommand, cmCablePackageEntryCommand);
protected:
typedef cmCablePackageEntryCommand::Entries Entries;
};
#endif

View File

@ -1,73 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCableInstantiateCommand.h"
#include "cmCacheManager.h"
#include "cmRegularExpression.h"
/**
* Write the CABLE configuration code to define this InstantiationSet.
*/
void cmCableInstantiateCommand::WriteConfiguration() const
{
std::ostream& os = m_CableData->GetOutputStream();
cmCableData::Indentation indent = m_CableData->GetIndentation();
cmRegularExpression needCdataBlock("[&<>]");
os << indent << "<InstantiationSet>" << std::endl;
for(Entries::const_iterator e = m_Entries.begin();
e != m_Entries.end(); ++e)
{
os << indent << " <Element>";
if(needCdataBlock.find(e->c_str()))
{
os << "<![CDATA[" << e->c_str() << "]]>";
}
else
{
os << e->c_str();
}
os << "</Element>" << std::endl;
}
os << indent << "</InstantiationSet>" << std::endl;
}

View File

@ -1,99 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCableInstantiateCommand_h
#define cmCableInstantiateCommand_h
#include "cmStandardIncludes.h"
#include "cmCablePackageEntryCommand.h"
/** \class cmCableInstantiateCommand
* \brief Define a command that generates a rule for explicit template
* instantiations.
*
* cmCableInstantiateCommand is used to generate a rule in a CABLE
* configuration file to create explicit template instantiations.
*/
class cmCableInstantiateCommand : public cmCablePackageEntryCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmCableInstantiateCommand;
}
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CABLE_INSTANTIATE";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Define CABLE InstantiationSet in a package.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"CABLE_INSTANTIATE(member1 member2 ...)\n"
"Generates an InstantiationSet in the CABLE configuration. It is\n"
"assumed that all members of the set are explicit instantiations of\n"
"template non-classes (functions, operators, etc).";
}
virtual void WriteConfiguration() const;
cmTypeMacro(cmCableInstantiateCommand, cmCablePackageEntryCommand);
protected:
typedef cmCablePackageEntryCommand::Entries Entries;
};
#endif

View File

@ -1,80 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCableOpenNamespaceCommand.h"
#include "cmCacheManager.h"
// cmCableOpenNamespaceCommand
bool cmCableOpenNamespaceCommand::InitialPass(std::vector<std::string>& args)
{
if(args.size() != 1)
{
this->SetError("called with incorrect number of arguments");
return false;
}
// This command needs to access the Cable data.
this->SetupCableData();
// The argument is the namespace name.
m_NamespaceName = args[0];
// Write the configuration for this command.
this->WriteNamespaceHeader();
// Ask the cable data to open the namespace.
m_CableData->OpenNamespace(m_NamespaceName);
return true;
}
/**
* Generate a CABLE Namespace open tag.
*/
void cmCableOpenNamespaceCommand::WriteNamespaceHeader() const
{
std::ostream& os = m_CableData->GetOutputStream();
cmCableData::Indentation indent = m_CableData->GetIndentation();
os << indent << "<Namespace name=\"" << m_NamespaceName.c_str()
<< "\">" << std::endl;
m_CableData->Indent();
}

View File

@ -1,114 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCableOpenNamespaceCommand_h
#define cmCableOpenNamespaceCommand_h
#include "cmStandardIncludes.h"
#include "cmCableCommand.h"
/** \class cmCableOpenNamespaceCommand
* \brief Define a command that opens a CABLE Namespace.
*
* cmCableOpenNamespaceCommand is used to generate CABLE Namespace
* open tags in the configuration file.
*/
class cmCableOpenNamespaceCommand : public cmCableCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmCableOpenNamespaceCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string>& args);
/**
* This determines if the command gets propagated down
* to makefiles located in subdirectories.
*/
virtual bool IsInherited()
{return true;}
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CABLE_OPEN_NAMESPACE";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Open a CABLE Namespace";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"CABLE_OPEN_NAMESPACE(namespace_name)\n"
"Open the given namespace in the generated configuration file.\n"
"There must be a matching CABLE_CLOSE_NAMESPACE(namespace_name)\n"
"called with the same name.";
}
cmTypeMacro(cmCableOpenNamespaceCommand, cmCableCommand);
private:
void WriteNamespaceHeader() const;
private:
/**
* The name of the namespace to setup.
*/
std::string m_NamespaceName;
};
#endif

View File

@ -1,209 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCablePackageCommand.h"
#include "cmCacheManager.h"
#include "cmTarget.h"
cmCablePackageCommand::~cmCablePackageCommand()
{
// If we are the owner of the cmCableData, we must delete it here.
// For most cmCableCommands, the cmCableCommand destructor will take
// care of this. If this package happens to be the last one, and is
// the owner, then the destructor of cmCableData will call back to a method
// in this class after the package part of it has been freed!
if(m_CableData && m_CableData->OwnerIs(this))
{
delete m_CableData;
// Make sure our superclass's destructor doesn't try to delete the
// cmCableData too.
m_CableData = NULL;
}
}
// cmCablePackageCommand
bool cmCablePackageCommand::InitialPass(std::vector<std::string>& args)
{
if(args.size() != 2)
{
this->SetError("called with incorrect number of arguments");
return false;
}
// setup this once. Really this should probably be moved somewhere else
// at some point.
{
// We must add a custom rule to cause the cable_config.xml to be re-built
// when it is removed. Rebuilding it means re-running CMake.
std::string cMakeLists = m_Makefile->GetStartDirectory();
cMakeLists += "/";
cMakeLists += "CMakeLists.txt";
cMakeLists = cmSystemTools::EscapeSpaces(cMakeLists.c_str());
std::string command = "${CMAKE_COMMAND}";
std::string commandArgs = cMakeLists;
#if defined(_WIN32) && !defined(__CYGWIN__)
commandArgs += " -DSP";
#endif
commandArgs += " -H\"";
commandArgs += m_Makefile->GetHomeDirectory();
commandArgs += "\" -S\"";
commandArgs += m_Makefile->GetStartDirectory();
commandArgs += "\" -O\"";
commandArgs += m_Makefile->GetStartOutputDirectory();
commandArgs += "\" -B\"";
commandArgs += m_Makefile->GetHomeOutputDirectory();
commandArgs += "\"";
m_Makefile->ExpandVariablesInString(commandArgs);
m_Makefile->ExpandVariablesInString(command);
std::vector<std::string> depends;
m_Makefile->AddCustomCommand(cMakeLists.c_str(),
command.c_str(),
commandArgs.c_str(),
depends,
"cable_config.xml", args[1].c_str());
}
// This command needs to access the Cable data.
this->SetupCableData();
// The argument is the package name.
m_PackageName = args[0];
m_TargetName = args[1];
// Ask the cable data to begin the package. This may call another
// cmCablePackageCommand's WritePackageFooter(). This will call
// this cmCablePackageCommand's WritePackageHeader().
m_CableData->BeginPackage(this);
// Add custom rules to the makefile to generate this package's source
// files.
{
std::string command = "${CABLE}";
m_Makefile->ExpandVariablesInString(command);
std::vector<std::string> depends;
depends.push_back(command);
std::string commandArgs = " cable_config.xml";
std::vector<std::string> outputs;
outputs.push_back("Cxx/"+m_PackageName+"_cxx.cxx");
outputs.push_back("Cxx/"+m_PackageName+"_cxx.h");
// A rule for the package's source files.
m_Makefile->AddCustomCommand("cable_config.xml",
command.c_str(),
commandArgs.c_str(),
depends,
outputs, m_TargetName.c_str());
}
// Add custom rules to the makefile to generate this package's xml files.
{
std::string command = "${GCCXML}";
m_Makefile->ExpandVariablesInString(command);
// Only add the rule if GCC-XML is available.
if((command != "") && (command != "${GCCXML}"))
{
std::vector<std::string> depends;
depends.push_back(command);
std::string input = m_Makefile->GetStartOutputDirectory();
input = input + "/Cxx/"+m_PackageName+"_cxx.cxx";
std::string output = "Cxx/"+m_PackageName+"_cxx.xml";
command = "\""+command+"\" ${CXX_FLAGS} -fsyntax-only -fxml=" + output + " -c " + input;
std::vector<std::string> outputs;
outputs.push_back("Cxx/"+m_PackageName+"_cxx.xml");
// A rule for the package's source files.
m_Makefile->AddCustomCommand(input.c_str(),
command.c_str(),
"",
depends,
outputs, m_TargetName.c_str());
}
}
// add the source list to the target
m_Makefile->GetTargets()[m_TargetName.c_str()].GetSourceLists().push_back(m_PackageName);
return true;
}
void cmCablePackageCommand::FinalPass()
{
// Add a rule to build the generated package.
std::string fileName = "Cxx/"+m_PackageName+"_cxx";
std::string filePath = m_Makefile->GetStartOutputDirectory();
cmSourceFile file;
file.SetIsAnAbstractClass(false);
file.SetIsAHeaderFileOnly(false);
file.SetName(fileName.c_str(), filePath.c_str(), "cxx", false);
m_Makefile->AddSource(file, m_PackageName.c_str());
}
/**
* Write a CABLE package header.
*/
void cmCablePackageCommand::WritePackageHeader() const
{
std::ostream& os = m_CableData->GetOutputStream();
cmCableData::Indentation indent = m_CableData->GetIndentation();
os << indent << "<Package name=\"" << m_PackageName.c_str() << "\">"
<< std::endl;
m_CableData->Indent();
}
/**
* Write a CABLE package footer.
*/
void cmCablePackageCommand::WritePackageFooter() const
{
m_CableData->Unindent();
std::ostream& os = m_CableData->GetOutputStream();
cmCableData::Indentation indent = m_CableData->GetIndentation();
os << indent << "</Package> <!-- \"" << m_PackageName.c_str() << "\" -->"
<< std::endl;
}

View File

@ -1,120 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCablePackageCommand_h
#define cmCablePackageCommand_h
#include "cmStandardIncludes.h"
#include "cmCableCommand.h"
/** \class cmCablePackageCommand
* \brief Define a command that begins a CABLE Package definition.
*
* cmCablePackageCommand is used to generate a new CABLE Package.
* All subsequent commands that require a package will refer to that
* setup by this command, until another package is started.
*/
class cmCablePackageCommand : public cmCableCommand
{
public:
cmCablePackageCommand() {}
virtual ~cmCablePackageCommand();
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmCablePackageCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string>& args);
/**
* This is called at the end after all the information
* specified by the command is accumulated. Most commands do
* not implement this method. At this point, reading and
* writing to the cache can be done.
*/
virtual void FinalPass();
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CABLE_PACKAGE";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Begin a package definition.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"CABLE_PACKAGE(package_name target)\n"
"Close current package (if any), and open a new package definition.";
}
void WritePackageHeader() const;
void WritePackageFooter() const;
const char *GetPackageName() {return m_PackageName.c_str();}
cmTypeMacro(cmCablePackageCommand, cmCableCommand);
private:
/**
* The name of the package.
*/
std::string m_PackageName;
std::string m_TargetName;
};
#endif

View File

@ -1,67 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCablePackageEntryCommand.h"
#include "cmCacheManager.h"
// cmCablePackageEntryCommand
bool cmCablePackageEntryCommand::InitialPass(std::vector<std::string>& args)
{
if(args.size() < 1)
{
this->SetError("called with incorrect number of arguments");
return false;
}
// This command instance needs to use the cmCableData instance.
this->SetupCableData();
// The arguments are the entries to the Pacakge.
for(std::vector<std::string>::const_iterator arg = args.begin();
arg != args.end(); ++arg)
{
m_Entries.push_back(*arg);
}
// Write this command's configuration.
this->WriteConfiguration();
return true;
}

View File

@ -1,82 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCablePackageEntryCommand_h
#define cmCablePackageEntryCommand_h
#include "cmStandardIncludes.h"
#include "cmCableCommand.h"
/** \class cmCablePackageEntryCommand
* \brief Superclass to all CABLE Package entry generation commands.
*
* cmCablePackageEntryCommand implements the InitialPass method of a cmCommand
* to save the arguments as a vector of entries to a CABLE Package. The
* InitialPass then calls the virtual WriteConfiguration() so that the subclass
* can generate the configuration code for its particular type of Package
* entry.
*/
class cmCablePackageEntryCommand : public cmCableCommand
{
public:
cmCablePackageEntryCommand() {}
virtual ~cmCablePackageEntryCommand() {}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string>& args);
cmTypeMacro(cmCablePackageEntryCommand, cmCableCommand);
virtual void WriteConfiguration() const =0;
protected:
typedef std::vector<std::string> Entries;
/**
* The package entries.
*/
Entries m_Entries;
};
#endif

View File

@ -1,140 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCableSourceFilesCommand.h"
#include "cmCacheManager.h"
void cmCableSourceFilesCommand::FinalPass()
{
// Get the index of the current package's cmClassFile.
// If it doesn't exist, ignore this command.
cmCablePackageCommand *cablePackage = m_CableData->GetCurrentPackage();
std::string fileName = "Cxx/";
fileName += cablePackage->GetPackageName();
fileName += "_cxx";
cmSourceFile *ci = m_Makefile->GetSource(cablePackage->GetPackageName(),
fileName.c_str());
if(ci == 0)
{ return; }
// The package's file has not yet been generated yet. The dependency
// finder will need hints. Add one for each source file.
for(Entries::const_iterator f = m_Entries.begin();
f != m_Entries.end(); ++f)
{
std::string header = *f+".h";
ci->GetDepends().push_back(header);
}
}
/**
* Write the CABLE configuration code to indicate header dependencies for
* a package.
*/
void cmCableSourceFilesCommand::WriteConfiguration() const
{
std::ostream& os = m_CableData->GetOutputStream();
cmCableData::Indentation indent = m_CableData->GetIndentation();
os << indent << "<Headers>" << std::endl;
for(Entries::const_iterator f = m_Entries.begin();
f != m_Entries.end(); ++f)
{
// Look for the normal include file.
std::string header = *f+".h";
if(this->SourceFileExists(header))
{
os << indent << " <File name=\"" << header.c_str() << "\"/>"
<< std::endl;
}
else
{
cmSystemTools::Error("Unable to find source file ", header.c_str());
}
// Look for an instantiation file.
std::string txx = *f+".txx";
if(this->SourceFileExists(txx))
{
os << indent << " <File name=\"" << txx.c_str()
<< "\" purpose=\"instantiate\"/>" << std::endl;
}
}
os << indent << "</Headers>" << std::endl;
}
/**
* Search the include path for the specified file.
*/
bool cmCableSourceFilesCommand::SourceFileExists(const std::string& name) const
{
// We must locate the file in the include path so that we can detect
// its extension, and whether there is more than one to find.
std::string file = name;
m_Makefile->ExpandVariablesInString(file);
// See if the file just exists here. The compiler's search path will
// locate it.
if(cmSystemTools::FileExists(file.c_str()))
{
return true;
}
// We must look for the file in the include search path.
const std::vector<std::string>& includeDirectories =
m_Makefile->GetIncludeDirectories();
for(std::vector<std::string>::const_iterator dir = includeDirectories.begin();
dir != includeDirectories.end(); ++dir)
{
std::string path = *dir + "/";
m_Makefile->ExpandVariablesInString(path);
if(cmSystemTools::FileExists((path+file).c_str()))
{
return true;
}
}
// We couldn't locate the source file.
return false;
}

View File

@ -1,105 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCableSourceFilesCommand_h
#define cmCableSourceFilesCommand_h
#include "cmStandardIncludes.h"
#include "cmCablePackageEntryCommand.h"
/** \class cmCableSourceFilesCommand
* \brief Define a command that generates a rule for a CABLE Headers block.
*
* cmCableSourceFilesCommand is used to generate a rule in a CABLE
* configuration file to setup a Package's include files.
*/
class cmCableSourceFilesCommand : public cmCablePackageEntryCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmCableSourceFilesCommand;
}
/**
* This is called at the end after all the information
* specified by the command is accumulated. Most commands do
* not implement this method. At this point, reading and
* writing to the cache can be done.
*/
virtual void FinalPass();
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CABLE_SOURCE_FILES";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Define CABLE header file dependencies in a package.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"CABLE_SOURCE_FILES(file1 file2 ...)"
"Generates a Package's Headers block in the CABLE configuration.";
}
virtual void WriteConfiguration() const;
bool SourceFileExists(const std::string&) const;
cmTypeMacro(cmCableSourceFilesCommand, cmCableCommand);
protected:
typedef cmCablePackageEntryCommand::Entries Entries;
};
#endif

View File

@ -1,44 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmCableWrapCommand.h"
#include "cmCacheManager.h"
// Don't need to implement anything here.

View File

@ -1,100 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmCableWrapCommand_h
#define cmCableWrapCommand_h
#include "cmStandardIncludes.h"
#include "cmCableDefineSetCommand.h"
/** \class cmCableWrapCommand
* \brief Define a command that generates a rule for CABLE-generated wrappers.
*
* cmCableWrapCommand is used to generate a rule in a CABLE
* configuration file to create type wrappers.
*/
class cmCableWrapCommand : public cmCableDefineSetCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmCableWrapCommand;
}
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CABLE_WRAP";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Define CABLE WrapperSet in a package.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"CABLE_WRAP(name_of_set [[tag1]:]memeber1 [[tag2]:]member2 ...\n"
" [SOURCE_FILES source1 source2 ...]] )\n"
"Generates a WrapperSet definition in the CABLE configuration.\n"
"If a the \"tag:\" syntax is not used, an attempt is made to\n"
"auto-generate a meaningful tag. If the SOURCE_FILES keyword is\n"
"given, all arguments after it refer to header files to be included\n"
"in the package in which the set is defined.\n";
}
cmTypeMacro(cmCableWrapCommand, cmCableDefineSetCommand);
protected:
virtual const char* GetXmlTag() const { return "WrapperSet"; }
};
#endif

View File

@ -14,18 +14,7 @@
#include "cmBuildNameCommand.cxx"
#include "cmBuildSharedLibrariesCommand.cxx"
#include "cmCableClassSetCommand.cxx"
#include "cmCableCloseNamespaceCommand.cxx"
#include "cmCableCommand.cxx"
#include "cmCableData.cxx"
#include "cmCableDefineSetCommand.cxx"
#include "cmCableInstantiateClassCommand.cxx"
#include "cmCableInstantiateCommand.cxx"
#include "cmCableOpenNamespaceCommand.cxx"
#include "cmCablePackageCommand.cxx"
#include "cmCablePackageEntryCommand.cxx"
#include "cmCableSourceFilesCommand.cxx"
#include "cmCableWrapTclCommand.cxx"
#include "cmCableWrapCommand.cxx"
#include "cmConfigureFileCommand.cxx"
#include "cmElseCommand.cxx"
#include "cmEnableTestingCommand.cxx"
@ -75,15 +64,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmBuildNameCommand);
commands.push_back(new cmBuildSharedLibrariesCommand);
commands.push_back(new cmCableClassSetCommand);
commands.push_back(new cmCableCloseNamespaceCommand);
commands.push_back(new cmCableDefineSetCommand);
commands.push_back(new cmCableInstantiateCommand);
commands.push_back(new cmCableInstantiateClassCommand);
commands.push_back(new cmCableOpenNamespaceCommand);
commands.push_back(new cmCablePackageCommand);
commands.push_back(new cmCableSourceFilesCommand);
commands.push_back(new cmCableWrapTclCommand);
commands.push_back(new cmCableWrapCommand);
commands.push_back(new cmConfigureFileCommand);
commands.push_back(new cmElseCommand);
commands.push_back(new cmEnableTestingCommand);