//=============================== // // Implementation for image library class // #include #include #include "Image.h" #include "ImageLibrary.h" // --------------------------------- // Constructor ImageLibrary::ImageLibrary( std::vector images ) { // Really you would copy the images rather than rely on the pointers // but students would not be expected to do this. m_images = images ; } // --------------------------- // To return all images std::vector ImageLibrary::image( ) { return m_images ; } // ---------------------- // Number of images in library int ImageLibrary::size() { return m_images.size() ; } // --------------------------- // To return an image by date Image* ImageLibrary::image( int date ) { for( int ind=0; ind < m_images.size(); ++ind ) { if( m_images[ind]->date() == date ) return m_images[ind] ; } return NULL ; } // --------------------------- // To return a set of images witihn a date range std::vector ImageLibrary::image( int d1 , int d2 ) { std::vector images; for( int ind=0; ind < m_images.size(); ++ind ) { if( ( d1 <= m_images[ind]->date() ) && ( m_images[ind]->date() <= d2 ) ) images.push_back( m_images[ind] ) ; } return images ; }