*.js files: keep the style consistent
[TortoiseGit.git] / src / Utils / BugTraqAssociations.h
blob44836a6bf22d01d08a8a00287741e3f479c7c827
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
20 #include "TGitPath.h"
22 struct CBugTraqProvider
24 CLSID clsid;
25 CString name;
28 /* TODO: It's less of an association and more of a "token" or "memento".
30 class CBugTraqAssociation
32 CTGitPath m_path;
33 CBugTraqProvider m_provider;
34 CString m_parameters;
36 public:
37 CBugTraqAssociation()
39 m_provider.clsid = GUID_NULL;
42 CBugTraqAssociation(LPCTSTR szWorkingCopy, const CLSID &provider_clsid, LPCTSTR szProviderName, LPCTSTR szParameters)
43 : m_path(szWorkingCopy), m_parameters(szParameters)
45 m_provider.clsid = provider_clsid;
46 m_provider.name = szProviderName;
49 const CTGitPath &GetPath() const { return m_path; }
50 CString GetProviderName() const { return m_provider.name; }
51 CLSID GetProviderClass() const { return m_provider.clsid; }
52 CString GetProviderClassAsString() const;
53 CString GetParameters() const { return m_parameters; }
56 class CBugTraqAssociations
58 typedef std::vector< CBugTraqAssociation * > inner_t;
59 inner_t m_inner;
61 public:
62 ~CBugTraqAssociations();
64 void Load();
65 void Save() const;
67 void Add(const CBugTraqAssociation &assoc);
68 void RemoveByPath(const CTGitPath &path);
70 bool FindProvider(const CTGitPathList &pathList, CBugTraqAssociation *assoc) const;
71 bool FindProvider(const CString &path, CBugTraqAssociation *assoc) const;
73 typedef inner_t::const_iterator const_iterator;
74 const_iterator begin() const { return m_inner.begin(); }
75 const_iterator end() const { return m_inner.end(); }
77 static std::vector<CBugTraqProvider> GetAvailableProviders();
78 static CString LookupProviderName(const CLSID &provider_clsid);
80 private:
81 bool FindProviderForPathList(const CTGitPathList &pathList, CBugTraqAssociation *assoc) const;
82 bool FindProviderForPath(CTGitPath path, CBugTraqAssociation *assoc) const;
84 struct FindByPathPred
86 const CTGitPath &m_path;
88 FindByPathPred(const CTGitPath &path)
89 : m_path(path) { }
91 bool operator() (const CBugTraqAssociation *assoc) const
93 return (assoc->GetPath().IsEquivalentToWithoutCase(m_path));