CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TfRevisionControl.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24
25#ifndef _TFREVISIONCONTROL_H_INCLUDED_
26#define _TFREVISIONCONTROL_H_INCLUDED_
27
28#include "TfSchemaManager.h"
29#include "DbObjectIterator.h"
30#include "ThreadsCounter.h"
31
32#define STL_USING_MAP
33#include "OdaSTL.h"
34
35#include <stdexcept>
36
41{
43 char data[20];
44
50 void write(OdStreamBuf* pBuf) const { pBuf->putBytes(data, 20); }
51
57 void read(OdStreamBuf* pBuf) { pBuf->getBytes(data, 20); }
58
67 bool operator < (const OdTfDigest& other) const
68 {
69 return memcmp(data, other.data, 20) < 0;
70 }
71
79 bool operator == (const OdTfDigest& other) const
80 {
81 return memcmp(data, other.data, 20) == 0;
82 }
83
91 bool operator != (const OdTfDigest& other) const
92 {
93 return memcmp(data, other.data, 20) != 0;
94 }
95
100 {
101 OdTfDigest res;
102 memset(res.data, 0, 20);
103 return res;
104 }
105
112 bool isNull() const
113 {
114 char test[20] = { 0 };
115 return memcmp(test, data, 20) == 0;
116 }
117
123 {
124 memset(data, 0, 20);
125 }
126};
127
132
137{
141 typedef std::map<OdString, OdTfDigest> ReferenceList;
142
147 {
156 };
157
161 typedef std::map<OdDbHandle, ChangeType> ChangeList;
162
171
174 };
175
194
198
204 };
205
218 bool inline isConflict(ChangeType myChange, ChangeType theirChange)
219 {
220 return myChange != kObjectUnmodified
221 && theirChange != kObjectUnmodified
222 && !(myChange == kObjectDeleted && theirChange == kObjectDeleted);
223 }
224};
225
226
227
232{
241
251 const OdString& author = OdString::kEmpty,
252 const OdString& message = OdString::kEmpty,
254 OdStreamBuf* arbitraryUserData = 0);
255};
256
267{
276
286 :annotation(author, message, date, arbitraryUserData) {}
287};
288
320{
324 OdTfRevisionControl::MergeResolution autoResolution) = 0;
325};
326
336template<OdTfRevisionControl::MergeResolution conflictResolution = OdTfRevisionControl::kMergeTheirsConflict>
338{
343
347 OdTfRevisionControl::MergeResolution autoResolution) override
348 {
349 return autoResolution ? autoResolution : conflictResolution;
350 }
351};
352
358{
359 struct Conflict
360 {
368 };
370
371 Conflicts const& conflicts() const { return m_conflicts; }
372 Conflicts& conflicts() { return m_conflicts; }
373
377 OdTfRevisionControl::MergeResolution autoResolution) override
378 {
379 if (autoResolution)
380 return autoResolution;
381 m_conflicts.append(Conflict(h, myChange, theirChange));
383 }
384
385private:
386 Conflicts m_conflicts;
387};
388
389class OdTfRepository;
390
396
397
398struct OdTfStorage;
399
405struct OdTfStorageImpl;
406
407namespace OdTfRevisionControl
408{
417
426
442 TFDLL_EXPORT OdTfDigest commit(OdDbDatabase* pDb, const OdTfCommitAnnotation& message, const OdDbObjectIdArray* objectsToSave = 0);
443
458 TFDLL_EXPORT bool dryMerge(const OdDbDatabase* pDb, const OdTfDigest& sha,
459 OdTfMergeHandler& mergeHandler);
460 TFDLL_EXPORT bool dryMerge(const OdDbDatabase* pDb, const OdString& reference,
461 OdTfMergeHandler& mergeHandler);
462
484 OdTfMergeHandler& mergeHandler, bool noFastForward = false);
485 TFDLL_EXPORT bool merge(OdDbDatabase* pDb, const OdString& reference,
486 OdTfMergeHandler& mergeHandler, bool noFastForward = false);
487
501
515 TFDLL_EXPORT void switchBranch(OdDbDatabase* pDb, const OdString& branch, bool hard = true);
516
524
533
545
557
568 TFDLL_EXPORT void writeObjectPartial(OdDbObjectId id, bool pageObjectToDisk = true);
569
577
587 TFDLL_EXPORT void getRevisionDifference(OdDbDatabase* pDb, const OdTfDigest& newRevision, const OdTfDigest& oldRevision, ChangeList& result);
588
598 TFDLL_EXPORT bool getCommonAncestor(OdDbDatabase* pDb, const OdTfDigest& theirSha, OdTfDigest& ancestor);
599}
600
605{
614
624 //static OdTfStoragePtr createObject(OdStreamBuf* pStream, OdDbHostAppServices* pHostApp);
625
641 OdTfDigest store(OdDbDatabase* pDb, const OdDbObjectIdArray* objectsToSave = 0);
642
655 OdDbDatabasePtr retrieve(const OdTfDigest& sha, bool partial = false) const;
664 bool isSchemePresent(const OdTfDigest& sha) const;
673
681
696 const OdTfDigest& mine, const OdTfDigest& theirs, const OdTfDigest& base,
697 OdTfMergeHandler& mergeHandler) const;
699 const OdDbDatabase *pDb, const OdTfDigest& theirs, const OdTfDigest& base,
700 OdTfMergeHandler& mergeHandler) const;
701
718 const OdTfDigest& mine, const OdTfDigest& theirs, const OdTfDigest& base,
719 OdTfMergeHandler& mergeHandler) const;
720
735 void merge(
736 OdDbDatabase *pDb, const OdTfDigest& theirs, const OdTfDigest& base,
737 OdTfMergeHandler& mergeHandler) const;
738
791 const OdTfDigestArray& from, const OdTfDigestArray& to,
793
811
821 void getRevisionDifference(const OdTfDigest& newRevision,
822 const OdTfDigest& oldRevision, OdTfRevisionControl::ChangeList& result) const;
823
832 const OdTfDigest& revision, OdTfRevisionControl::ChangeList& result) const;
833
840
847 void setReference(const OdString& refName, const OdTfDigest& sha);
848
855
864 bool getReference(const OdString& refName, OdTfDigest& sha) const;
865
872
873protected:
874 // Internal implementation not writing a header section. To be used in derived
875 // makePatch() implementations.
877 const OdTfDigestArray& from, const OdTfDigestArray& to,
878 const OdTfRevisionControl::ReferenceList& refs) const;
879
880 protected:
881 friend struct OdTfStorageImpl;
883 OdTfStorageImpl* m_pImpl;
884};
885
892{
893public:
903
910 void init(const bool isNewStorage);
911
935 const OdDbObjectIdArray* objectsToSave = 0);
936
945 OdTfDigest import(OdDbDatabase* pDb, const OdString& localbranch);
946
962 OdDbDatabasePtr checkout(const OdTfDigest& sha, const OdString& localBranch,
963 bool partial = false);
964
975 OdDbDatabasePtr checkout(const OdString& reference, const OdString& localBranch, bool partial = false);
976
988 OdDbDatabasePtr checkout(const OdString& branch, bool partial = false);
989
1049 const OdTfDigestArray& from, const OdTfDigestArray& to,
1051
1111 const OdTfDigestArray& from, const OdTfDigest& to,
1113
1124
1138};
1139
1140
1141#endif //_TFREVISIONCONTROL_H_INCLUDED_
bool operator!=(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:403
bool operator==(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:397
bool operator<(const OdString &s1, const OdString &s2)
Definition: OdString.h:1309
#define TFDLL_EXPORT
Definition: Tf.h:39
OdSmartPtr< OdTfRepository > OdTfRepositoryPtr
OdArray< OdTfDigest, OdMemoryAllocator< OdTfDigest > > OdTfDigestArray
OdSmartPtr< OdTfStorage > OdTfStoragePtr
size_type append(const T &value)
Definition: OdArray.h:1725
virtual void getBytes(void *buffer, OdUInt32 numBytes)
virtual void putBytes(const void *buffer, OdUInt32 numBytes)
FIRSTDLL_EXPORT_STATIC static const OdString kEmpty
Definition: OdString.h:98
static OdTfRepositoryPtr createObject(OdStreamBufPtr pStream, OdDbHostAppServices *pHostApp)
OdDbDatabasePtr checkout(const OdTfDigest &sha, const OdString &localBranch, bool partial=false)
void init(const bool isNewStorage)
OdTfDigest writeCommitInfo(OdTfCommitInfo &commitInfo)
OdTfCommitInfo getCommitInfo(const OdTfDigest &sha) const
OdStreamBufPtr makePatch(const OdTfDigestArray &from, const OdTfDigestArray &to, const OdTfRevisionControl::ReferenceList &refs=OdTfRevisionControl::ReferenceList()) const
OdDbDatabasePtr checkout(const OdString &branch, bool partial=false)
OdDbDatabasePtr checkout(const OdString &reference, const OdString &localBranch, bool partial=false)
OdStreamBufPtr makePatch(const OdTfDigestArray &from, const OdTfDigest &to, const OdTfRevisionControl::ReferenceList &refs=OdTfRevisionControl::ReferenceList()) const
OdTfDigest commit(OdDbDatabase *pDb, const OdTfDigestArray &parents, const OdTfCommitAnnotation &message=OdTfCommitAnnotation(), const OdDbObjectIdArray *objectsToSave=0)
@ kInitUniversalTime
Definition: OdTimeStamp.h:48
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition: gles2_ext.h:110
TFDLL_EXPORT bool dryMerge(const OdDbDatabase *pDb, const OdTfDigest &sha, OdTfMergeHandler &mergeHandler)
TFDLL_EXPORT void getRevisionDifference(OdDbDatabase *pDb, const OdTfDigest &newRevision, const OdTfDigest &oldRevision, ChangeList &result)
TFDLL_EXPORT OdTfDigest commit(OdDbDatabase *pDb, const OdTfCommitAnnotation &message, const OdDbObjectIdArray *objectsToSave=0)
TFDLL_EXPORT void endPartialImport(OdDbDatabase *pDb)
bool isConflict(ChangeType myChange, ChangeType theirChange)
TFDLL_EXPORT OdString getLocalBranch(OdDbDatabase *pDb, OdTfDigest *head=0)
TFDLL_EXPORT OdDbObjectIdArray getLocalChanges(OdDbDatabase *pDb)
TFDLL_EXPORT OdTfRepository * getRepository(OdDbDatabase *pDb)
std::map< OdDbHandle, ChangeType > ChangeList
TFDLL_EXPORT bool merge(OdDbDatabase *pDb, const OdTfDigest &sha, OdTfMergeHandler &mergeHandler, bool noFastForward=false)
TFDLL_EXPORT OdStreamBufPtr compressData(OdDbDatabase *pDb)
TFDLL_EXPORT void writeObjectPartial(OdDbObjectId id, bool pageObjectToDisk=true)
TFDLL_EXPORT void loadObjects(OdDbDatabase *pDb, OdDbObjectIterator *pObjects, OdMTLoadReactor *pReactor=0)
TFDLL_EXPORT OdTfRepositoryPtr detachRepository(OdDbDatabase *pDb)
TFDLL_EXPORT void switchBranch(OdDbDatabase *pDb, const OdString &branch, bool hard=true)
std::map< OdString, OdTfDigest > ReferenceList
TFDLL_EXPORT void beginPartialImport(OdStreamBufPtr pStream, OdDbDatabase *pDb)
TFDLL_EXPORT bool getCommonAncestor(OdDbDatabase *pDb, const OdTfDigest &theirSha, OdTfDigest &ancestor)
OdTfCommitAnnotation(const OdString &author=OdString::kEmpty, const OdString &message=OdString::kEmpty, const OdTimeStamp &date=OdTimeStamp(OdTimeStamp::kInitUniversalTime), OdStreamBuf *arbitraryUserData=0)
OdTfDigestArray parents
OdTfCommitInfo(const OdString &author=OdString::kEmpty, const OdString &message=OdString::kEmpty, const OdTimeStamp &date=OdTimeStamp(OdTimeStamp::kInitUniversalTime), OdStreamBuf *arbitraryUserData=0)
OdTfCommitAnnotation annotation
bool isNull() const
static OdTfDigest kNull()
void read(OdStreamBuf *pBuf)
void write(OdStreamBuf *pBuf) const
OdTfRevisionControl::MergeResolution operator()(const OdDbHandle &h, OdTfRevisionControl::ChangeType myChange, OdTfRevisionControl::ChangeType theirChange, OdTfRevisionControl::MergeResolution autoResolution) override
virtual OdTfRevisionControl::MergeResolution operator()(const OdDbHandle &h, OdTfRevisionControl::ChangeType myChange, OdTfRevisionControl::ChangeType theirChange, OdTfRevisionControl::MergeResolution autoResolution)=0
OdTfRevisionControl::ChangeType myChange
OdTfRevisionControl::ChangeType theirChange
Conflict(const OdDbHandle &handle, OdTfRevisionControl::ChangeType myChange, OdTfRevisionControl::ChangeType theirChange)
OdTfRevisionControl::MergeResolution operator()(const OdDbHandle &h, OdTfRevisionControl::ChangeType myChange, OdTfRevisionControl::ChangeType theirChange, OdTfRevisionControl::MergeResolution autoResolution) override
Conflicts const & conflicts() const
OdArray< Conflict > Conflicts
void getRevisionDifference(OdDbDatabase *pDb, const OdTfDigest &revision, OdTfRevisionControl::ChangeList &result) const
OdStreamBufPtr makePatch(const OdTfDigestArray &from, const OdTfDigestArray &to, const OdTfRevisionControl::ReferenceList &refs=OdTfRevisionControl::ReferenceList()) const
void setReference(const OdString &refName, const OdTfDigest &sha)
void makePatch(OdStreamBuf *s, const OdTfDigestArray &from, const OdTfDigestArray &to, const OdTfRevisionControl::ReferenceList &refs) const
bool getReference(const OdString &refName, OdTfDigest &sha) const
OdDbDatabasePtr merge(const OdTfDigest &mine, const OdTfDigest &theirs, const OdTfDigest &base, OdTfMergeHandler &mergeHandler) const
void getRevisionDifference(const OdTfDigest &newRevision, const OdTfDigest &oldRevision, OdTfRevisionControl::ChangeList &result) const
OdTfDigest store(OdDbDatabase *pDb, const OdDbObjectIdArray *objectsToSave=0)
OdStreamBufPtr getStorageStream() const
void dryMerge(const OdDbDatabase *pDb, const OdTfDigest &theirs, const OdTfDigest &base, OdTfMergeHandler &mergeHandler) const
OdTfDigest applySchemePatch(OdStreamBufPtr &schemePatch) const
void getReferences(OdTfRevisionControl::ReferenceList &refs) const
bool isSchemePresent(const OdTfDigest &sha) const
void setReference(const OdTfRevisionControl::ReferenceList &branches)
OdStreamBufPtr makeSchemePatch(const OdTfDigest &sha) const
void dryMerge(const OdTfDigest &mine, const OdTfDigest &theirs, const OdTfDigest &base, OdTfMergeHandler &mergeHandler) const
OdTfStorageImpl * m_pImpl
void merge(OdDbDatabase *pDb, const OdTfDigest &theirs, const OdTfDigest &base, OdTfMergeHandler &mergeHandler) const
OdDbDatabasePtr retrieve(const OdTfDigest &sha, bool partial=false) const
void applyPatch(OdStreamBuf *s, OdTfDigestArray &roots, OdTfRevisionControl::ReferenceList &refs)