.. _program_listing_file_include_gwmodelpp_spatialweight_SpatialWeight.h: Program Listing for File SpatialWeight.h ======================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/gwmodelpp/spatialweight/SpatialWeight.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef SPATIALWEIGHT_H #define SPATIALWEIGHT_H #include "Weight.h" #include "Distance.h" #include "BandwidthWeight.h" #include "CRSDistance.h" #include "MinkwoskiDistance.h" #include "DMatDistance.h" #include "OneDimDistance.h" namespace gwm { class SpatialWeight { public: SpatialWeight(); SpatialWeight(Weight* weight, Distance* distance); SpatialWeight(const SpatialWeight& spatialWeight); virtual ~SpatialWeight(); Weight *weight() const { return mWeight; } void setWeight(Weight *weight) { if (mWeight) delete mWeight; mWeight = weight; } void setWeight(Weight& weight) { if (mWeight) delete mWeight; mWeight = weight.clone(); } void setWeight(Weight&& weight) { if (mWeight) delete mWeight; mWeight = weight.clone(); } template T* weight() const { return nullptr; } Distance *distance() const { return mDistance; } void setDistance(Distance *distance) { if (mDistance) delete mDistance; mDistance = distance; } void setDistance(Distance& distance) { if (mDistance) delete mDistance; mDistance = distance.clone(); } void setDistance(Distance&& distance) { if (mDistance) delete mDistance; mDistance = distance.clone(); } template T* distance() const { return nullptr; } public: SpatialWeight& operator=(const SpatialWeight& spatialWeight); SpatialWeight& operator=(const SpatialWeight&& spatialWeight); public: virtual arma::vec weightVector(arma::uword focus) { return mWeight->weight(mDistance->distance(focus)); } virtual bool isValid(); private: Weight* mWeight = nullptr; Distance* mDistance = nullptr; }; template<> inline BandwidthWeight* SpatialWeight::weight() const { return static_cast(mWeight); } template<> inline CRSDistance* SpatialWeight::distance() const { return static_cast(mDistance); } template<> inline MinkwoskiDistance* SpatialWeight::distance() const { return static_cast(mDistance); } template<> inline DMatDistance* SpatialWeight::distance() const { return static_cast(mDistance); } template<> inline OneDimDistance* SpatialWeight::distance() const { return static_cast(mDistance); } } #endif // SPATIALWEIGHT_H