CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
TfRevisionControl.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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-2024 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
40struct TFDLL_EXPORT OdTfDigest
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
225
226
227
256
266struct TFDLL_EXPORT OdTfCommitInfo
267{
276
286 :annotation(author, message, date, arbitraryUserData) {}
287};
288
327
337template<OdTfRevisionControl::MergeResolution conflictResolution = OdTfRevisionControl::kMergeTheirsConflict>
339{
344
348 OdTfRevisionControl::MergeResolution autoResolution) override
349 {
350 return autoResolution ? autoResolution : conflictResolution;
351 }
352};
353
359{
371
372 Conflicts const& conflicts() const { return m_conflicts; }
373 Conflicts& conflicts() { return m_conflicts; }
374
378 OdTfRevisionControl::MergeResolution autoResolution) override
379 {
380 if (autoResolution)
381 return autoResolution;
382 m_conflicts.append(Conflict(h, myChange, theirChange));
384 }
385
386private:
387 Conflicts m_conflicts;
388};
389
390class OdTfRepository;
391
397
398
399struct OdTfStorage;
400
406struct OdTfStorageImpl;
407
408namespace OdTfRevisionControl
409{
418
427
443 TFDLL_EXPORT OdTfDigest commit(OdDbDatabase* pDb, const OdTfCommitAnnotation& message, const OdDbObjectIdArray* objectsToSave = 0);
444
459 TFDLL_EXPORT bool dryMerge(const OdDbDatabase* pDb, const OdTfDigest& sha,
460 OdTfMergeHandler& mergeHandler);
461 TFDLL_EXPORT bool dryMerge(const OdDbDatabase* pDb, const OdString& reference,
462 OdTfMergeHandler& mergeHandler);
463
484 TFDLL_EXPORT bool merge(OdDbDatabase* pDb, const OdTfDigest& sha,
485 OdTfMergeHandler& mergeHandler, bool noFastForward = false);
486 TFDLL_EXPORT bool merge(OdDbDatabase* pDb, const OdString& reference,
487 OdTfMergeHandler& mergeHandler, bool noFastForward = false);
488
501 TFDLL_EXPORT OdString getLocalBranch(OdDbDatabase* pDb, OdTfDigest* head = 0);
502
516 TFDLL_EXPORT void switchBranch(OdDbDatabase* pDb, const OdString& branch, bool hard = true);
517
525
534
545 TFDLL_EXPORT void loadObjects(OdDbDatabase* pDb, OdDbObjectIterator* pObjects, OdMTLoadReactor* pReactor = 0);
546
557 TFDLL_EXPORT void beginPartialImport(OdStreamBufPtr pStream, OdDbDatabase* pDb);
558
569 TFDLL_EXPORT void writeObjectPartial(OdDbObjectId id, bool pageObjectToDisk = true);
570
577 TFDLL_EXPORT void endPartialImport(OdDbDatabase* pDb);
578
588 TFDLL_EXPORT void getRevisionDifference(OdDbDatabase* pDb, const OdTfDigest& newRevision, const OdTfDigest& oldRevision, ChangeList& result);
589
599 TFDLL_EXPORT bool getCommonAncestor(OdDbDatabase* pDb, const OdTfDigest& theirSha, OdTfDigest& ancestor);
600}
601
605struct TFDLL_EXPORT OdTfStorage : public OdRxObject
606{
615
625 //static OdTfStoragePtr createObject(OdStreamBuf* pStream, OdDbHostAppServices* pHostApp);
626
642 OdTfDigest store(OdDbDatabase* pDb, const OdDbObjectIdArray* objectsToSave = 0);
643
656 OdDbDatabasePtr retrieve(const OdTfDigest& sha, bool partial = false) const;
665 bool isSchemePresent(const OdTfDigest& sha) const;
674
682
697 const OdTfDigest& mine, const OdTfDigest& theirs, const OdTfDigest& base,
698 OdTfMergeHandler& mergeHandler) const;
700 const OdDbDatabase *pDb, const OdTfDigest& theirs, const OdTfDigest& base,
701 OdTfMergeHandler& mergeHandler) const;
702
719 const OdTfDigest& mine, const OdTfDigest& theirs, const OdTfDigest& base,
720 OdTfMergeHandler& mergeHandler) const;
721
736 void merge(
737 OdDbDatabase *pDb, const OdTfDigest& theirs, const OdTfDigest& base,
738 OdTfMergeHandler& mergeHandler) const;
739
792 const OdTfDigestArray& from, const OdTfDigestArray& to,
794
812
822 void getRevisionDifference(const OdTfDigest& newRevision,
823 const OdTfDigest& oldRevision, OdTfRevisionControl::ChangeList& result) const;
824
833 const OdTfDigest& revision, OdTfRevisionControl::ChangeList& result) const;
834
841
848 void setReference(const OdString& refName, const OdTfDigest& sha);
849
856
865 bool getReference(const OdString& refName, OdTfDigest& sha) const;
866
873
874protected:
875 // Internal implementation not writing a header section. To be used in derived
876 // makePatch() implementations.
878 const OdTfDigestArray& from, const OdTfDigestArray& to,
879 const OdTfRevisionControl::ReferenceList& refs) const;
880
881 protected:
882 friend struct OdTfStorageImpl;
885};
886
892class TFDLL_EXPORT OdTfRepository : public OdTfStorage
893{
894public:
904
911 void init(const bool isNewStorage);
912
936 const OdDbObjectIdArray* objectsToSave = 0);
937
946 OdTfDigest import(OdDbDatabase* pDb, const OdString& localbranch);
947
963 OdDbDatabasePtr checkout(const OdTfDigest& sha, const OdString& localBranch,
964 bool partial = false);
965
976 OdDbDatabasePtr checkout(const OdString& reference, const OdString& localBranch, bool partial = false);
977
989 OdDbDatabasePtr checkout(const OdString& branch, bool partial = false);
990
1050 const OdTfDigestArray& from, const OdTfDigestArray& to,
1052
1112 const OdTfDigestArray& from, const OdTfDigest& to,
1114
1125
1139};
1140
1141
1142#endif //_TFREVISIONCONTROL_H_INCLUDED_
OdSmartPtr< OdDbDatabase > OdDbDatabasePtr
Definition DbDatabase.h:203
OdSmartPtr< OdStreamBuf > OdStreamBufPtr
bool operator!=(T left, const OdGiVariant::EnumType right)
Definition GiVariant.h:405
bool operator==(T left, const OdGiVariant::EnumType right)
Definition GiVariant.h:399
OdArray< OdDbObjectId, OdClrMemAllocator< OdDbObjectId > > OdDbObjectIdArray
Definition IdArrays.h:53
bool operator<(const OdString &s1, const OdString &s2)
Definition OdString.h:1317
OdSmartPtr< OdTfRepository > OdTfRepositoryPtr
OdArray< OdTfDigest, OdMemoryAllocator< OdTfDigest > > OdTfDigestArray
OdSmartPtr< OdTfStorage > OdTfStoragePtr
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:100
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)
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
friend struct OdTfStorageImpl
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)