2013-11-14 11:48:37 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2013 Statoil ASA.
|
|
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
OPM 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 Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef GROUPTREE_HPP
|
2016-11-07 14:25:00 +01:00
|
|
|
#define GROUPTREE_HPP
|
2013-11-14 11:48:37 +01:00
|
|
|
|
|
|
|
|
#include <string>
|
2014-02-10 12:18:42 +01:00
|
|
|
#include <vector>
|
2013-11-14 11:48:37 +01:00
|
|
|
|
|
|
|
|
namespace Opm {
|
|
|
|
|
|
2016-11-07 14:25:00 +01:00
|
|
|
class GroupTree {
|
2013-11-14 11:48:37 +01:00
|
|
|
public:
|
2016-11-07 14:25:00 +01:00
|
|
|
void update( const std::string& name );
|
|
|
|
|
void update( const std::string& name, const std::string& parent );
|
|
|
|
|
bool exists( const std::string& group ) const;
|
|
|
|
|
const std::string& parent( const std::string& name ) const;
|
|
|
|
|
std::vector< std::string > children( const std::string& parent ) const;
|
2013-11-14 11:48:37 +01:00
|
|
|
|
2016-11-07 14:25:00 +01:00
|
|
|
bool operator==( const GroupTree& ) const;
|
|
|
|
|
bool operator!=( const GroupTree& ) const;
|
2013-11-20 13:48:55 +01:00
|
|
|
|
2016-11-07 14:25:00 +01:00
|
|
|
private:
|
|
|
|
|
struct group {
|
|
|
|
|
std::string name;
|
|
|
|
|
std::string parent;
|
2013-11-14 16:05:13 +01:00
|
|
|
|
2016-11-07 14:25:00 +01:00
|
|
|
bool operator<( const group& rhs ) const;
|
|
|
|
|
bool operator==( const std::string& name ) const;
|
|
|
|
|
bool operator!=( const std::string& name ) const;
|
2016-10-05 10:34:58 +02:00
|
|
|
|
2016-11-07 14:25:00 +01:00
|
|
|
bool operator<( const std::string& name ) const;
|
|
|
|
|
bool operator==( const group& rhs ) const;
|
|
|
|
|
bool operator!=( const group& rhs ) const;
|
|
|
|
|
};
|
2016-10-05 10:34:58 +02:00
|
|
|
|
2016-11-07 14:25:00 +01:00
|
|
|
std::vector< group > groups = { group { "FIELD", "" } };
|
|
|
|
|
friend bool operator<( const std::string&, const group& );
|
|
|
|
|
std::vector< group >::iterator find( const std::string& );
|
|
|
|
|
};
|
2013-11-14 11:48:37 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 14:25:00 +01:00
|
|
|
#endif /* GROUPTREE_HPP */
|
2013-11-14 11:48:37 +01:00
|
|
|
|