OSDN Git Service

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