CPatch: New memory management
[TortoiseGit.git] / src / Utils / BugTraqAssociations.h
blobc4d992ec73c450e06b361dfaaae3065e581aae37
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009, 2014, 2016-2017 - 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;
36 bool m_enabled;
38 public:
39 CBugTraqAssociation()
40 : m_enabled(true)
42 m_provider.clsid = GUID_NULL;
45 CBugTraqAssociation(LPCTSTR szWorkingCopy, const CLSID &provider_clsid, LPCTSTR szProviderName, LPCTSTR szParameters, bool enabled)
46 : m_path(szWorkingCopy), m_parameters(szParameters), m_enabled(enabled)
48 m_provider.clsid = provider_clsid;
49 m_provider.name = szProviderName;
52 const CTGitPath &GetPath() const { return m_path; }
53 CString GetProviderName() const { return m_provider.name; }
54 CLSID GetProviderClass() const { return m_provider.clsid; }
55 CString GetProviderClassAsString() const;
56 CString GetParameters() const { return m_parameters; }
57 bool IsEnabled() const { return m_enabled; }
58 bool SetEnabled(bool enabled) { if (m_enabled == enabled) { return false; } m_enabled = enabled; return true; }
61 class CBugTraqAssociations
63 typedef std::vector< CBugTraqAssociation * > inner_t;
64 inner_t m_inner;
66 public:
67 CBugTraqAssociations();
68 ~CBugTraqAssociations();
70 void Load(LPCTSTR uuid = nullptr, LPCTSTR params = nullptr);
71 void Save() const;
73 void Add(const CBugTraqAssociation &assoc);
74 void Remove(CBugTraqAssociation* assoc);
76 bool FindProvider(const CString &path, CBugTraqAssociation *assoc);
78 typedef inner_t::const_iterator const_iterator;
79 const_iterator begin() const { return m_inner.begin(); }
80 const_iterator end() const { return m_inner.end(); }
82 static std::vector<CBugTraqProvider> GetAvailableProviders();
83 static CString LookupProviderName(const CLSID &provider_clsid);
85 private:
86 bool FindProviderForPath(const CTGitPath& path, CBugTraqAssociation *assoc) const;
88 struct FindByPathPred
90 const CTGitPath &m_path;
92 FindByPathPred(const CTGitPath &path)
93 : m_path(path) { }
95 bool operator() (const CBugTraqAssociation *assoc) const
97 return (assoc->GetPath().IsEquivalentToWithoutCase(m_path));
100 CString providerUUID;
101 CString providerParams;
102 CBugTraqAssociation * pProjectProvider;