Skip to content
Snippets Groups Projects
Commit e1c4eba6 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Add class SuccessBin

parent 3a28c5ef
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ ENDIF() ...@@ -37,6 +37,7 @@ ENDIF()
SET (${PROJECT_NAME}_HEADERS SET (${PROJECT_NAME}_HEADERS
include/hpp/statistics/bin.hh include/hpp/statistics/bin.hh
include/hpp/statistics/success-bin.hh
) )
# Add dependency toward hpp-model library in pkg-config file. # Add dependency toward hpp-model library in pkg-config file.
......
// Copyright (c) 2014, LAAS-CNRS
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
//
// This file is part of hpp-statistics.
// hpp-statistics 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 of the License, or (at your option) any later version.
//
// hpp-statistics 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
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-statistics. If not, see <http://www.gnu.org/licenses/>.
#ifndef HPP_MANIPULATION_GRAPH_STATISTICS_HH
# define HPP_MANIPULATION_GRAPH_STATISTICS_HH
# include <ostream>
# include <hpp/statistics/config.hh>
# include "hpp/statistics/bin.hh"
namespace hpp {
namespace statistics {
/// This class count the number of success and failure.
class HPP_STATISTICS_DLLAPI SuccessBin : public Bin
{
public:
/// Constructor
SuccessBin (const bool success);
/// Value of the bin.
/// \return True is it counts "success", False otherwise.
bool isSuccess () const;
/// Add an occurence
/// \return The frequency after increment;
size_t operator ++();
/// Add an occurence
/// \return The frequency before increment;
size_t operator ++(int);
/// \return The number of element in the bin.
size_t freq () const;
private:
bool success_;
size_t freq_;
std::ostream& printValue (std::ostream& os) const;
};
} // namespace statistics
} // namespace hpp
#endif // HPP_MANIPULATION_GRAPH_STATISTICS_HH
...@@ -21,6 +21,7 @@ SET(LIBRARY_NAME ${PROJECT_NAME}) ...@@ -21,6 +21,7 @@ SET(LIBRARY_NAME ${PROJECT_NAME})
ADD_LIBRARY(${LIBRARY_NAME} SHARED ADD_LIBRARY(${LIBRARY_NAME} SHARED
bin.cc bin.cc
success-bin.cc
) )
INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION lib) INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION lib)
// Copyright (c) 2014, LAAS-CNRS
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
//
// This file is part of hpp-statistics.
// hpp-statistics 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 of the License, or (at your option) any later version.
//
// hpp-statistics 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
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-statistics. If not, see <http://www.gnu.org/licenses/>.
#include "hpp/statistics/success-bin.hh"
namespace hpp {
namespace statistics {
SuccessBin::SuccessBin (const bool success) :
success_ (success), freq_ (0)
{}
bool SuccessBin::isSuccess () const
{
return success_;
}
size_t SuccessBin::freq () const
{
return freq_;
}
size_t SuccessBin::operator ++()
{
return ++freq_;
}
size_t SuccessBin::operator ++(int)
{
return freq_++;
}
std::ostream& SuccessBin::printValue (std::ostream& os) const
{
os << "Event ";
if (success_) os << "'Success'";
else os << "'Failure'";
return os;
}
} // namespace statistics
} // namespace hpp
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment