Commit c56cd6a7 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - new properties class - base structure

parent b64d5b77
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <string>
#include "WProperty2.h"
WProperty2::WProperty2( std::string name, std::string description ):
m_name( name ),
m_description( description )
{
// initialize members
}
WProperty2::~WProperty2()
{
// clean up
}
std::string WProperty2::getName() const
{
return m_name;
}
std::string WProperty2::getDescription() const
{
return m_description;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WPROPERTY2_H
#define WPROPERTY2_H
#include <string>
#include "WPropertyTypes.h"
/**
* Class managing a single named property.
*/
class WProperty2
{
public:
/**
* Create an empty instance just containing a name.
*
* \param name the property name
* \param description the property description
*/
WProperty2( std::string name, std::string description );
/**
* Destructor.
*/
virtual ~WProperty2();
/**
* Get the name of the property.
*
* \return the name.
*/
std::string getName() const;
/**
* Get the description of the property.
*
* \return the description.
*/
std::string getDescription() const;
/**
* Returns the actual type of the property. This is needed to identify all subclassed types.
*
* \return the type.
*/
virtual PROPERTY_TYPE getType() const = 0;
protected:
/**
* Name of the property.
*/
std::string m_name;
/**
* Description of the property.
*/
std::string m_description;
private:
};
#endif // WPROPERTY2_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WPROPERTYTYPES_H
#define WPROPERTYTYPES_H
/**
* Enum of all possible types, that can be used with WProperty.
*/
typedef enum
{
UNKNOWN, // type not know
INT, // integer value
DOUBLE, // floating point value
BOOL, // boolean
STRING // a string
}
PROPERTY_TYPE;
#endif // WPROPERTYTYPES_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WPropertyVariable.h"
void hallo()
{
WPropertyVariable< bool > p( "ich", "du", false );
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WPROPERTYVARIABLE_H
#define WPROPERTYVARIABLE_H
#include <stdint.h>
#include <string>
#include <typeinfo>
#include "WProperty2.h"
/**
* A named property class with a concrete type.
*/
template< typename T >
class WPropertyVariable: public WProperty2
{
public:
/**
* Create an empty instance just containing a name.
*
* \param name the property name
* \param description the property description
* \param initial the initial value
*/
WPropertyVariable( std::string name, std::string description, const T& initial ):
WProperty2( name, description )
{
// initialize everything
}
/**
* Destructor.
*/
virtual ~WPropertyVariable()
{
// clean up
}
T& get() const
{
return m_value;
}
void set( T& val )
{
m_value = val;
}
virtual PROPERTY_TYPE getType() const
{
if ( typeid( T ) == typeid( int ) )
return INT;
else
return INT;
}
protected:
/**
* The actual variable handled by this property.
*/
T m_value;
private:
};
#endif // WPROPERTYVARIABLE_H
......@@ -131,7 +131,6 @@ void WMDirectVolumeRendering::connectors()
void WMDirectVolumeRendering::properties()
{
m_properties->addBool( "textureChanged", false, true );
m_properties->addBool( "active", true, true )->connect( boost::bind( &WMDirectVolumeRendering::slotPropertyChanged, this, _1 ) );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment