InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IDatabaseSnapshot.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Habib Khalfallah
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Reviewed: 10/5/98
24 //
25 // Purpose: Provides access to the database that holds a K2 publication.
26 //
27 // THIS IS NOT A STANDARD BOSS INTERFACE
28 //
29 //========================================================================================
30 
31 #ifndef __IDatabaseSnapshot__
32 #define __IDatabaseSnapshot__
33 #include "IDataBase.h"
34 #include <boost/intrusive_ptr.hpp>
35 #include "IDThreadingPrimitives.h"
36 
37 // For internal use only
38 // This defines the abstract interface for database snapshot.
39 
40 class IDatabaseSnapshot;
41 typedef boost::intrusive_ptr<IDatabaseSnapshot> DatabaseSnapshotPtr;
42 class IPubFile;
43 class IDataBase;
44 class MemXferBytes;
45 
47 {
48 public:
49  IDatabaseSnapshot() : fRefCount(0)
50  {}
51 
52  virtual ~IDatabaseSnapshot() {};
53 
54  virtual void SetFileInfo(IPubFile* pubFile, const IDFile & sysFileFromOpen) = 0;
55  virtual IPubFile* GetPubFile() const = 0;
56  virtual const IDFile & GetSysFileFromOpen () const = 0;
57  // Tmp solution to links updates optimization
58  // For more generic solution we need to use a time-stamp like thing
59  virtual uint32 GetLinksUpdateSeed() const = 0;
60  virtual void SetLinksUpdateSeed(uint32 seed) = 0;
61  virtual IDatabaseSnapshot* GetLastDBSnapshotBeforePubFileSharing () const = 0;
62  virtual void DetatchFromBase() = 0;
63  virtual IDataBase* CreateCloneDataBase() = 0;
64 
65  virtual void AddRef()
66  {
67  IDThreading::AtomicIncrement(fRefCount);
68  }
69  virtual void Release()
70  {
71  const uint32 newCount = IDThreading::AtomicDecrement(fRefCount);
72  ASSERT (newCount < uint32(-1));
73  if (newCount == 0)
74  {
75  delete this;
76  }
77  }
78 
79  virtual MemXferBytes* GetPrivateDataForHTTPLinks() = 0;
80  virtual void SetPrivateDataForHTTPLinks(MemXferBytes* bytes) = 0;
81  virtual std::string GetAssetRef() =0;
82  virtual IDataBase * GetDB() = 0;
83 protected:
84  volatile uint32 fRefCount; // atomic
85 
86  friend void intrusive_ptr_add_ref(IDatabaseSnapshot* p)
87  {
88  p->AddRef();
89  }
90 
91  friend void intrusive_ptr_release(IDatabaseSnapshot* p)
92  {
93  p->Release();
94  }
95 };
96 #endif