AGX Dynamics  2.35.0.1
ShareHandle.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 
18 #ifndef AGXDATA_SHARE_HANDLE_H
19 #define AGXDATA_SHARE_HANDLE_H
20 
21 
22 #include <agx/agxCore_export.h>
23 #include <agx/Vector.h>
24 #include <agx/Referenced.h>
25 #include <agx/SymmetricPair.h>
26 
27 namespace agxData
28 {
29  class Buffer;
30 
33  {
34  public:
35  static bool hasBridge(Buffer *buffer1, Buffer *buffer2);
36  static ShareHandle *create(Buffer *buffer1, Buffer *buffer2);
37 
38  public:
40 
41  void addBuffer(Buffer *buffer);
42 
43  Buffer *getActiveBuffer();
44  const Buffer *getActiveBuffer() const;
45 
46  void activate(Buffer* buffer);
47  void removeBuffer(Buffer *buffer);
48 
49  void reinit();
50 
51  protected:
52  virtual ~ShareHandle();
53 
54  public:
55  typedef void (*ActivationFn)(Buffer *activationTarget, Buffer *currentHolder);
57 
60  {
61  public:
63  virtual ~PlatformBridge();
64 
65  virtual void init(Buffer *buffer1, Buffer *buffer2);
66  virtual void activate(Buffer *activationTarget, Buffer *currentHolder) = 0;
67 
68  DevicePairDescriptor getDescriptor() const;
69  private:
70  DevicePairDescriptor m_descriptor;
71  };
72 
73  private:
74  Buffer *m_activeBuffer;
75  agx::Vector<Buffer *> m_buffers;
76  };
77 
78 
79  /* Implementation */
81  AGX_FORCE_INLINE const Buffer *ShareHandle::getActiveBuffer() const { return m_activeBuffer; }
82 
84 
85 }
86 
87 #endif // AGXDATA_SHARE_HANDLE_H
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXCORE_EXPORT
Abstract representation of a data buffer.
Definition: Buffer.h:56
virtual void init(Buffer *buffer1, Buffer *buffer2)
PlatformBridge(agx::UInt type1, agx::UInt type2)
DevicePairDescriptor getDescriptor() const
Definition: ShareHandle.h:83
virtual void activate(Buffer *activationTarget, Buffer *currentHolder)=0
void activate(Buffer *buffer)
void addBuffer(Buffer *buffer)
static ShareHandle * create(Buffer *buffer1, Buffer *buffer2)
static bool hasBridge(Buffer *buffer1, Buffer *buffer2)
Buffer * getActiveBuffer()
Definition: ShareHandle.h:80
agx::SymmetricPair< agx::UInt > DevicePairDescriptor
Definition: ShareHandle.h:56
void removeBuffer(Buffer *buffer)
Base class providing referencing counted objects.
Definition: Referenced.h:114
Templated vector class.
Definition: agx/Vector.h:53
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes for low level data storage for AGX.
Definition: Container.h:23
uint32_t UInt
Definition: Integer.h:34