Louvre  v2.9.0-1
C++ library for Wayland compositors
Public Member Functions | Protected Member Functions | List of all members
LResource Class Reference

Wrapper for native wl_resource structs. More...

+ Inheritance diagram for LResource:

Public Member Functions

wl_resource * resource () const noexcept
 Retrieve the wrapped wl_resource pointer. More...
 
LClientclient () const noexcept
 Retrieve the client that owns this resource. More...
 
Int32 version () const noexcept
 Retrieve the version of the global interface. More...
 
UInt32 id () const noexcept
 Retrieve the ID of the resource. More...
 
void destroy ()
 Destroy the resource. More...
 
- Public Member Functions inherited from LObject
 LObject (const LObject &) noexcept
 Copy constructor. More...
 
LObjectoperator= (const LObject &) noexcept
 Assignment operator (each object has its own individual LWeak reference count). More...
 
void setUserData (UIntPtr data) const noexcept
 Store an unsigned integer value/pointer. More...
 
UIntPtr userData () const noexcept
 Retrieves the stored unsigned integer value/pointer. More...
 

Protected Member Functions

 LResource (wl_client *client, const wl_interface *interface, Int32 version, UInt32 id, const void *implementation) noexcept
 Constructor for LResource using wl_client and other parameters. More...
 
 LResource (LClient *client, const wl_interface *interface, Int32 version, UInt32 id, const void *implementation) noexcept
 Constructor for LResource using LClient and other parameters. More...
 
 ~LResource ()=default
 Destructor for LResource. More...
 
- Protected Member Functions inherited from LObject
 LObject () noexcept=default
 Constructor of the LObject class. More...
 
virtual ~LObject () noexcept
 Destructor of the LObject class. More...
 
void notifyDestruction () noexcept
 Notifies the object destruction. More...
 

Detailed Description

Wrapper for native wl_resource structs.

This class serves as a wrapper for the wl_resource struct from the original Wayland library.
Numerous objects expose their LResource objects, allowing you to utilize native Wayland methods if desired.

To explore all the globals/resources implemented by Louvre, refer to the Louvre/src/lib/protocols directory.

Note
This class is primarily intended for implementing additional protocols beyond those provided by Louvre.

Constructor & Destructor Documentation

◆ LResource() [1/2]

LResource ( wl_client *  client,
const wl_interface *  interface,
Int32  version,
UInt32  id,
const void *  implementation 
)
protectednoexcept

Constructor for LResource using wl_client and other parameters.

This constructor creates an LResource and registers it with the provided parameters.

Parameters
clientThe wl_client associated with the resource.
interfacePointer to the wl_interface provided by the protocol.
versionVersion of the global interface.
idID of the resource; passing 0 automatically generates an increasing ID.
implementationPointer to the interface implementation (struct with callback functions to handle client requests).
destroyCallback function to handle resource destruction.

◆ LResource() [2/2]

LResource ( LClient client,
const wl_interface *  interface,
Int32  version,
UInt32  id,
const void *  implementation 
)
protectednoexcept

Constructor for LResource using LClient and other parameters.

This constructor creates an LResource and registers it with the provided parameters.

Parameters
clientThe LClient associated with the resource.
interfacePointer to the wl_interface provided by the protocol.
versionVersion of the global interface.
idID of the resource; passing 0 automatically generates an increasing ID.
implementationPointer to the interface implementation (struct with callback functions to handle client requests).

◆ ~LResource()

~LResource ( )
protecteddefault

Destructor for LResource.

Member Function Documentation

◆ resource()

wl_resource* resource ( ) const
inlinenoexcept

Retrieve the wrapped wl_resource pointer.

This method returns the original wl_resource pointer associated with this LResource.

Returns
A pointer to the wrapped wl_resource.

◆ client()

LClient* client ( ) const
inlinenoexcept

Retrieve the client that owns this resource.

This method returns the LClient instance to which this resource belongs.

Returns
A pointer to the owning LClient.

◆ version()

Int32 version ( ) const
noexcept

Retrieve the version of the global interface.

This method returns the version of the global interface associated with this resource.

Returns
The version of the global interface.

◆ id()

UInt32 id ( ) const
noexcept

Retrieve the ID of the resource.

This method returns the ID of the resource, which is the same as calling wl_resource_get_id().

Returns
The ID of the resource.

◆ destroy()

void destroy ( )

Destroy the resource.

This method destroys the resource, equivalent to calling wl_resource_destroy().