1 // SSVersionObject.h: interface for the SSActions class.
3 //////////////////////////////////////////////////////////////////////
5 #if !defined(AFX_SSHISTORYOBJECT_H__58F12C7C_FE74_43B1_9BF6_9E803182D8D7__INCLUDED_)
6 #define AFX_SSHISTORYOBJECT_H__58F12C7C_FE74_43B1_9BF6_9E803182D8D7__INCLUDED_
10 #endif // _MSC_VER > 1000
13 #include "SSCommentObject.h"
18 class SSLabeledAction
; // Labeled = 0,
19 class SSCreatedProjectAction
; // Created_Project = 1,
20 class SSAddedProjectAction
; // Added_Project = 2,
21 class SSAddedFileAction
; // Added_File = 3,
22 class SSDestroyedProjectAction
; // Destroyed_Project = 4,
23 class SSDestroyedFileAction
; // Destroyed_File = 5,
24 class SSDeletedProjectAction
; // Deleted_Project = 6,
25 class SSDeletedFileAction
; // Deleted_File = 7,
26 class SSRecoveredProjectAction
; // Recovered_Project = 8,
27 class SSRecoveredFileAction
; // Recovered_File = 9,
28 class SSRenamedProjectAction
; // Renamed_Project = 10,
29 class SSRenamedFileAction
; // Renamed_File = 11,
30 //class SSAction12 // missing action 12,
31 //class SSAction13 // missing action 13
32 class SSSharedAction
; // Shared_File = 14,
33 class SSRollbackAction
; // RollBack_File = 15,
34 class SSCreatedFileAction
; // Created_File = 16,
35 class SSCheckedInAction
; // Checked_in = 17,
36 //class SSAction18 // missing action 18
37 //class SSRollBackAction // RollBack = 19
39 class ISSActionVisitor
42 virtual bool Apply (const SSLabeledAction
& rAction
) = 0;
43 virtual bool Apply (const SSCreatedProjectAction
& rAction
) = 0;
44 virtual bool Apply (const SSCreatedFileAction
& rAction
) = 0;
45 virtual bool Apply (const SSAddedProjectAction
& rAction
) = 0;
46 virtual bool Apply (const SSAddedFileAction
& rAction
) = 0;
47 virtual bool Apply (const SSDeletedProjectAction
& rAction
) = 0;
48 virtual bool Apply (const SSDeletedFileAction
& rAction
) = 0;
49 virtual bool Apply (const SSRecoveredProjectAction
& rAction
) = 0;
50 virtual bool Apply (const SSRecoveredFileAction
& rAction
) = 0;
51 virtual bool Apply (const SSRollbackAction
& rAction
) = 0;
53 virtual bool Apply (const SSDestroyedProjectAction
& rAction
) = 0;
54 virtual bool Apply (const SSDestroyedFileAction
& rAction
) = 0;
55 virtual bool Apply (const SSRenamedProjectAction
& rAction
) = 0;
56 virtual bool Apply (const SSRenamedFileAction
& rAction
) = 0;
57 virtual bool Apply (const SSCheckedInAction
& rAction
) = 0;
58 virtual bool Apply (const SSSharedAction
& rAction
) = 0;
61 //---------------------------------------------------------------------------
65 SSAction (SSRecordPtr pRecord
);
68 static SSAction
* MakeAction (SSRecordPtr pRecord
);
70 eAction
GetActionID () const { return m_ActionId
; }
72 virtual std::string
FormatActionString () = 0;
73 virtual bool Accept (ISSActionVisitor
& rVisitor
) = 0;
75 virtual void ToXml (XMLNode
* pParent
) const = 0;
76 virtual void Dump (std::ostream
& os
) const;
79 const VERSION_RECORD
* GetHistoryRecordPtr (SSRecordPtr pRecord
) const;
83 //---------------------------------------------------------------------------
84 class SSVersionObject
: public SSObject
87 SSVersionObject (SSRecordPtr pRecord
);
88 virtual ~SSVersionObject ();
90 // handle copy constructor und assigment
91 SSVersionObject (SSVersionObject
& object
);
92 SSVersionObject
& operator= (SSVersionObject
const & object
);
94 // BOOST_PP_SEQ_FOR_EACH(DEFINE_ACCESSORS, GetData(), VERSION_RECORD_SEQ);
95 ulong
GetPrevious () const { return GetData ()->Previous
; }
96 eAction
GetActionID () const { return static_cast <eAction
> (GetData ()->ActionID
); }
97 short GetVersionNumber () const { return GetData ()->VersionNumber
; }
98 time_t GetDate () const { return GetData ()->Date
; }
99 std::string
GetUsername () const { return std::string (GetData ()->Username
, 32); }
100 std::string
GetLabel () const { return std::string (GetData ()->Label
, 32); }
101 ulong
GetOffsetToNextRecordOrComment () const { return GetData ()->OffsetToNextRecordOrComment
; }
102 ulong
GetOffsetToLabelComment () const { return GetData ()->OffsetToLabelComment
; }
103 short GetLengthComment () const { return GetData ()->LengthComment
; }
104 short GetLengthLabelComment () const { return GetData ()->LengthLabelComment
; }
106 // std::string GetUsername () const { return GetData ()->user; }
107 // int GetVersionNumber () const { return GetData ()->version; }
108 // eAction GetActionId () const { return static_cast <eAction> (GetData ()->action); }
109 std::string
GetActionString () const { return m_pAction
? m_pAction
->FormatActionString () : CAction::ActionToString (GetActionID()); }
110 // time_t GetDate () const { return GetData ()->date; }
111 std::string
GetComment () const;
113 // special Label Action functions
114 // std::string GetLabel () const;
115 std::string
GetLabelComment () const;
117 // reporting functions
118 virtual void Accept (ISSObjectVisitor
& rVisitor
, const ISSContext
* pCtx
= NULL
) const { rVisitor
.Apply (*this, pCtx
); }
120 const VERSION_RECORD
* GetData () const { return (const VERSION_RECORD
*) SSObject::GetData (); }
122 SSAction
* GetAction () const { return m_pAction
; }
123 SSVersionObject
GetPreviousObject () const;
124 SSCommentObject
GetCommentObject () const;
126 virtual bool Validate ();
128 virtual void ToXml (XMLNode
* pParent
) const;
129 virtual void Dump (std::ostream
& os
) const;
137 //---------------------------------------------------------------------------
138 template <class ACTION
>
139 class SSActionEx
: public SSAction
142 SSActionEx (SSRecordPtr pRecord
)
147 bool Accept (ISSActionVisitor
& rVisitor
)
149 return rVisitor
.Apply(*This());
152 // return a pointer to the most derived class
155 return static_cast<ACTION
*>(this);
160 //---------------------------------------------------------------------------
161 class SSLabeledAction
: public SSActionEx
<SSLabeledAction
>
164 SSLabeledAction (SSRecordPtr pRecord
);
165 virtual ~SSLabeledAction ();
167 std::string
GetLabel () const { return m_Label
; }
168 std::string
GetLabelComment () const { return m_LabelComment
; }
170 virtual std::string
FormatActionString ();
172 virtual void ToXml (XMLNode
* pParent
) const;
173 virtual void Dump (std::ostream
& os
) const;
177 std::string m_LabelComment
;
180 //---------------------------------------------------------------------------
184 virtual std::string
GetPhysical () const = 0;
185 virtual SSName
GetSSName () const = 0;
188 //---------------------------------------------------------------------------
189 template <class ACTION
, class STRUCT
>
190 class SSItemAction
: public SSActionEx
<ACTION
>, public ISSItemAction
193 SSItemAction (SSRecordPtr pRecord
, std::string actionString
);
195 std::string
GetPhysical () const { return std::string (m_Action
.physical
, 8); }
196 SSName
GetSSName () const { return m_Action
.name
; }
198 std::string
GetName () const { SSName
name (GetSSName ()); return name
.GetFullName (); }
200 virtual std::string
FormatActionString ();
202 virtual void ToXml (XMLNode
* pParent
) const;
203 virtual void Dump (std::ostream
& os
) const;
207 std::string m_ActionString
;
210 class SSCreatedProjectAction
: public SSItemAction
<SSCreatedProjectAction
, ITEM_ACTION
>
213 SSCreatedProjectAction (SSRecordPtr pRecord
)
214 : SSItemAction
<SSCreatedProjectAction
, ITEM_ACTION
> (pRecord
, "Created Project $")
219 class SSCreatedFileAction
: public SSItemAction
<SSCreatedFileAction
, ITEM_ACTION
>
222 SSCreatedFileAction (SSRecordPtr pRecord
)
223 : SSItemAction
<SSCreatedFileAction
, ITEM_ACTION
> (pRecord
, "Created File ")
228 class SSAddedProjectAction
: public SSItemAction
<SSAddedProjectAction
, ITEM_ACTION
>
231 SSAddedProjectAction (SSRecordPtr pRecord
)
232 : SSItemAction
<SSAddedProjectAction
, ITEM_ACTION
> (pRecord
, "Added Project $")
237 class SSAddedFileAction
: public SSItemAction
<SSAddedFileAction
, ITEM_ACTION
>
240 SSAddedFileAction (SSRecordPtr pRecord
)
241 : SSItemAction
<SSAddedFileAction
, ITEM_ACTION
> (pRecord
, "Added File ")
246 class SSDeletedProjectAction
: public SSItemAction
<SSDeletedProjectAction
, ITEM_ACTION
>
249 SSDeletedProjectAction (SSRecordPtr pRecord
)
250 : SSItemAction
<SSDeletedProjectAction
, ITEM_ACTION
> (pRecord
, "Deleted Project $")
255 class SSDeletedFileAction
: public SSItemAction
<SSDeletedFileAction
, ITEM_ACTION
>
258 SSDeletedFileAction (SSRecordPtr pRecord
)
259 : SSItemAction
<SSDeletedFileAction
, ITEM_ACTION
> (pRecord
, "Deleted File ")
264 class SSRecoveredProjectAction
: public SSItemAction
<SSRecoveredProjectAction
, ITEM_ACTION
>
267 SSRecoveredProjectAction (SSRecordPtr pRecord
)
268 : SSItemAction
<SSRecoveredProjectAction
, ITEM_ACTION
> (pRecord
, "Recovered Project ")
273 class SSRecoveredFileAction
: public SSItemAction
<SSRecoveredFileAction
, ITEM_ACTION
>
276 SSRecoveredFileAction (SSRecordPtr pRecord
)
277 : SSItemAction
<SSRecoveredFileAction
, ITEM_ACTION
> (pRecord
, "Recovered File ")
282 //---------------------------------------------------------------------------
283 class SSRollbackAction
: public SSItemAction
<SSRollbackAction
, ROLLBACK_ACTION
>
286 SSRollbackAction (SSRecordPtr pRecord
)
287 : SSItemAction
<SSRollbackAction
, ROLLBACK_ACTION
> (pRecord
, "Rolled back ")
291 std::string
GetParent () const { return std::string (m_Action
.parent
, 8); }
293 virtual void ToXml (XMLNode
* pParent
) const;
294 virtual void Dump (std::ostream
& os
) const;
297 //---------------------------------------------------------------------------
299 template <class ACTION
>
300 class SSDestroyedAction
: public SSItemAction
<ACTION
, DESTROYED_ACTION
>
303 SSDestroyedAction (SSRecordPtr pRecord
, std::string prefix
);
305 virtual std::string
FormatActionString ();
308 std::string m_Prefix
;
311 class SSDestroyedProjectAction
: public SSDestroyedAction
<SSDestroyedProjectAction
>
314 SSDestroyedProjectAction (SSRecordPtr pRecord
)
315 : SSDestroyedAction
<SSDestroyedProjectAction
> (pRecord
, "$")
319 class SSDestroyedFileAction
: public SSDestroyedAction
<SSDestroyedFileAction
>
322 SSDestroyedFileAction (SSRecordPtr pRecord
)
323 : SSDestroyedAction
<SSDestroyedFileAction
> (pRecord
, "")
328 //---------------------------------------------------------------------------
330 template <class ACTION
>
331 class SSRenamedAction
: public SSItemAction
<ACTION
, RENAMED_ACTION
>
334 SSRenamedAction (SSRecordPtr pRecord
, std::string prefix
);
336 std::string
GetNewName () const { SSName
name (m_Action
.newName
); return name
.GetFullName (); }
337 SSName
GetNewSSName () const { return m_Action
.newName
; }
339 virtual std::string
FormatActionString ();
341 virtual void ToXml (XMLNode
* pParent
) const;
342 virtual void Dump (std::ostream
& os
) const;
345 std::string m_Prefix
;
348 class SSRenamedProjectAction
: public SSRenamedAction
<SSRenamedProjectAction
>
351 SSRenamedProjectAction (SSRecordPtr pRecord
)
352 : SSRenamedAction
<SSRenamedProjectAction
> (pRecord
, "$")
356 class SSRenamedFileAction
: public SSRenamedAction
<SSRenamedFileAction
>
359 SSRenamedFileAction (SSRecordPtr pRecord
)
360 : SSRenamedAction
<SSRenamedFileAction
> (pRecord
, "")
364 //---------------------------------------------------------------------------
366 class SSCheckedInAction
: public SSActionEx
<SSCheckedInAction
>
369 SSCheckedInAction ( SSRecordPtr pRecord
);
370 ~SSCheckedInAction ();
372 std::string
GetFileSepc () const { return m_Action
.checkInSpec
; }
373 long GetOffset () const { return m_Action
.offsetFileDelta
; }
374 SSRecordPtr
GetFileDelta () const;
376 virtual std::string
FormatActionString ();
377 virtual bool Accept (ISSActionVisitor
& rVisitor
) { return rVisitor
.Apply (*this); }
379 virtual void ToXml (XMLNode
* pParent
) const;
380 virtual void Dump (std::ostream
& os
) const;
383 CHECKED_IN_ACTION m_Action
;
384 mutable SSRecordPtr m_pFileDelta
;
385 SSFileImpPtr m_FilePtr
;
389 //---------------------------------------------------------------------------
391 class SSSharedAction
: public SSItemAction
<SSSharedAction
, SHARED_FILE_ACTION
>
394 SSSharedAction ( SSRecordPtr pRecord
);
397 std::string
GetSrcPathSpec () const { return m_Action
.srcPathSpec
; }
398 short GetPinnedToVersion () const { return m_Action
.pinnedToVersion
; }
399 short GetVersion () const { return m_Action
.version
; }
401 virtual std::string
FormatActionString ();
403 virtual void ToXml (XMLNode
* pParent
) const;
404 virtual void Dump (std::ostream
& os
) const;
409 #endif // !defined(AFX_SSHISTORYOBJECT_H__58F12C7C_FE74_43B1_9BF6_9E803182D8D7__INCLUDED_)