diff --git a/modules/img/base/src/CMakeLists.txt b/modules/img/base/src/CMakeLists.txt index 23e6ea92d7bb9a0ed6dd7452d02b9f306e24099d..78097d2ab0af3686fa5298e23c5e7d062eaec9fb 100644 --- a/modules/img/base/src/CMakeLists.txt +++ b/modules/img/base/src/CMakeLists.txt @@ -3,85 +3,86 @@ add_subdirectory(image_state) set(OST_IMG_SOURCES -data.cc +circle_mask.cc +composite_mask.cc data_algorithm.cc data_observer.cc -extent.cc +data.cc extent_iterator.cc +extent_mask.cc +extent.cc image_factory.cc image_handle.cc image_impl.cc +image_list.cc +inverted_mask.cc +map.cc +mask_base.cc +mask_op.cc +mask.cc +observable.cc paste_impl.cc peak.cc -pixel_sampling.cc phase.cc -point.cc +physical_units.cc +pixel_sampling.cc point_list.cc -size.cc -mask.cc -mask_base.cc -composite_mask.cc -inverted_mask.cc +point.cc polygon_mask.cc -extent_mask.cc -spherical_mask.cc -mask_op.cc -circle_mask.cc -image_list.cc -physical_units.cc progress.cc -map.cc +size.cc +spherical_mask.cc ) set(OST_IMG_HEADERS algorithm.hh +circle_mask.hh +composite_mask.hh data_algorithm.hh -data.hh -data_types.hh data_observer.hh +data_types.hh +data.hh debug.hh dllexport.hh -extent.hh extent_iterator.hh -image.hh +extent_mask.hh +extent.hh image_factory.hh image_fw.hh -image_handle.hh image_handle_fw.hh +image_handle.hh image_impl.hh -image_state.hh +image_list.hh image_state_fw.hh +image_state.hh +image.hh +inverted_mask.hh +map.hh +mask_base_fw.hh +mask_base.hh +mask_op.hh mask_visitor.hh +mask.hh +module_config.hh normalizer_fw.hh normalizer_impl.hh null_data.hh observable.hh paste_impl.hh peak.hh -pixel_sampling.hh phase.hh -point.hh +physical_units.hh +pixel_sampling.hh point_list.hh +point.hh +polygon_mask.hh +progress.hh size.hh -util.hh +spherical_mask.hh util.cc -module_config.hh +util.hh value_util.hh vecmat.hh -mask_base_fw.hh -mask_base.hh -composite_mask.hh -inverted_mask.hh -polygon_mask.hh -extent_mask.hh -spherical_mask.hh -mask_op.hh -mask.hh -circle_mask.hh -image_list.hh -physical_units.hh -progress.hh -map.hh ) if (ENABLE_INFO) diff --git a/modules/img/base/src/image_handle.hh b/modules/img/base/src/image_handle.hh index 62ed281d2967872bc44d790c3b7d1e09f94f2ae9..13a6cb2429674bcb6864eac57055278439e2e727 100644 --- a/modules/img/base/src/image_handle.hh +++ b/modules/img/base/src/image_handle.hh @@ -117,7 +117,7 @@ class DLLEXPORT_OST_IMG_BASE ImageHandle: public Data { // for access to Sampling friend class ConstImageHandle; - typedef Observable<DataObserver> DataObservable; + typedef Observable DataObservable; typedef boost::shared_ptr<DataObservable> ObsPtr; typedef boost::shared_ptr<ImageStateBasePtr> StatePtrPtr; diff --git a/modules/img/base/src/observable.cc b/modules/img/base/src/observable.cc new file mode 100644 index 0000000000000000000000000000000000000000..36d52009408a2d470d97cc3edfcf4396ba92ffb2 --- /dev/null +++ b/modules/img/base/src/observable.cc @@ -0,0 +1,82 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2011 by the OpenStructure authors +// Copyright (C) 2003-2010 by the IPLT authors +// +// This library 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.0 of the License, or (at your option) +// any later version. +// This library 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 this library; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +//------------------------------------------------------------------------------ + +/* + abstract observable concept + + Author: Ansgar Philippsen +*/ + +#include <ost/img/observable.hh> +#include <ost/img/data_observer.hh> + +namespace ost { namespace img { + +Observable::Observable() { + list_.clear(); +} + +Observable::Observable(const Observable& o) { + list_.clear(); +} + +Observable::~Observable() { + for(ObserverIter it=list_.begin();it!=list_.end();++it) { + (*it)->ObserverInvalidate(); + (*it)->ObserverRelease(); + } +} + +Observable& Observable::operator=(const Observable& o) { + list_.clear(); + return *this; +} + +void Observable::Attach(DataObserver* d) { + list_.push_back(d); +} + +void Observable::Detach(DataObserver* o) { + list_.remove(o); +} + +void Observable::Notify() const { + for(ObserverConstIter it=list_.begin();it!=list_.end();++it) + (*it)->ObserverUpdate(); +} +void Observable::Notify(const Extent& e) const { + for(ObserverConstIter it=list_.begin();it!=list_.end();++it) + (*it)->ObserverUpdate(e); +} +void Observable::Notify(const Point& p) const { + for(ObserverConstIter it=list_.begin();it!=list_.end();++it) + (*it)->ObserverUpdate(p); +} + +int Observable::GetListSize() const { + return list_.size(); +} + +long Observable::MemSize() const { + return sizeof(list_) + list_.size()*sizeof(DataObserver*); +} + + +}} // namespace diff --git a/modules/img/base/src/observable.hh b/modules/img/base/src/observable.hh index 90da00db135cb2c742b221545b2677525885ddc4..7b8ca63b81b135c88e5d4f9d42a4f6f35a06de55 100644 --- a/modules/img/base/src/observable.hh +++ b/modules/img/base/src/observable.hh @@ -19,7 +19,7 @@ //------------------------------------------------------------------------------ /* - abstract observable concept + observable concept Author: Ansgar Philippsen */ @@ -32,72 +32,43 @@ namespace ost { namespace img { +// fw decl +class DataObserver; + //! templated observable class /* manages a list of observers, which must offer the methods ObserverRelease, ObserverInvalidate and ObserverUpdate */ -template <class T> class DLLEXPORT Observable { - typedef std::list<T *> ObserverList; - typedef typename ObserverList::iterator ObserverIter; - typedef typename ObserverList::const_iterator ObserverConstIter; + typedef std::list<DataObserver *> ObserverList; + typedef ObserverList::iterator ObserverIter; + typedef ObserverList::const_iterator ObserverConstIter; public: - Observable() { - list_.clear(); - } - + Observable() ; /* copy logic: the observers are not copied */ - Observable(const Observable& o) { - list_.clear(); - } + Observable(const Observable& o) ; - ~Observable() { - for(ObserverIter it=list_.begin();it!=list_.end();++it) { - (*it)->ObserverInvalidate(); - (*it)->ObserverRelease(); - } - } + ~Observable() ; /* assignement logic: the observers are not copied */ - Observable& operator=(const Observable& o) { - list_.clear(); - return *this; - } - - void Attach(T* d) { - list_.push_back(d); - } - - void Detach(T* o) { - list_.remove(o); - } - - void Notify() const { - for(ObserverConstIter it=list_.begin();it!=list_.end();++it) - (*it)->ObserverUpdate(); - } - void Notify(const Extent& e) const { - for(ObserverConstIter it=list_.begin();it!=list_.end();++it) - (*it)->ObserverUpdate(e); - } - void Notify(const Point& p) const { - for(ObserverConstIter it=list_.begin();it!=list_.end();++it) - (*it)->ObserverUpdate(p); - } - - int GetListSize() const { - return list_.size(); - } - - long MemSize() const { - return sizeof(list_) + list_.size()*sizeof(T*); - } + Observable& operator=(const Observable& o) ; + + void Attach(DataObserver* d) ; + + void Detach(DataObserver* o) ; + + void Notify() const ; + void Notify(const Extent& e) const ; + void Notify(const Point& p) const ; + int GetListSize() const ; + + long MemSize() const ; private: ObserverList list_;