/usr/include/tulip/ObservableProperty.h is in libtulip-dev 3.1.2-2.3ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | //-*-c++-*-
/**
Authors: David Auber, Patrick Mary, Morgan Mathiaut
from the LaBRI Visualization Team
Email : auber@tulip-software.org
Last modification : 13/03/2009
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/
#ifndef PROPERTYOBSERVABLE_H
#define PROPERTYOBSERVABLE_H
#include <ext/slist>
#include "tulip/Node.h"
#include "tulip/Edge.h"
namespace tlp {
struct PropertyInterface;
//=========================================================
/** \addtogroup graphs */
/*@{*/
/// Observer for Property
/**
* The Observer pattern is described in the lecture notes and pp293-304
* of Design Patterns by Gamma, Helm, Johnson, and Vlissides. It is a
* framework for handling state dependency between observer and observed
* object.
*/
class TLP_SCOPE PropertyObserver {
public:
virtual ~PropertyObserver() {}
virtual void beforeSetNodeValue(PropertyInterface*, const node){}
virtual void afterSetNodeValue(PropertyInterface*, const node){}
virtual void beforeSetEdgeValue(PropertyInterface*, const edge){}
virtual void afterSetEdgeValue(PropertyInterface*, const edge){}
virtual void beforeSetAllNodeValue(PropertyInterface*){}
virtual void afterSetAllNodeValue(PropertyInterface*){}
virtual void beforeSetAllEdgeValue(PropertyInterface*){}
virtual void afterSetAllEdgeValue(PropertyInterface*){}
virtual void destroy(PropertyInterface*){}
};
/*@}*/
}
#ifndef DOXYGEN_NOTFOR_DEVEL
/* namespace std {
template <>
struct less<tlp::PropertyObserver *> {
size_t operator()(const tlp::PropertyObserver * obs1,const tlp::PropertyObserver *obs2) const {
return (unsigned long)obs1<(unsigned long)obs2;
}
};
}*/
#endif // DOXYGEN_NOTFOR_DEVEL
namespace tlp {
/** \addtogroup graphs */
/*@{*/
/**
*/
/// Observable object for Property
class TLP_SCOPE ObservableProperty {
public:
virtual ~ObservableProperty() {}
/**
* Register a new observer
*/
void addPropertyObserver(PropertyObserver *) const;
/**
* Returns the number of observers
*/
unsigned int countPropertyObservers();
/**
* Remove an observer
*/
void removePropertyObserver(PropertyObserver *) const;
/**
* Remove all observers
*/
void removePropertyObservers();
protected:
void notifyBeforeSetNodeValue(PropertyInterface*,const node n);
void notifyAfterSetNodeValue(PropertyInterface*,const node n);
void notifyBeforeSetEdgeValue(PropertyInterface*,const edge e);
void notifyAfterSetEdgeValue(PropertyInterface*,const edge e);
void notifyBeforeSetAllNodeValue(PropertyInterface*);
void notifyAfterSetAllNodeValue(PropertyInterface*);
void notifyBeforeSetAllEdgeValue(PropertyInterface*);
void notifyAfterSetAllEdgeValue(PropertyInterface*);
void notifyDestroy(PropertyInterface*);
mutable stdext::slist<PropertyObserver*> observers;
};
/*@}*/
inline void ObservableProperty::addPropertyObserver(PropertyObserver *obs) const {
observers.push_front(obs);
}
inline unsigned int ObservableProperty::countPropertyObservers() {
return observers.size();
}
inline void ObservableProperty::removePropertyObserver(PropertyObserver *item) const{
observers.remove(item);
}
inline void ObservableProperty::removePropertyObservers() {
observers.clear();
}
}
#endif
|