[cmake-commits] martink committed cmProperty.cxx NONE 1.1 cmProperty.h NONE 1.1 cmPropertyDefinition.cxx NONE 1.1 cmPropertyDefinition.h NONE 1.1 cmPropertyDefinitionMap.cxx NONE 1.1 cmPropertyDefinitionMap.h NONE 1.1 cmPropertyMap.cxx NONE 1.1 cmPropertyMap.h NONE 1.1

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Dec 1 13:35:05 EST 2006


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv14866

Added Files:
	cmProperty.cxx cmProperty.h cmPropertyDefinition.cxx 
	cmPropertyDefinition.h cmPropertyDefinitionMap.cxx 
	cmPropertyDefinitionMap.h cmPropertyMap.cxx cmPropertyMap.h 
Log Message:
ENH: getting some of the property changed chewcked into CVS at least


--- NEW FILE: cmPropertyDefinition.cxx ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmPropertyDefinition.cxx,v $
  Language:  C++
  Date:      $Date: 2006/12/01 18:35:03 $
  Version:   $Revision: 1.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "cmPropertyDefinition.h"
#include "cmSystemTools.h"

cmDocumentationEntry cmPropertyDefinition::GetDocumentation() const
{
  cmDocumentationEntry e;
  e.name = this->LongName.c_str();
  e.brief = 
    this->ShortDescription.size() ? this->ShortDescription.c_str() : 0;
  e.full = this->FullDescription.size() ? this->FullDescription.c_str() : 0;
  return e;
}

void cmPropertyDefinition
::DefineProperty(const char *name, cmProperty::ScopeType scope,
                 const char *ShortDescription,
                 const char *FullDescription,
                 bool chain)
{
  this->Name = name;
  this->Scope = scope;
  this->Chained = chain;
  if (ShortDescription)
    {
    this->ShortDescription = ShortDescription;
    }
  if (FullDescription)
    {
    this->FullDescription = FullDescription;
    }
  this->LongName = this->Name;
  switch (this->Scope)
    {
    case cmProperty::TARGET: this->LongName += " on a target";
      break;
    case cmProperty::SOURCE_FILE: this->LongName += " on a source file";
      break;
    case cmProperty::DIRECTORY: this->LongName += " on a directory";
      break;
    }
}


--- NEW FILE: cmPropertyMap.h ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmPropertyMap.h,v $
  Language:  C++
  Date:      $Date: 2006/12/01 18:35:03 $
  Version:   $Revision: 1.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef cmPropertyMap_h
#define cmPropertyMap_h

#include "cmProperty.h"

class cmake;

class cmPropertyMap : public std::map<cmStdString,cmProperty>
{
public:
  cmProperty *GetOrCreateProperty(const char *name);

  void SetProperty(const char *name, const char *value, 
                   cmProperty::ScopeType scope);

  const char *GetPropertyValue(const char *name, 
                               cmProperty::ScopeType scope,
                               bool &chain) const;

  void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; };

  cmPropertyMap() { this->CMakeInstance = 0;};

private:
  cmake *CMakeInstance;
};

#endif


--- NEW FILE: cmProperty.cxx ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmProperty.cxx,v $
  Language:  C++
  Date:      $Date: 2006/12/01 18:35:02 $
  Version:   $Revision: 1.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "cmProperty.h"
#include "cmSystemTools.h"

void cmProperty::Set(const char *name, const char *value)
{
  this->Name = name;
  this->Value = value;
  this->ValueHasBeenSet = true;
}

const char *cmProperty::GetValue() const
{
  if (this->ValueHasBeenSet)
    {
    return this->Value.c_str();
    }
  return 0;
}

--- NEW FILE: cmPropertyDefinition.h ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmPropertyDefinition.h,v $
  Language:  C++
  Date:      $Date: 2006/12/01 18:35:03 $
  Version:   $Revision: 1.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef cmPropertyDefinition_h
#define cmPropertyDefinition_h

#include "cmProperty.h"

class cmPropertyDefinition 
{
public:
  // Define this property
  void DefineProperty(const char *name, cmProperty::ScopeType scope,
                      const char *ShortDescription,
                      const char *FullDescription, 
                      bool chained);

  // get the documentation string
  cmDocumentationEntry GetDocumentation() const;

  // basic constructor 
  cmPropertyDefinition() { this->Chained = false; };

  // is it chained?
  bool IsChained() {return this->Chained; };

protected:
  std::string Name;
  std::string LongName;
  std::string ShortDescription;
  std::string FullDescription;
  cmProperty::ScopeType Scope; 
  bool Chained;
};

#endif

--- NEW FILE: cmProperty.h ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmProperty.h,v $
  Language:  C++
  Date:      $Date: 2006/12/01 18:35:03 $
  Version:   $Revision: 1.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef cmProperty_h
#define cmProperty_h

#include "cmStandardIncludes.h"

class cmProperty 
{
public:
  enum ScopeType { TARGET, SOURCE_FILE, DIRECTORY, GLOBAL, TEST };

  // set this property
  void Set(const char *name, const char *value);

  // get the value
  const char *GetValue() const;

  // construct with the value not set
  cmProperty() { this->ValueHasBeenSet = false; };

protected:
  std::string Name;
  std::string Value;
  bool ValueHasBeenSet;
};

#endif

--- NEW FILE: cmPropertyDefinitionMap.cxx ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmPropertyDefinitionMap.cxx,v $
  Language:  C++
  Date:      $Date: 2006/12/01 18:35:03 $
  Version:   $Revision: 1.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "cmPropertyDefinitionMap.h"
