AGX Dynamics  2.37.3.2
ShareHandle.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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:
39  ShareHandle();
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:
62  PlatformBridge(agx::UInt type1, agx::UInt type2);
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
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
agx::SymmetricPair< agx::UInt > DevicePairDescriptor
Definition: ShareHandle.h:56
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGX_FORCE_INLINE
Definition: Object.h:59
Base class providing referencing counted objects.
Definition: Referenced.h:119
Templated vector class.
Definition: Vector.h:52
uint32_t UInt
Definition: Integer.h:34
Abstract representation of a data buffer.
Definition: Buffer.h:55
Contains classes for low level data storage for AGX.
Definition: Container.h:23
DevicePairDescriptor getDescriptor() const
Definition: ShareHandle.h:83
Buffer * getActiveBuffer()
Definition: ShareHandle.h:80
#define AGXCORE_EXPORT