-
Notifications
You must be signed in to change notification settings - Fork 51
/
CWriterComponent.h
201 lines (165 loc) · 4.74 KB
/
CWriterComponent.h
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/*
Copyright (c) 2011 Wangdera Corporation ([email protected])
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
using namespace std;
#include "CHoboCopyException.h"
#include "Utilities.h"
class CWriterComponent
{
private:
CString _logicalPath;
bool _logicalPathParsed;
CString _name;
CWriterComponent* _pParent;
// vector<CString> _pathComponents;
bool _selectableForBackup;
VSS_COMPONENT_TYPE _type;
int _writer;
public:
CWriterComponent::CWriterComponent()
{
_pParent = NULL;
}
bool get_HasSelectableAncestor(void)
{
if (_pParent == NULL)
{
return false;
}
if (_pParent->get_SelectableForBackup())
{
return true;
}
return _pParent->get_HasSelectableAncestor();
}
CString get_LogicalPath(void)
{
return _logicalPath;
}
void set_LogicalPath(CString logicalPath)
{
_logicalPath = logicalPath;
_logicalPathParsed = false;
}
CString get_Name(void)
{
return _name;
}
void set_Name(CString value)
{
_name = value;
}
CWriterComponent* get_Parent(void)
{
return _pParent;
}
void set_Parent(CWriterComponent* value)
{
_pParent = value;
}
bool get_SelectableForBackup(void)
{
return _selectableForBackup;
}
void set_SelectableForBackup(bool selectableForBackup)
{
_selectableForBackup = selectableForBackup;
}
VSS_COMPONENT_TYPE get_Type(void)
{
return _type;
}
void set_Type(VSS_COMPONENT_TYPE value)
{
_type = value;
}
int get_Writer(void)
{
return _writer;
}
void set_Writer(int writer)
{
_writer = writer;
}
/*
bool IsAncestorOf(CWriterComponent& potentialDescendant)
{
ParseLogicalPath();
potentialDescendant.ParseLogicalPath();
if (_pathComponents.size() >= potentialDescendant._pathComponents.size())
{
return false;
}
for (unsigned int iPathComponent = 0;
iPathComponent < _pathComponents.size();
++iPathComponent)
{
if (potentialDescendant._pathComponents[iPathComponent].Compare(_pathComponents[iPathComponent]) != 0)
{
return false;
}
}
return true;
}
*/
bool IsParentOf(CWriterComponent& potentialParent)
{
// The other component is our parent if our logical path is equal to
// their logical path plus their name.
CString pathToCompare = potentialParent.get_LogicalPath();
if (pathToCompare.GetLength() > 0)
{
pathToCompare.Append(TEXT("\\"));
}
pathToCompare.Append(potentialParent.get_Name());
return get_LogicalPath().Compare(pathToCompare) == 0;
}
private:
/*
void ParseLogicalPath()
{
if (_logicalPathParsed)
{
return;
}
_logicalPathParsed = true;
_pathComponents.clear();
_pathComponents.push_back(TEXT(""));
if (_logicalPath.IsEmpty())
{
return;
}
bool done = false;
int start = 0;
while (!done)
{
CString component = _logicalPath.Tokenize(TEXT("\\"), start);
if (start == -1)
{
done = true;
}
else
{
_pathComponents.push_back(component);
}
}
}
*/
};