#include "cmSystemTools.h"


void cmPropertyDefinitionMap
::DefineProperty(const char *name, cmProperty::ScopeType scope,
                 const char *ShortDescription,
                 const char *FullDescription,
                 bool chain)
{
  if (!name)
    {
    return;
    }

  cmPropertyDefinitionMap::iterator it = this->find(name);
  cmPropertyDefinition *prop;
  if (it == this->end())
    {
    prop = &(*this)[name];
    prop->DefineProperty(name,scope,ShortDescription, FullDescription, chain);
    }
}

void cmPropertyDefinitionMap
::GetPropertiesDocumentation(std::vector<cmDocumentationEntry>& v) const
{
  for(cmPropertyDefinitionMap::const_iterator j = this->begin();
      j != this->end(); ++j)
    {
    cmDocumentationEntry e = j->second.GetDocumentation();
    if (e.brief)
      {
      v.push_back(e);
      }
    }
}

bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name)
{
  if (!name)
    {
    return false;
    }

  cmPropertyDefinitionMap::iterator it = this->find(name);
  if (it == this->end())
    {
    return false;
    }

  return true;
}

bool cmPropertyDefinitionMap::IsPropertyChained(const char *name)
{
  if (!name)
    {
    return false;
    }

  cmPropertyDefinitionMap::iterator it = this->find(name);
  if (it == this->end())
    {
    return false;
    }

  return it->second.IsChained();
}

--- NEW FILE: cmPropertyDefinitionMap.h ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmPropertyDefinitionMap.h,v $
  Language:  C++
  Date:      $Date: 2006/12/01 18:35:03 $
  Version:   $Revision: 1.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef cmPropertyDefinitionMap_h
#define cmPropertyDefinitionMap_h

#include "cmPropertyDefinition.h"

class cmPropertyDefinitionMap : public std::map<cmStdString,cmPropertyDefinition>
{
public:
  // define the property
  void DefineProperty(const char *name, cmProperty::ScopeType scope,
                      const char *ShortDescription,
                      const char *FullDescription,
                      bool chain);

  // has a named property been defined
  bool IsPropertyDefined(const char *name);

  // is a named property set to chain
  bool IsPropertyChained(const char *name);

  void GetPropertiesDocumentation(std::vector<cmDocumentationEntry>& v) const;
};

#endif


--- NEW FILE: cmPropertyMap.cxx ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmPropertyMap.cxx,v $
  Language:  C++
  Date:      $Date: 2006/12/01 18:35:03 $
  Version:   $Revision: 1.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "cmPropertyMap.h"
#include "cmSystemTools.h"
#include "cmake.h"

cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
{
  cmPropertyMap::iterator it = this->find(name);
  cmProperty *prop;
  if (it == this->end())
    {
    prop = &(*this)[name];
    }
  else
    {
    prop = &(it->second);
    }
  return prop;
}

void cmPropertyMap::SetProperty(const char *name, const char *value,
                                cmProperty::ScopeType scope)
{
  if (!name)
    {
    return;
    }

#if 0
  if (!this->CMakeInstance)
    {
    cmSystemTools::Error("CMakeInstance not set on a property map!"); 
    abort();
    }
  else if (!this->CMakeInstance->IsPropertyDefined(name,scope))
    {
    // is a property being queried without being defined first? If so then
    // report it as we probably need to document it
    std::string msg = "Property ";
    msg += name;
    msg += " set yet undefined on ";
    switch (scope)
      {
      case cmProperty::TARGET: 
        msg += "target.";
        break;
      case cmProperty::SOURCE_FILE:
        msg += "source file.";
        break;
      case cmProperty::DIRECTORY:
        msg += "directory.";
        break;
      case cmProperty::TEST:
        msg += "test.";
        break;
      default:
        msg += "unknown.";
        break;
      }
    cmSystemTools::Error(msg.c_str()); 
    }
#endif

  cmProperty *prop = this->GetOrCreateProperty(name);
  prop->Set(name,value);
}

const char *cmPropertyMap
::GetPropertyValue(const char *name, 
                   cmProperty::ScopeType scope, 
                   bool &chain) const
{
  chain = false;
  if (!name)
    {
    return 0;
    }

  // has the property been defined?
#if 0
  if (!this->CMakeInstance)
    {
    cmSystemTools::Error("CMakeInstance not set on a property map!"); 
    abort();
    }
  else if (!this->CMakeInstance->IsPropertyDefined(name,scope))
    {
    // is a property being queried without being defined first? If so then
    // report it as we probably need to document it
    std::string msg = "Property ";
    msg += name;
    msg += " queried yet undefined on ";
    switch (scope)
      {
      case cmProperty::TARGET: 
        msg += "target.";
        break;
      case cmProperty::SOURCE_FILE:
        msg += "source file.";
        break;
      case cmProperty::DIRECTORY:
        msg += "directory.";
        break;
      case cmProperty::TEST:
        msg += "test.";
        break;
      default:
        msg += "unknown.";
        break;
      }
    cmSystemTools::Error(msg.c_str()); 
    }
#endif

  cmPropertyMap::const_iterator it = this->find(name);
  if (it == this->end())
    {
    // should we chain up?
    chain = this->CMakeInstance->IsPropertyChained(name,scope);
    return 0;
    }

  return it->second.GetValue();
}




More information about the Cmake-commits mailing list