Advertisement
Guest User

Untitled

a guest
Dec 14th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.78 KB | None | 0 0
  1.     namespace khipu{
  2. //filterbank.h
  3.         template < typename T >
  4.         class Filterbank;
  5.  
  6.         template < typename T >
  7.         void swap( Filterbank<T> &, Filterbank<T> & );
  8.  
  9.         template < typename T >
  10.         class Filterbank{
  11.  
  12.             public:
  13.  
  14.                 typedef std::unique_ptr<Kernel2D<T> > KernelPtr;
  15.  
  16.                 Filterbank();
  17.                 Filterbank( Filterbank<T> && );
  18.                 ~Filterbank();
  19.  
  20.                 friend void swap <>( Filterbank<T> &, Filterbank<T> & );
  21.                 Filterbank<T> & operator =( Filterbank<T> && );
  22.                 const std::unique_ptr<Kernel2D<T> > & at ( int ) const;
  23.  
  24.                 int size() const;
  25.  
  26.             private:
  27.  
  28.                 std::vector< KernelPtr > m_Bank; // error here
  29.                 //  error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>'
  30.                 //
  31.         };
  32.     }
  33.  
  34.     namespace khipu{
  35. // filterbankdescriptor.h
  36.         template < typename T >
  37.         class FilterbankDescriptor : public Descriptor<T>{
  38.  
  39.             public:
  40.                
  41.                 FilterbankDescriptor();
  42.                 FilterbankDescriptor( const Filterbank<T> & );
  43.                 FilterbankDescriptor( const FilterbankDescriptor<T> & );
  44.                 FilterbankDescriptor( FilterbankDescriptor<T> && );
  45.                 ~FilterbankDescriptor();
  46.  
  47.                 virtual std::unique_ptr<Descriptor<T> > clone() const;
  48.                 virtual std::unique_ptr<Descriptor<T> > create() const;
  49.  
  50.                 virtual FeatureImage<T> describe(const Matrix<T> &, const std::string & ) const;
  51.                 virtual FeatureImage<T> describe(const FeatureImage<T> &, const std::string & ) const;
  52.  
  53.             private:
  54.  
  55.                 Filterbank<T> m_Bank; // error here
  56.        
  57.         };
  58.     }
  59.  
  60.  
  61.  
  62. namespace khipu{
  63. //filterbank.cpp
  64.         template < typename T >
  65.         Filterbank<T>::Filterbank()
  66.         {
  67.    
  68.         }
  69.  
  70.         template < typename T >
  71.         Filterbank<T>::Filterbank( Filterbank<T> && other)
  72.             :m_Bank(std::move(other.m_Bank))
  73.         {
  74.    
  75.         }
  76.  
  77.         template < typename T >
  78.         Filterbank<T>::~Filterbank()
  79.         {
  80.    
  81.         }
  82.  
  83.  
  84.         template < typename T >
  85.         void swap( Filterbank<T> & bank_a, Filterbank<T> & bank_b ){
  86.             bank_a.m_Bank.swap(bank_b.m_Bank);
  87.         }
  88.  
  89.         template < typename T >
  90.         Filterbank<T> & Filterbank<T>::operator =( Filterbank<T> && bank ){
  91.  
  92.             //bank.swap(*this);
  93.             m_Bank = std::move(bank.m_Bank);
  94.             return (*this);
  95.         }
  96.  
  97.         template < typename T >
  98.         const std::unique_ptr<Kernel2D<T> > & Filterbank<T>::at( int index ) const{
  99.             return m_Bank[index];
  100.         }
  101.  
  102.         template < typename T >
  103.         int Filterbank<T>::size() const{
  104.             return static_cast<int>(m_Bank.size());
  105.         }
  106.  
  107.    
  108.  
  109.         // explicit instantiations
  110.         template class Filterbank<float>;
  111.         template class Filterbank<double>;
  112.  
  113.         template void swap ( Filterbank<float> &, Filterbank<float> & );
  114.         template void swap ( Filterbank<double> &, Filterbank<double> & );
  115.     }
  116.  
  117.     namespace khipu{
  118. //filterbankdescriptor.cpp
  119.         template < typename T >
  120.         FilterbankDescriptor<T>::FilterbankDescriptor(){
  121.  
  122.         }
  123.  
  124.         template < typename T >
  125.         FilterbankDescriptor<T>::FilterbankDescriptor( const Filterbank<T> &  bank )
  126.             :m_Bank(bank)
  127.         {
  128.  
  129.         }
  130.  
  131.         template < typename T >
  132.         FilterbankDescriptor<T>::FilterbankDescriptor( const FilterbankDescriptor<T> & filterbankDesc )
  133.             :m_Bank(filterbankDesc.m_Bank)
  134.         {
  135.  
  136.         }
  137.  
  138.         template < typename T >
  139.         FilterbankDescriptor<T>::FilterbankDescriptor( FilterbankDescriptor<T> && other )
  140.             :m_Bank(std::move(other.m_Bank))
  141.         {
  142.    
  143.         }
  144.  
  145.         template < typename T >
  146.         FilterbankDescriptor<T>::~FilterbankDescriptor(){
  147.        
  148.         }
  149.  
  150.         template < typename T >
  151.         std::unique_ptr<Descriptor<T> > FilterbankDescriptor<T>::clone() const{
  152.             return std::unique_ptr<Descriptor<T> >( new FilterbankDescriptor<T>(*this) );
  153.         }
  154.        
  155.         template < typename T >
  156.         std::unique_ptr<Descriptor<T> > FilterbankDescriptor<T>::create() const{
  157.             return std::unique_ptr<Descriptor<T> >( new FilterbankDescriptor<T>( ) );
  158.         }
  159.  
  160.         template < typename T >
  161.         FeatureImage<T> FilterbankDescriptor<T>::describe(const Matrix<T> & refMatrix, const std::string & strOutput ) const{
  162.        
  163.             int nRows      = refMatrix.getRows();
  164.             int nCols      = refMatrix.getCols();
  165.             int nChannels  = refMatrix.getChannels();
  166.             int nBankSize  = m_Bank.size();
  167.             int nDepth     = nChannels * nBankSize;
  168.        
  169.             int nFeatIndex = 0;
  170.             int nIdx = 0;
  171.  
  172.             FeatureImage<T> featImage(nRows, nCols, nDepth);
  173.  
  174.             return (featImage);
  175.         }
  176.        
  177.         template < typename T >
  178.         FeatureImage<T> FilterbankDescriptor<T>::describe(const FeatureImage<T> & refFeatImage, const std::string & strOutput ) const{
  179.            
  180.             int nRows      = refFeatImage.getHeight();
  181.             int nCols      = refFeatImage.getWidth();
  182.             int nChannels  = refFeatImage.getDepth();
  183.             int nBankSize  = m_Bank.size();
  184.             int nDepth     = nChannels * nBankSize;
  185.        
  186.             int nFeatIndex = 0;
  187.             int nIdx = 0;
  188.  
  189.             FeatureImage<T> featImage(nRows, nCols, nDepth);
  190.  
  191.             return (featImage);
  192.         }
  193.  
  194.         template class FilterbankDescriptor<float>;
  195.         template class FilterbankDescriptor<double>;
  196.     }
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement