* ./hurricane/src/hurricane/Name.h

./hurricane/src/hurricane/Name.cpp :
   - New feature : Allocate a static member "_emptyName" which could be used
       to manage effeciently empty Name (for functions returning reference on
       Name, by example).

 * ./hurricane/src/hurricane/Property.h
   ./hurricane/src/hurricane/Property.cpp :
   - Change : Now StandardPrivateProperty & StandardSharedProperty templates
       systematically uses static member for the property's name. This leads
       to suppress the "const Name&" argument when creating a property, and
       the _name member is no longer present in each object instance.
   - Change : Property must now be created/get through static methods :
               StandardPrivateProperty<Value>::get ( DBo* );
               StandardPrivateProperty<Value>::create ( DBo* );
               StandardPrivateProperty<Value>::create ( DBo*, const Value& );
       Note that, as before, the Value type must provide a default constructor
       and a copy constructor.

  * ./hurricane/src/hviewer/DisplayStyle.cpp :
    Bug : early Graphics::enable() no longer makes application crash.
This commit is contained in:
Jean-Paul Chaput 2008-10-04 15:44:15 +00:00
parent 8fe480ea30
commit e32a20b23f
13 changed files with 995 additions and 814 deletions

View File

@ -1,166 +1,166 @@
// ****************************************************************************************************
// File: DBo.cpp
// Authors: R. Escassut
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************
// -*- C++ -*-
//
// This file is part of the Hurricane Software.
// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./DBo.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/DBo.h"
#include "hurricane/Property.h"
#include "hurricane/Quark.h"
#include "hurricane/Error.h"
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::DBo".
// ****************************************************************************************************
// DBo implementation
// ****************************************************************************************************
DBo::DBo()
// *******
: _propertySet()
{
}
DBo::DBo (): _propertySet()
{ }
DBo::~DBo()
// ********
{
}
void DBo::destroy()
// ***************
{
// trace << "entering DBo::destroy: " << this << endl;
// trace_in();
DBo::~DBo ()
{ }
void DBo::_postCreate ()
{ }
void DBo::_preDestroy ()
{
clearProperties ();
}
void DBo::destroy ()
{
_preDestroy();
delete this;
}
// trace << "exiting DBo::destroy:" << endl;
// trace_out();
}
Property* DBo::getProperty(const Name& name) const
// ***********************************************
{
Property* DBo::getProperty ( const Name& name ) const
{
PropertySet::const_iterator iterator = _propertySet.begin();
while (iterator != _propertySet.end()) {
Property* property = *iterator;
if (property->getName() == name) return property;
++iterator;
while ( iterator != _propertySet.end() ) {
Property* property = *iterator;
if (property->getName() == name) return property;
++iterator;
}
return NULL;
}
}
void DBo::put(Property* property)
// ******************************
{
if (!property)
throw Error("Can't put property : null property");
Property* oldProperty = getProperty(property->getName());
if (property != oldProperty) {
if (oldProperty) {
_propertySet.erase(oldProperty);
oldProperty->onReleasedBy(this);
}
_propertySet.insert(property);
property->onCapturedBy(this);
Properties DBo::getProperties () const
{
return getCollection(_propertySet);
}
void DBo::put ( Property* property )
{
if ( !property )
throw Error("DBo::put(): Can't put property : NULL property.");
Property* oldProperty = getProperty ( property->getName() );
if ( property != oldProperty ) {
if ( oldProperty ) {
_propertySet.erase ( oldProperty );
oldProperty->onReleasedBy ( this );
}
_propertySet.insert ( property );
property->onCapturedBy ( this );
}
}
}
void DBo::remove(Property* property)
// *********************************
{
if (!property)
throw Error("Can't remove property : null property");
if (_propertySet.find(property) != _propertySet.end()) {
_propertySet.erase(property);
property->onReleasedBy(this);
if (dynamic_cast<Quark*>(this) && _propertySet.empty()) destroy();
void DBo::remove ( Property* property )
{
if ( !property )
throw Error("DBo::remove(): Can't remove property : NULL property.");
if ( _propertySet.find(property) != _propertySet.end() ) {
_propertySet.erase ( property );
property->onReleasedBy ( this );
if ( dynamic_cast<Quark*>(this) && _propertySet.empty() )
destroy();
}
}
}
void DBo::removeProperty(const Name& name)
// ***************************************
{
Property* property = getProperty(name);
if (property) {
_propertySet.erase(property);
property->onReleasedBy(this);
if (dynamic_cast<Quark*>(this) && _propertySet.empty()) destroy();
void DBo::removeProperty ( const Name& name )
{
Property* property = getProperty ( name );
if ( property ) {
_propertySet.erase ( property );
property->onReleasedBy ( this );
if ( dynamic_cast<Quark*>(this) && _propertySet.empty() )
destroy();
}
}
}
void DBo::clearProperties()
// ************************
{
// trace << "entering DBo::ClearProperties: " << this << endl;
// trace_in();
while (!_propertySet.empty()) {
Property* property = *_propertySet.begin();
// trace << property << endl;
_propertySet.erase(property);
property->onReleasedBy(this);
void DBo::_onDestroyed ( Property* property )
{
if ( property && ( _propertySet.find(property) != _propertySet.end() ) ) {
_propertySet.erase ( property );
if ( dynamic_cast<Quark*>(this) && _propertySet.empty() )
destroy();
}
// trace << "exiting DBo::ClearProperties:" << endl;
// trace_out();
}
void DBo::_postCreate()
// ********************
{
}
void DBo::_preDestroy()
// *******************
{
// trace << "entering DBo::_Predestroy: " << this << endl;
// trace_in();
clearProperties();
}
// trace << "exiting DBo::_Predestroy:" << endl;
// trace_out();
}
void DBo::clearProperties ()
{
while ( !_propertySet.empty() ) {
Property* property = *_propertySet.begin();
_propertySet.erase ( property );
property->onReleasedBy ( this );
}
}
string DBo::_getTypeName () const
// ******************************
{
return "DBo";
}
string DBo::_getString() const
// ***************************
{
string DBo::_getTypeName () const
{
return "DBo";
}
string DBo::_getString () const
{
return "<" + _getTypeName() + ">";
}
}
Record* DBo::_getRecord() const
// **********************
{
Record* record = new Record(getString(this));
record->add(getSlot("Properties", &_propertySet));
return record;
}
void DBo::_onDestroyed(Property* property)
// *************************************
{
if (property && (_propertySet.find(property) != _propertySet.end())) {
_propertySet.erase(property);
if (dynamic_cast<Quark*>(this) && _propertySet.empty()) destroy();
}
}
Record* DBo::_getRecord () const
{
Record* record = new Record ( getString(this) );
record->add ( getSlot("Properties", &_propertySet) );
return record;
}
} // End of Hurricane namespace.
// ****************************************************************************************************
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************

View File

@ -39,21 +39,19 @@ namespace Hurricane {
: Exception()
, _reason(reason)
, _code(0)
{
}
{ }
Error::Error ( int code, const string& reason )
: Exception()
, _reason(reason)
, _code(code)
{
}
{ }
Error::Error ( const char* format, ... )
: Exception()
, _reason("")
, _reason()
, _code(0)
{
static char formatted [ 8192 ];
@ -69,7 +67,7 @@ namespace Hurricane {
Error::Error ( int code, const char* format, ... )
: Exception()
, _reason("")
, _reason()
, _code(code)
{
static char formatted [ 8192 ];
@ -95,7 +93,7 @@ namespace Hurricane {
{ return _TName("Error"); }
string Error::_getString() const
string Error::_getString () const
{
if ( !_code )
return "[ERROR] " + _reason;

View File

@ -15,6 +15,10 @@ namespace Hurricane {
// Name implementation
// ****************************************************************************************************
const Name Name::_emptyName;
Name::Name()
// *********
: _sharedName(NULL)

View File

@ -1,173 +1,192 @@
// ****************************************************************************************************
// File: Property.cpp
// Authors: R. Escassut
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************
#include "hurricane/Property.h"
#include "hurricane/DBo.h"
#include "hurricane/Error.h"
// -*- C++ -*-
//
// This file is part of the Hurricane Software.
// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./Property.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/Property.h"
#include "hurricane/DBo.h"
#include "hurricane/Error.h"
namespace Hurricane {
// Error messages.
const char* propertyTypeNameError =
"Property<%s>::get():\n Discrepency between type and property name on %s.\n";
// ****************************************************************************************************
// Property implementation
// ****************************************************************************************************
Property::Property()
// *****************
{
}
// -------------------------------------------------------------------
// Class : "Hurricane::Property".
Property::~Property()
// ******************
{
}
void Property::destroy()
// ********************
{
Name Property::_baseName = "Property";
Name Property::staticGetName ()
{
return _baseName;
}
Property::Property ()
{ }
Property::~Property ()
{ }
void Property::destroy ()
{
_preDestroy();
delete this;
}
}
string Property::_getString() const
// ********************************
{
string Property::_getString () const
{
string s = "<" + _getTypeName() + ">";
s.insert(s.length() - 1, " " + getString(getName()));
return s;
}
}
Record* Property::_getRecord() const
// ***************************
{
Record* Property::_getRecord () const
{
return new Record(getString(this));
}
}
// -------------------------------------------------------------------
// Class : "Hurricane::PrivateProperty".
// ****************************************************************************************************
// PrivateProperty implementation
// ****************************************************************************************************
PrivateProperty::PrivateProperty()
// *******************************
: Inherit(),
_owner(NULL)
{
}
PrivateProperty::PrivateProperty ()
: Property()
, _owner(NULL)
{ }
void PrivateProperty::_preDestroy()
// *******************************
{
Inherit::_preDestroy();
if (_owner) _owner->_onDestroyed(this);
}
void PrivateProperty::_preDestroy ()
{
Property::_preDestroy();
void PrivateProperty::onCapturedBy(DBo* owner)
// *******************************************
{
if ( _owner ) _owner->_onDestroyed(this);
}
void PrivateProperty::onCapturedBy ( DBo* owner )
{
_owner = owner;
}
}
void PrivateProperty::onReleasedBy(DBo* owner)
// *******************************************
{
if (_owner == owner) onNotOwned();
}
void PrivateProperty::onNotOwned()
// *******************************
{
void PrivateProperty::onReleasedBy ( DBo* owner )
{
if ( _owner == owner ) onNotOwned();
}
void PrivateProperty::onNotOwned ()
{
destroy();
}
}
string PrivateProperty::_getString() const
// ***************************************
{
return Inherit::_getString();
}
Record* PrivateProperty::_getRecord() const
// **********************************
{
Record* record = Inherit::_getRecord();
string PrivateProperty::_getString () const
{
return Property::_getString ();
}
Record* PrivateProperty::_getRecord () const
{
Record* record = Property::_getRecord();
if (record) {
record->add(getSlot("Owner", _owner));
record->add(getSlot("Owner", _owner));
}
return record;
}
}
// -------------------------------------------------------------------
// Class : "Hurricane::SharedProperty".
// ****************************************************************************************************
// SharedProperty implementation
// ****************************************************************************************************
SharedProperty::SharedProperty()
// *****************************
: Inherit(),
_ownerSet()
{
}
SharedProperty::SharedProperty ()
: Property()
, _ownerSet()
{ }
void SharedProperty::_preDestroy()
// ******************************
{
Inherit::_preDestroy();
void SharedProperty::_preDestroy ()
{
Property::_preDestroy();
while (!_ownerSet.empty()) {
DBo* owner = *_ownerSet.begin();
_ownerSet.erase(owner);
owner->_onDestroyed(this);
DBo* owner = *_ownerSet.begin();
_ownerSet.erase(owner);
owner->_onDestroyed(this);
}
}
}
void SharedProperty::onCapturedBy(DBo* owner)
// ******************************************
{
void SharedProperty::onCapturedBy ( DBo* owner )
{
_ownerSet.insert(owner);
}
}
void SharedProperty::onReleasedBy(DBo* owner)
// ******************************************
{
void SharedProperty::onReleasedBy ( DBo* owner )
{
_ownerSet.erase(owner);
if (_ownerSet.empty()) onNotOwned();
}
}
void SharedProperty::onNotOwned()
// ******************************
{
void SharedProperty::onNotOwned ()
{
destroy();
}
}
string SharedProperty::_getString() const
// **************************************
{
return Inherit::_getString();
}
Record* SharedProperty::_getRecord() const
// *********************************
{
Record* record = Inherit::_getRecord();
string SharedProperty::_getString () const
{
return Property::_getString ();
}
Record* SharedProperty::_getRecord () const
{
Record* record = Property::_getRecord();
if (record) {
record->add(getSlot("Owners", &_ownerSet));
record->add(getSlot("Owners", &_ownerSet));
}
return record;
}
}
} // End of Hurricane namespace.
// ****************************************************************************************************
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************

View File

@ -1,55 +1,112 @@
// ****************************************************************************************************
// File: Warning.cpp
// Authors: R. Escassut
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************
#include "hurricane/Warning.h"
// -*- C++ -*-
//
// This file is part of the Hurricane Software.
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Remy Escassut |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./Warning.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
# include <cstdarg>
# include "hurricane/Warning.h"
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::Warning".
// ****************************************************************************************************
// Warning implementation
// ****************************************************************************************************
Warning::Warning(const string& reason, int code)
// *********************************************
: Inherit(),
_reason(reason),
_code(code)
{
}
Warning::Warning ( const string& reason )
: Exception()
, _reason(reason)
, _code(0)
{ }
Warning::Warning(const Warning& warning)
// *************************************
: Inherit(),
_reason(warning._reason),
_code(warning._code)
{
}
Warning& Warning::operator=(const Warning& warning)
// ************************************************
{
Warning::Warning ( int code, const string& reason )
: Exception()
, _reason(reason)
, _code(code)
{ }
Warning::Warning ( const char* format, ... )
: Exception()
, _reason()
, _code(0)
{
static char formatted [ 8192 ];
va_list args;
va_start ( args, format );
vsnprintf ( formatted, 8191, format, args );
va_end ( args );
_reason = formatted;
}
Warning::Warning ( int code, const char* format, ... )
: Exception()
, _reason()
, _code(code)
{
static char formatted [ 8192 ];
va_list args;
va_start ( args, format );
vsnprintf ( formatted, 8191, format, args );
va_end ( args );
_reason = formatted;
}
Warning::Warning ( const Warning& warning )
: Exception()
, _reason(warning._reason)
, _code(warning._code)
{ }
Warning& Warning::operator= ( const Warning& warning )
{
_reason = warning._reason;
_code = warning._code;
_code = warning._code;
return *this;
}
}
string Warning::_getString() const
// *******************************
{
if (!_code) return "[WARNING] " + _reason;
string Warning::_getTypeName () const
{ return _TName("Warning"); }
string Warning::_getString () const
{
if (!_code)
return "[WARNING] " + _reason;
return "[WARNING:" + getString(_code) + "] " + _reason;
}
}
} // End of Hurricane namespace.
// ****************************************************************************************************
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************

View File

@ -129,7 +129,7 @@ template<typename Data> inline Hurricane::Slot* getSlot ( const std::string& nam
// Default match.
template<typename Data> inline std::string getString ( Data data )
{ return "<Data Unsupported by getString>"; }
{ return "<Data type unsupported by getString()>"; }
// "const *" flavors.
@ -524,26 +524,28 @@ inline Hurricane::Record* getRecord ( const std::multiset<Element,Compare>* s )
}
# define GETSTRING_POINTER_SUPPORT(Data) \
template<> inline std::string getString<Data*>( Data* data ) \
{ if (!data) return "NULL " #Data; return data->_getString(); } \
\
template<> inline std::string getString<const Data*>( const Data* data ) \
{ if (!data) return "NULL const " #Data; return data->_getString(); }
# define IOSTREAM_POINTER_SUPPORT(Data) \
inline std::ostream& operator<< ( std::ostream& o, Data* d ) \
{ \
if (!d) return o << "NULL"; \
return o << "&" << getString<Data*>(d); \
} \
inline std::ostream& operator<< ( std::ostream& o, const Data* d ) \
{ \
if (!d) return o << "NULL"; \
return o << "&" << getString<const Data*>(d); \
inline std::ostream& operator<< ( std::ostream& o, Data* d ) \
{ \
if (!d) return o << "NULL"; \
return o << "&" << getString<Data*>(d); \
} \
inline std::ostream& operator<< ( std::ostream& o, const Data* d ) \
{ \
if (!d) return o << "NULL"; \
return o << "&" << getString<const Data*>(d); \
}
# define INSPECTOR_POINTER_SUPPORT(Data) \
template<> inline std::string getString<Data*>( Data* data ) \
{ if (!data) return "NULL " #Data; return data->_getString(); } \
\
template<> inline std::string getString<const Data*>( const Data* data ) \
{ if (!data) return "NULL const " #Data; return data->_getString(); } \
\
# define GETRECORD_POINTER_SUPPORT(Data) \
template<> inline Hurricane::Record* getRecord<Data*>( Data* data ) \
{ if (!data) return NULL; return data->_getRecord(); } \
\
@ -551,21 +553,23 @@ inline Hurricane::Record* getRecord ( const std::multiset<Element,Compare>* s )
{ if (!data) return NULL; return data->_getRecord(); } \
# define GETSTRING_REFERENCE_SUPPORT(Data) \
template<> inline std::string getString<Data&>( Data& data ) \
{ return data._getString(); } \
\
template<> inline std::string getString<const Data&>( const Data& data ) \
{ return data._getString(); }
# define IOSTREAM_REFERENCE_SUPPORT(Data) \
inline std::ostream& operator<< ( std::ostream& o, Data& d ) \
{ return o << getString<Data&>(d); } \
\
inline std::ostream& operator<< ( std::ostream& o, const Data& d ) \
inline std::ostream& operator<< ( std::ostream& o, Data& d ) \
{ return o << getString<Data&>(d); } \
\
inline std::ostream& operator<< ( std::ostream& o, const Data& d ) \
{ return o << getString<Data&>(d); }
# define INSPECTOR_REFERENCE_SUPPORT(Data) \
template<> inline std::string getString<Data&>( Data& data ) \
{ return data._getString(); } \
\
template<> inline std::string getString<const Data&>( const Data& data ) \
{ return data._getString(); } \
\
# define GETRECORD_REFERENCE_SUPPORT(Data) \
template<> inline Hurricane::Record* getRecord<Data&>( Data& data ) \
{ return data._getRecord(); } \
\
@ -573,44 +577,53 @@ inline Hurricane::Record* getRecord ( const std::multiset<Element,Compare>* s )
{ return data._getRecord(); }
# define GETSTRING_VALUE_SUPPORT(Data) \
template<> inline std::string getString<Data>( Data data ) \
{ return data._getString(); }
# define IOSTREAM_VALUE_SUPPORT(Data) \
inline std::ostream& operator<< ( std::ostream& o, Data d ) \
{ return o << getString<Data>(d); }
# define INSPECTOR_VALUE_SUPPORT(Data) \
template<> inline std::string getString<Data>( Data data ) \
{ return data._getString(); } \
\
# define GETRECORD_VALUE_SUPPORT(Data) \
template<> inline Hurricane::Record* getRecord<Data>( Data data ) \
{ return data._getRecord(); }
# define INSPECTOR_P_SUPPORT(Data) \
INSPECTOR_POINTER_SUPPORT(Data) \
GETRECORD_POINTER_SUPPORT(Data) \
GETSTRING_POINTER_SUPPORT(Data) \
IOSTREAM_POINTER_SUPPORT(Data)
# define INSPECTOR_R_SUPPORT(Data) \
INSPECTOR_REFERENCE_SUPPORT(Data) \
GETRECORD_REFERENCE_SUPPORT(Data) \
GETSTRING_REFERENCE_SUPPORT(Data) \
IOSTREAM_REFERENCE_SUPPORT(Data)
# define INSPECTOR_V_SUPPORT(Data) \
INSPECTOR_VALUE_SUPPORT(Data) \
GETRECORD_VALUE_SUPPORT(Data) \
GETSTRING_VALUE_SUPPORT(Data) \
IOSTREAM_VALUE_SUPPORT(Data)
# define INSPECTOR_PR_SUPPORT(Data) \
INSPECTOR_POINTER_SUPPORT(Data) \
INSPECTOR_REFERENCE_SUPPORT(Data) \
GETRECORD_POINTER_SUPPORT(Data) \
GETSTRING_POINTER_SUPPORT(Data) \
GETRECORD_REFERENCE_SUPPORT(Data) \
GETSTRING_REFERENCE_SUPPORT(Data) \
IOSTREAM_POINTER_SUPPORT(Data) \
IOSTREAM_REFERENCE_SUPPORT(Data)
# define INSPECTOR_PV_SUPPORT(Data) \
INSPECTOR_POINTER_SUPPORT(Data) \
INSPECTOR_VALUE_SUPPORT(Data) \
GETRECORD_POINTER_SUPPORT(Data) \
GETSTRING_POINTER_SUPPORT(Data) \
GETRECORD_VALUE_SUPPORT(Data) \
GETSTRING_VALUE_SUPPORT(Data) \
IOSTREAM_POINTER_SUPPORT(Data) \
IOSTREAM_VALUE_SUPPORT(Data)

View File

@ -1,97 +1,87 @@
// ****************************************************************************************************
// File: DBo.h
// Authors: R. Escassut
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************
#ifndef HURRICANE_DBO
#define HURRICANE_DBO
// -*- C++ -*-
//
// This file is part of the Hurricane Software.
// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./DBo.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_DBO__
#define __HURRICANE_DBO__
#include "hurricane/DBos.h"
#include "hurricane/Properties.h"
#include "hurricane/Name.h"
#include "hurricane/DBos.h"
#include "hurricane/Name.h"
#include "hurricane/Property.h"
namespace Hurricane {
class Property;
// ****************************************************************************************************
// DBo declaration
// ****************************************************************************************************
class DBo {
// ********
// -------------------------------------------------------------------
// Class : "Hurricane::DBo".
#if !defined(__DOXYGEN_PROCESSOR__)
// Types
// *****
class DBo {
public: typedef set<Property*> PropertySet;
public:
// Types.
typedef set<Property*> PropertySet;
// Methods.
virtual void destroy();
inline PropertySet& _getPropertySet ();
void _onDestroyed ( Property* property );
Property* getProperty ( const Name& ) const;
Properties getProperties () const;
inline bool hasProperty () const;
void put ( Property* );
void remove ( Property* );
void removeProperty ( const Name& );
void clearProperties ();
// Hurricane Managment.
virtual string _getTypeName () const;
virtual string _getString () const;
virtual Record* _getRecord () const;
// Attributs
// *********
private:
// Internal: Attributes.
mutable PropertySet _propertySet;
private: mutable PropertySet _propertySet;
protected:
// Internal: Constructors & Destructors.
DBo ();
virtual ~DBo ();
virtual void _postCreate ();
virtual void _preDestroy ();
private:
// Forbidden: Copies.
DBo ( const DBo& );
DBo& operator= ( const DBo& );
};
// Constructors
// ************
protected: DBo();
private: DBo(const DBo& dbo); // not implemented to forbid copy construction
// Destructors
// ***********
protected: virtual ~DBo();
// Operators
// *********
private: DBo& operator=(const DBo& dbo); // not implemented to forbid assignment
// Others
// ******
protected: virtual void _postCreate();
protected: virtual void _preDestroy();
public: virtual string _getTypeName() const;
public: virtual string _getString() const;
public: virtual Record* _getRecord() const;
public: PropertySet& _getPropertySet() {return _propertySet;};
public: void _onDestroyed(Property* property);
#endif
// Destructors
// ***********
public: virtual void destroy();
// Accessors
// *********
public: Property* getProperty(const Name& name) const;
public: Properties getProperties() const {return getCollection(_propertySet);};
// Predicates
// **********
public: bool hasProperty() const {return !_propertySet.empty();};
// Updators
// ********
public: void put(Property* property);
public: void remove(Property* property);
public: void removeProperty(const Name& name);
public: void clearProperties();
};
// Inline Functions.
inline DBo::PropertySet& DBo::_getPropertySet () { return _propertySet; }
inline bool DBo::hasProperty () const { return !_propertySet.empty(); }
} // End of Hurricane namespace.
@ -114,8 +104,4 @@ inline Hurricane::Slot* getSlot ( const std::string& name, std::set<Hurricane::P
}
#endif // HURRICANE_DBO
// ****************************************************************************************************
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************
#endif // __HURRICANE_DBO__

View File

@ -63,4 +63,10 @@ namespace Hurricane {
} // End of Hurricane namespace.
GETSTRING_POINTER_SUPPORT(Hurricane::Error);
GETSTRING_VALUE_SUPPORT(Hurricane::Error);
IOSTREAM_POINTER_SUPPORT(Hurricane::Error);
IOSTREAM_VALUE_SUPPORT(Hurricane::Error);
# endif // __HURRICANE_ERROR__

View File

@ -23,6 +23,9 @@ class SharedName;
class Name {
// *******
private: static const Name _emptyName;
public: static const Name& emptyName () { return _emptyName; };
// Attributes
// **********

View File

@ -1,355 +1,443 @@
// ****************************************************************************************************
// File: Property.h
// Authors: R. Escassut
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************
#ifndef HURRICANE_PROPERTY
#define HURRICANE_PROPERTY
// -*- C++ -*-
//
// This file is part of the Hurricane Software.
// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./Property.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_PROPERTY__
#define __HURRICANE_PROPERTY__
#include "hurricane/Name.h"
#include "hurricane/Properties.h"
#include "hurricane/DBo.h"
#include "hurricane/Error.h"
#include "hurricane/Name.h"
#include "hurricane/Properties.h"
#include "hurricane/DBos.h"
#include "hurricane/Error.h"
namespace Hurricane {
extern const char* propertyTypeNameError;
// -------------------------------------------------------------------
// Class : "Hurricane::Property".
class Property {
public:
// Static Method.
template<typename DerivedProperty>
static DerivedProperty* get ( const DBo* );
static Name staticGetName ();
// Constructor.
template<typename DerivedProperty>
static DerivedProperty* create ();
template<typename DerivedProperty, typename Value>
static DerivedProperty* create ( const Value& );
// Destructor.
virtual void destroy ();
// Methods.
virtual Name getName () const = 0;
virtual void onCapturedBy ( DBo* owner ) = 0;
virtual void onReleasedBy ( DBo* owner ) = 0;
// Hurricane Managment.
virtual string _getTypeName () const = 0;
virtual string _getString () const;
virtual Record* _getRecord () const;
private:
static Name _baseName;
protected:
// Internal: Constructors & Destructors.
Property ();
virtual ~Property ();
virtual void _postCreate () {};
virtual void _preDestroy () {};
private:
Property ( const Property& );
Property& operator= ( const Property& );
};
template<typename DerivedProperty>
DerivedProperty* Property::create ()
{
DerivedProperty* property = new DerivedProperty();
property->_postCreate();
return property;
}
template<typename DerivedProperty, typename Value>
DerivedProperty* Property::create ( const Value& value )
{
DerivedProperty* property = new DerivedProperty(value);
property->_postCreate();
return property;
}
template<typename DerivedProperty>
DerivedProperty* Property::get ( const DBo* object )
{
Property* property1 = object->getProperty ( DerivedProperty::staticGetName() );
DerivedProperty* property2 = dynamic_cast<DerivedProperty*> ( property1 );
if ( property1 && !property2 )
throw Error ( propertyTypeNameError
, getString(DerivedProperty::staticGetName()).c_str()
, getString(object).c_str() );
return property2;
}
// -------------------------------------------------------------------
// Class : "Hurricane::PrivateProperty".
class PrivateProperty : public Property {
public:
// Methods.
inline DBo* getOwner () const;
virtual void onCapturedBy ( DBo* owner );
virtual void onReleasedBy ( DBo* owner );
virtual void onNotOwned ();
virtual string _getString () const;
virtual Record* _getRecord () const;
private:
// Internal: Attributes.
DBo* _owner;
protected:
// Internal: Constructor & Destructors.
PrivateProperty ();
virtual void _preDestroy ();
};
// Inline Functions.
inline DBo* PrivateProperty::getOwner () const { return _owner; };
// -------------------------------------------------------------------
// Template Class : "Hurricane::StandardPrivateProperty".
template<typename Value> class StandardPrivateProperty : public PrivateProperty {
public:
static Name staticGetName ();
static StandardPrivateProperty* get ( const DBo* );
// Constructors.
static StandardPrivateProperty* create ();
static StandardPrivateProperty* create ( const Value& );
// Methods.
virtual Name getName () const;
Value& getValue () const;
void setValue ( const Value& );
virtual string _getTypeName () const;
virtual string _getString () const;
virtual Record* _getRecord () const;
private:
// Internal: Attributes.
static Name _name;
mutable Value _value;
protected:
// Internal: Constructor.
StandardPrivateProperty ();
StandardPrivateProperty ( const Value& );
};
template<typename Value>
Name StandardPrivateProperty<Value>::staticGetName ()
{
return _name;
}
template<typename Value>
StandardPrivateProperty<Value>* StandardPrivateProperty<Value>::create ()
{
StandardPrivateProperty<Value>* property = new StandardPrivateProperty<Value>();
property->_postCreate();
return property;
}
template<typename Value>
StandardPrivateProperty<Value>* StandardPrivateProperty<Value>::create ( const Value& value )
{
StandardPrivateProperty<Value>* property = new StandardPrivateProperty<Value>(value);
property->_postCreate();
return property;
}
template<typename Value>
StandardPrivateProperty<Value>* StandardPrivateProperty<Value>::get ( const DBo* object )
{
Property* property1 = object->getProperty ( StandardPrivateProperty<Value>::staticGetName() );
StandardPrivateProperty* property2 = dynamic_cast<StandardPrivateProperty<Value>*> ( property1 );
if ( property1 && !property2 )
throw Error ( propertyTypeNameError
, getString(StandardPrivateProperty<Value>::staticGetName()).c_str()
, getString(object).c_str() );
return property2;
}
template<typename Value>
StandardPrivateProperty<Value>::StandardPrivateProperty ()
: PrivateProperty(), _value()
{ }
template<typename Value>
StandardPrivateProperty<Value>::StandardPrivateProperty ( const Value& value )
: PrivateProperty(), _value(value)
{ }
template<typename Value>
Name StandardPrivateProperty<Value>::getName() const
{
return staticGetName();
}
template<typename Value>
Value& StandardPrivateProperty<Value>::getValue () const
{
return _value;
}
template<typename Value>
void StandardPrivateProperty<Value>::setValue ( const Value& value )
{
_value = value;
}
template<typename Value>
string StandardPrivateProperty<Value>::_getTypeName () const
{
return _TName("StandardPrivateProperty");
}
template<typename Value>
string StandardPrivateProperty<Value>::_getString () const
{
string s = PrivateProperty::_getString();
s.insert(s.length() - 1, " " + getString(_value));
return s;
}
template<typename Value>
Record* StandardPrivateProperty<Value>::_getRecord () const
{
Record* record = PrivateProperty::_getRecord();
if (record) {
record->add ( getSlot("Name" , staticGetName()) );
record->add ( getSlot("Value",&_value) );
}
return record;
}
// -------------------------------------------------------------------
// Class : "Hurricane::SharedProperty".
class SharedProperty : public Property {
public:
// Types.
typedef set<DBo*> DBoSet;
// Methods.
inline DBos getOwners () const;
virtual void onCapturedBy ( DBo* owner );
virtual void onReleasedBy ( DBo* owner );
virtual void onNotOwned ();
inline DBoSet& _getOwnerSet ();
virtual string _getString () const;
virtual Record* _getRecord () const;
private:
// Internal: Attributes.
DBoSet _ownerSet;
protected:
// Internal: Constructor & Destructor.
SharedProperty ();
virtual void _preDestroy ();
};
// Inline Functions.
DBos SharedProperty::getOwners () const { return getCollection(_ownerSet); }
SharedProperty::DBoSet& SharedProperty::_getOwnerSet () { return _ownerSet; }
// -------------------------------------------------------------------
// Template Class : "Hurricane::StandardSharedProperty".
template<typename Value> class StandardSharedProperty : public SharedProperty {
// ****************************************************************************************************
// Property declaration
// ****************************************************************************************************
class Property {
// *************
// Constructors
// ************
protected: Property();
private: Property(const Property& property); // not implemented to forbid copy construction
// Destructors
// ***********
protected: virtual ~Property();
public: virtual void destroy();
// Operators
// *********
private: Property& operator=(const Property& property); // not implemented to forbid assignment
// Accessors
// *********
public: virtual Name getName() const = 0;
// Managers
// ********
public: virtual void onCapturedBy(DBo* owner) = 0;
public: virtual void onReleasedBy(DBo* owner) = 0;
// Others
// ******
protected: virtual void _postCreate() {};
protected: virtual void _preDestroy() {};
public: virtual string _getTypeName() const = 0;
public: virtual string _getString() const;
public: virtual Record* _getRecord() const;
};
// ****************************************************************************************************
// PrivateProperty declaration
// ****************************************************************************************************
class PrivateProperty : public Property {
// ************************************
// Types
// *****
public: typedef Property Inherit;
// Attributes
// **********
private: DBo* _owner;
// Constructors
// ************
protected: PrivateProperty();
// Accessors
// *********
public: DBo* getOwner() const {return _owner;};
// Managers
// ********
public: virtual void onCapturedBy(DBo* owner);
public: virtual void onReleasedBy(DBo* owner);
public: virtual void onNotOwned();
// Others
// ******
protected: virtual void _preDestroy();
public: virtual string _getString() const;
public: virtual Record* _getRecord() const;
};
// ****************************************************************************************************
// StandardPrivateProperty declaration
// ****************************************************************************************************
template<class Value> class StandardPrivateProperty : public PrivateProperty {
// *************************************************************************
// Types
// *****
public: typedef PrivateProperty Inherit;
// Attributes
// **********
private: Name _name;
private: Value _value;
// Constructors
// ************
protected: StandardPrivateProperty(const Name& name, const Value& value)
// *********************************************************************
: Inherit(),
_name(name),
_value(value)
{
};
public: static StandardPrivateProperty* create(const Name& name, const Value& value )
// **********************************************************************************
{
StandardPrivateProperty* property = new StandardPrivateProperty(name, value);
property->_postCreate();
return property;
};
// Accessors
// *********
public: virtual Name getName() const
// *********************************
{
return _name;
};
public: const Value& getValue() const
// **********************************
{
return _value;
};
// Modifieurs
// **********
public: void setValue(const Value& value)
// **************************************
{
_value = value;
};
// Others
// ******
public: virtual string _getTypeName() const
// ****************************************
{
return _TName("StandardPrivateProperty");
};
public: virtual string _getString() const
// **************************************
{
string s = Inherit::_getString();
s.insert(s.length() - 1, " " + getString(_value));
return s;
};
public: virtual Record* _getRecord() const
// *********************************
{
Record* record = Inherit::_getRecord();
if (record) {
record->add(getSlot("Name", &_name));
record->add(getSlot("Value", _value));
}
return record;
};
};
// ****************************************************************************************************
// SharedProperty declaration
// ****************************************************************************************************
class SharedProperty : public Property {
// ***********************************
// Types
// *****
public: typedef Property Inherit;
public: typedef set<DBo*> DBoSet;
// Attributes
// **********
private: DBoSet _ownerSet;
// Constructors
// ************
protected: SharedProperty();
// Accessors
// *********
public: DBos getOwners() const {return getCollection(_ownerSet);};
// Managers
// ********
public: virtual void onCapturedBy(DBo* owner);
public: virtual void onReleasedBy(DBo* owner);
public: virtual void onNotOwned();
// Accessors
// *********
protected: virtual void _preDestroy();
public: virtual string _getString() const;
public: virtual Record* _getRecord() const;
public: DBoSet& _getOwnerSet() {return _ownerSet;};
};
// ****************************************************************************************************
// StandardSharedProperty declaration
// ****************************************************************************************************
template<class Value> class StandardSharedProperty : public SharedProperty {
// ***********************************************************************
// Types
// *****
public: typedef SharedProperty Inherit;
// Attributes
// **********
private: Name _name;
private: Value _value;
// Constructors
// ************
protected: StandardSharedProperty(const Name& name, const Value& value)
// ********************************************************************
: Inherit(),
_name(name),
_value(value)
{
};
public: static StandardSharedProperty* create(const Name& name, const Value& value )
// *********************************************************************************
{
StandardSharedProperty* property = new StandardSharedProperty(name, value);
property->_postCreate();
return property;
};
// Accessors
// *********
public: virtual Name getName() const
// *********************************
{
return _name;
};
public: const Value& getValue() const
// **********************************
{
return _value;
};
// Modifieurs
// **********
public: void setValue(const Value& value)
// **************************************
{
_value = value;
};
// Others
// ******
public: virtual string _getTypeName() const
// ****************************************
{
return _TName("StandardSharedProperty");
};
public: virtual string _getString() const
// **************************************
{
string s = Inherit::_getString();
s.insert(s.length() - 1, " " + getString(_value));
return s;
};
public: virtual Record* _getRecord() const
// *********************************
{
Record* record = Inherit::_getRecord();
if (record) {
record->add(getSlot("Name", &_name));
record->add(getSlot("Value", &_value));
}
return record;
};
};
public:
static Name staticGetName ();
static StandardSharedProperty* get ( const DBo* );
// Constructors.
static StandardSharedProperty* create ();
static StandardSharedProperty* create ( const Value& );
// Methods.
virtual Name getName () const;
Value& getValue () const;
void setValue ( const Value& );
virtual string _getTypeName () const;
virtual string _getString () const;
virtual Record* _getRecord () const;
private:
// Internal: Attributes.
static Name _name;
mutable Value _value;
protected:
// Internal: Constructor.
StandardSharedProperty ();
StandardSharedProperty ( const Value& );
};
// Template function members.
template<typename Value>
Name StandardSharedProperty<Value>::staticGetName ()
{
return _name;
}
template<typename Value>
StandardSharedProperty<Value>* StandardSharedProperty<Value>::create ()
{
StandardSharedProperty<Value>* property = new StandardSharedProperty<Value>();
property->_postCreate();
return property;
}
template<typename Value>
StandardSharedProperty<Value>* StandardSharedProperty<Value>::create ( const Value& value )
{
StandardSharedProperty<Value>* property = new StandardPrivateProperty<Value>(value);
property->_postCreate();
return property;
}
template<typename Value>
StandardSharedProperty<Value>* StandardSharedProperty<Value>::get ( const DBo* object )
{
Property* property1 = object->getProperty ( StandardSharedProperty<Value>::staticGetName() );
StandardSharedProperty* property2 = dynamic_cast<StandardSharedProperty<Value>*> ( property1 );
if ( property1 && !property2 )
throw Error ( propertyTypeNameError
, getString(StandardSharedProperty<Value>::staticGetName()).c_str()
, getString(object).c_str() );
return property2;
}
template<typename Value>
StandardSharedProperty<Value>::StandardSharedProperty ()
: SharedProperty(), _value()
{ }
template<typename Value>
StandardSharedProperty<Value>::StandardSharedProperty ( const Value& value )
: SharedProperty(), _value(value)
{ }
template<typename Value>
Name StandardSharedProperty<Value>::getName() const
{
return staticGetName();
}
template<typename Value>
Value& StandardSharedProperty<Value>::getValue() const
{
return _value;
}
template<typename Value>
void StandardSharedProperty<Value>::setValue(const Value& value)
{
_value = value;
}
template<typename Value>
string StandardSharedProperty<Value>::_getTypeName() const
{
return _TName("StandardSharedProperty");
}
template<typename Value>
string StandardSharedProperty<Value>::_getString() const
{
string s = SharedProperty::_getString();
s.insert(s.length() - 1, " " + getString(_value));
return s;
}
template<typename Value>
Record* StandardSharedProperty<Value>::_getRecord() const
{
Record* record = SharedProperty::_getRecord();
if (record) {
record->add ( getSlot("Name" , staticGetName()) );
record->add ( getSlot("Value", &_value) );
}
return record;
}
} // End of Hurricane namespace.
@ -358,8 +446,4 @@ template<class Value> class StandardSharedProperty : public SharedProperty {
INSPECTOR_P_SUPPORT(Hurricane::Property);
#endif // HURRICANE_PROPERTY
// ****************************************************************************************************
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************
#endif // __HURRICANE_PROPERTY__

View File

@ -1,68 +1,73 @@
// ****************************************************************************************************
// File: Warning.h
// Authors: R. Escassut
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************
#ifndef HURRICANE_WARNING
#define HURRICANE_WARNING
// -*- C++ -*-
//
// This file is part of the Hurricane Software.
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Remy Escassut |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./Warning.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
# ifndef __HURRICANE_WARNING__
# define __HURRICANE_WARNING__
#include "hurricane/Exception.h"
namespace Hurricane {
class Warning : public Exception {
// ****************************************************************************************************
// Warning declaration
// ****************************************************************************************************
public:
// Constructors.
Warning ( const string& reason );
Warning ( const char* format, ... );
Warning ( int code, const string& reason );
Warning ( int code, const char* format, ... );
Warning ( const Warning& warning );
Warning& operator= ( const Warning& warning );
// Methods.
inline string getReason () const;
inline int getCode () const;
// Hurricane Managment.
virtual string _getTypeName () const;
virtual string _getString () const;
class Warning : public Exception {
// *****************************
protected:
// Internal: Attributes.
string _reason;
int _code;
};
// Types
// *****
public: typedef Exception Inherit;
// Attributes
// **********
private: string _reason;
private: int _code;
// Constructors
// ************
public: Warning(const string& reason, int code = 0);
public: Warning(const Warning& warning);
// Operators
// *********
public: Warning& operator=(const Warning& warning);
// Accessors
// *********
public: string getReason() const {return _reason;};
public: int getCode() const {return _code;};
// Others
// ******
public: virtual string _getTypeName() const { return _TName("Warning"); };
public: virtual string _getString() const;
};
// Inline Functions.
inline string Warning::getReason () const { return _reason; }
inline int Warning::getCode () const { return _code; }
} // End of Hurricane namespace.
#endif // HURRICANE_WARNING
GETSTRING_POINTER_SUPPORT(Hurricane::Warning);
GETSTRING_VALUE_SUPPORT(Hurricane::Warning);
IOSTREAM_POINTER_SUPPORT(Hurricane::Warning);
IOSTREAM_VALUE_SUPPORT(Hurricane::Warning);
// ****************************************************************************************************
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
// ****************************************************************************************************
# endif // __HURRICANE_WARNING__

View File

@ -53,6 +53,7 @@
# include <cassert>
# include "hurricane/viewer/DisplayStyle.h"
# include "hurricane/viewer/Graphics.h"
@ -112,7 +113,11 @@ namespace Hurricane {
, float threshold
)
{
return new DrawingStyle ( name, pattern, red, green, blue, borderWidth, threshold );
DrawingStyle* style = new DrawingStyle ( name, pattern, red, green, blue, borderWidth, threshold );
//if ( Graphics::isEnabled() )
// style->qtAllocate ();
return style;
}

View File

@ -76,9 +76,6 @@ namespace Hurricane {
, _active(NULL)
, _qtEnabled(false)
{
_styles.push_back ( new DisplayStyle("Fallback") );
_active = _styles[0];
_active->setDescription ( "Builtin fallback style" );
}
@ -90,8 +87,12 @@ namespace Hurricane {
Graphics* Graphics::getGraphics ()
{
if ( !_singleton )
if ( !_singleton ) {
_singleton = new Graphics ();
DisplayStyle* fallback = new DisplayStyle("Fallback");
fallback->setDescription ( "Builtin fallback style" );
_singleton->_addStyle ( fallback );
}
return _singleton;
}