Skip to content
Snippets Groups Projects
Commit 2af836ec authored by Andreas Schenk's avatar Andreas Schenk
Browse files

replaced abstract observable class with concrete version for Data

This change simplifies downstream refactoring of Data and ImageHandle
parent c8ed01b3
Branches
Tags
No related merge requests found
...@@ -3,85 +3,86 @@ add_subdirectory(image_state) ...@@ -3,85 +3,86 @@ add_subdirectory(image_state)
set(OST_IMG_SOURCES set(OST_IMG_SOURCES
data.cc circle_mask.cc
composite_mask.cc
data_algorithm.cc data_algorithm.cc
data_observer.cc data_observer.cc
extent.cc data.cc
extent_iterator.cc extent_iterator.cc
extent_mask.cc
extent.cc
image_factory.cc image_factory.cc
image_handle.cc image_handle.cc
image_impl.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 paste_impl.cc
peak.cc peak.cc
pixel_sampling.cc
phase.cc phase.cc
point.cc physical_units.cc
pixel_sampling.cc
point_list.cc point_list.cc
size.cc point.cc
mask.cc
mask_base.cc
composite_mask.cc
inverted_mask.cc
polygon_mask.cc polygon_mask.cc
extent_mask.cc
spherical_mask.cc
mask_op.cc
circle_mask.cc
image_list.cc
physical_units.cc
progress.cc progress.cc
map.cc size.cc
spherical_mask.cc
) )
set(OST_IMG_HEADERS set(OST_IMG_HEADERS
algorithm.hh algorithm.hh
circle_mask.hh
composite_mask.hh
data_algorithm.hh data_algorithm.hh
data.hh
data_types.hh
data_observer.hh data_observer.hh
data_types.hh
data.hh
debug.hh debug.hh
dllexport.hh dllexport.hh
extent.hh
extent_iterator.hh extent_iterator.hh
image.hh extent_mask.hh
extent.hh
image_factory.hh image_factory.hh
image_fw.hh image_fw.hh
image_handle.hh
image_handle_fw.hh image_handle_fw.hh
image_handle.hh
image_impl.hh image_impl.hh
image_state.hh image_list.hh
image_state_fw.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_visitor.hh
mask.hh
module_config.hh
normalizer_fw.hh normalizer_fw.hh
normalizer_impl.hh normalizer_impl.hh
null_data.hh null_data.hh
observable.hh observable.hh
paste_impl.hh paste_impl.hh
peak.hh peak.hh
pixel_sampling.hh
phase.hh phase.hh
point.hh physical_units.hh
pixel_sampling.hh
point_list.hh point_list.hh
point.hh
polygon_mask.hh
progress.hh
size.hh size.hh
util.hh spherical_mask.hh
util.cc util.cc
module_config.hh util.hh
value_util.hh value_util.hh
vecmat.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) if (ENABLE_INFO)
......
...@@ -117,7 +117,7 @@ class DLLEXPORT_OST_IMG_BASE ImageHandle: public Data { ...@@ -117,7 +117,7 @@ class DLLEXPORT_OST_IMG_BASE ImageHandle: public Data {
// for access to Sampling // for access to Sampling
friend class ConstImageHandle; friend class ConstImageHandle;
typedef Observable<DataObserver> DataObservable; typedef Observable DataObservable;
typedef boost::shared_ptr<DataObservable> ObsPtr; typedef boost::shared_ptr<DataObservable> ObsPtr;
typedef boost::shared_ptr<ImageStateBasePtr> StatePtrPtr; typedef boost::shared_ptr<ImageStateBasePtr> StatePtrPtr;
......
//------------------------------------------------------------------------------
// 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
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/* /*
abstract observable concept observable concept
Author: Ansgar Philippsen Author: Ansgar Philippsen
*/ */
...@@ -32,72 +32,43 @@ ...@@ -32,72 +32,43 @@
namespace ost { namespace img { namespace ost { namespace img {
// fw decl
class DataObserver;
//! templated observable class //! templated observable class
/* /*
manages a list of observers, which must manages a list of observers, which must
offer the methods ObserverRelease, ObserverInvalidate offer the methods ObserverRelease, ObserverInvalidate
and ObserverUpdate and ObserverUpdate
*/ */
template <class T>
class DLLEXPORT Observable { class DLLEXPORT Observable {
typedef std::list<T *> ObserverList; typedef std::list<DataObserver *> ObserverList;
typedef typename ObserverList::iterator ObserverIter; typedef ObserverList::iterator ObserverIter;
typedef typename ObserverList::const_iterator ObserverConstIter; typedef ObserverList::const_iterator ObserverConstIter;
public: public:
Observable() { Observable() ;
list_.clear();
}
/* /*
copy logic: the observers are not copied copy logic: the observers are not copied
*/ */
Observable(const Observable& o) { Observable(const Observable& o) ;
list_.clear();
}
~Observable() { ~Observable() ;
for(ObserverIter it=list_.begin();it!=list_.end();++it) {
(*it)->ObserverInvalidate();
(*it)->ObserverRelease();
}
}
/* /*
assignement logic: the observers are not copied assignement logic: the observers are not copied
*/ */
Observable& operator=(const Observable& o) { Observable& operator=(const Observable& o) ;
list_.clear();
return *this; void Attach(DataObserver* d) ;
}
void Detach(DataObserver* o) ;
void Attach(T* d) {
list_.push_back(d); void Notify() const ;
} void Notify(const Extent& e) const ;
void Notify(const Point& p) const ;
void Detach(T* o) { int GetListSize() const ;
list_.remove(o);
} long MemSize() const ;
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*);
}
private: private:
ObserverList list_; ObserverList list_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment