/* * mp_AUResults.h * * Author: Andrew Salamon * Date: Tue Jan 16, 2007 * * Copyright (c) 2007 Machine Perception Laboratory * University of California San Diego. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef __MP_AURESULTS_H__ #define __MP_AURESULTS_H__ #include #include #include /** A container class for holding the results of an AU calculation. * It holds intermediate (frequency) results as well as the final result. */ class mp_AUResults { public: mp_AUResults(); mp_AUResults( const std::string &_name, unsigned int auCount ); mp_AUResults( const std::string &_name, std::vector &_auResults, std::vector< std::vector > &_frequencies ); mp_AUResults( const mp_AUResults &other ); ~mp_AUResults(); void addFrequency( unsigned int ni, unsigned int mu, std::vector &step ); void clear(); std::string getName() const { return name; } std::vector getAUResults() const; std::vector frequenciesForAUIndex( unsigned int index ) const; mp_AUResults &operator=( const mp_AUResults &other ); mp_AUResults operator+( const mp_AUResults &other ); mp_AUResults &operator+=( const mp_AUResults &other ); friend std::ostream &operator<<( std::ostream &os, const mp_AUResults &res ); friend bool operator==( const mp_AUResults& lhs, const mp_AUResults& rhs ); typedef enum { unknown = -1, begin = 0, text = begin, binary, xml, end } filetype; static std::string extensionForFiletype( filetype ftype ); static filetype filetypeFromName( const std::string &filename ); void save( std::ostream &os, filetype type = xml ); void restore( std::istream &is, filetype type = xml ); private: std::string name; std::vector auResults; std::vector< std::vector > frequencies; unsigned int indexForNIMU( unsigned int ni, unsigned int mu ); void initVectorSizes( unsigned int auCount ); }; #endif