Fixed c&p error: Usage of wrong path
[TortoiseGit.git] / src / Utils / BugTraqAssociations.h
blob97e29dd858f8c5939b3c1aa956a0782f2a394cf4
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009,2014 - TortoiseGit
4 // Copyright (C) 2008,2013 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
21 #include "TGitPath.h"
23 struct CBugTraqProvider
25 CLSID clsid;
26 CString name;
29 /* TODO: It's less of an association and more of a "token" or "memento".
31 class CBugTraqAssociation
33 CTGitPath m_path;
34 CBugTraqProvider m_provider;
35 CString m_parameters;
37 public:
38 CBugTraqAssociation()
40 m_provider.clsid = GUID_NULL;
43 CBugTraqAssociation(LPCTSTR szWorkingCopy, const CLSID &provider_clsid, LPCTSTR szProviderName, LPCTSTR szParameters)
44 : m_path(szWorkingCopy), m_parameters(szParameters)
46 m_provider.clsid = provider_clsid;
47 m_provider.name = szProviderName;
50 const CTGitPath &GetPath() const { return m_path; }
51 CString GetProviderName() const { return m_provider.name; }
52 CLSID GetProviderClass() const { return m_provider.clsid; }
53 CString GetProviderClassAsString() const;
54 CString GetParameters() const { return m_parameters; }
57 class CBugTraqAssociations
59 typedef std::vector< CBugTraqAssociation * > inner_t;
60 inner_t m_inner;
62 public:
63 CBugTraqAssociations();
64 ~CBugTraqAssociations();
66 void Load(LPCTSTR uuid = nullptr, LPCTSTR params = nullptr);
67 void Save() const;
69 void Add(const CBugTraqAssociation &assoc);
70 void RemoveByPath(const CTGitPath &path);
72 bool FindProvider(const CString &path, CBugTraqAssociation *assoc);
74 typedef inner_t::const_iterator const_iterator;
75 const_iterator begin() const { return m_inner.begin(); }
76 const_iterator end() const { return m_inner.end(); }
78 static std::vector<CBugTraqProvider> GetAvailableProviders();
79 static CString LookupProviderName(const CLSID &provider_clsid);
81 private:
82 bool FindProviderForPath(const 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));
96 CString providerUUID;
97 CString providerParams;
98 CBugTraqAssociation * pProjectProvider;