summaryrefslogtreecommitdiff
path: root/indra/newview/llfilteredpathfindinglinksets.h
blob: 388818c32b1995d703136b1b75b9b359f167ab2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/** 
 * @file llfilteredpathfindinglinksets.h
 * @author William Todd Stinson
 * @brief Class to implement the filtering of a set of pathfinding linksets
 *
 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2010, Linden Research, Inc.
 * 
 * This library 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;
 * version 2.1 of the License only.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

#ifndef LL_FILTEREDPATHFINDINGLINKSETS_H
#define LL_FILTEREDPATHFINDINGLINKSETS_H

#include <string>
#include <map>
#include "llpathfindinglinkset.h"

class LLSD;

class FilterString
{
public:
	FilterString();
	FilterString(const std::string& pFilter);
	virtual ~FilterString();

	const std::string& get() const;
	bool               set(const std::string& pFilter);
	void               clear();

	bool               isActive() const;
	bool               doesMatch(const std::string& pTestString) const;

protected:

private:
	std::string mFilter;
	std::string mUpperFilter;
};

class LLFilteredPathfindingLinksets
{
public:
	typedef std::map<std::string, LLPathfindingLinkset> PathfindingLinksetMap;

	LLFilteredPathfindingLinksets();
	LLFilteredPathfindingLinksets(const LLSD& pLinksetItems);
	LLFilteredPathfindingLinksets(const LLFilteredPathfindingLinksets& pOther);
	virtual ~LLFilteredPathfindingLinksets();

	void                         setPathfindingLinksets(const LLSD& pLinksetItems);
	void                         updatePathfindingLinksets(const LLSD& pLinksetItems);
	void                         clearPathfindingLinksets();

	const PathfindingLinksetMap& getAllLinksets() const;
	const PathfindingLinksetMap& getFilteredLinksets();

	BOOL                         isFiltersActive() const;

	void                         setNameFilter(const std::string& pNameFilter);
	const std::string&           getNameFilter() const;

	void                         setDescriptionFilter(const std::string& pDescriptionFilter);
	const std::string&           getDescriptionFilter() const;

	void                              setLinksetUseFilter(LLPathfindingLinkset::ELinksetUse pLinksetUse);
	LLPathfindingLinkset::ELinksetUse getLinksetUseFilter() const;

	void                         clearFilters();

protected:

private:
	PathfindingLinksetMap mAllLinksets;
	PathfindingLinksetMap mFilteredLinksets;

	bool                              mIsFiltersDirty;
	FilterString                      mNameFilter;
	FilterString                      mDescriptionFilter;
	LLPathfindingLinkset::ELinksetUse mLinksetUseFilter;

	void applyFilters();
	BOOL doesMatchFilters(const LLPathfindingLinkset& pLinkset) const;
};

#endif // LL_FILTEREDPATHFINDINGLINKSETS_H