/*
 * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
 *
 * The license of this code is the same as for the source it was derived from.
 */

#ifndef __INTERFACES_SENSOR_THRESHOLD_H__
#define __INTERFACES_SENSOR_THRESHOLD_H__

#include <gio/gio.h>

G_BEGIN_DECLS


/* ------------------------------------------------------------------------ */
/* Declarations for org.openbmc.SensorIntegerThreshold */

#define TYPE_SENSOR_INTEGER_THRESHOLD (sensor_integer_threshold_get_type ())
#define SENSOR_INTEGER_THRESHOLD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_THRESHOLD, SensorIntegerThreshold))
#define IS_SENSOR_INTEGER_THRESHOLD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_THRESHOLD))
#define SENSOR_INTEGER_THRESHOLD_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_SENSOR_INTEGER_THRESHOLD, SensorIntegerThresholdIface))

struct _SensorIntegerThreshold;
typedef struct _SensorIntegerThreshold SensorIntegerThreshold;
typedef struct _SensorIntegerThresholdIface SensorIntegerThresholdIface;

struct _SensorIntegerThresholdIface
{
  GTypeInterface parent_iface;



  gboolean (*handle_get_threshold_state) (
    SensorIntegerThreshold *object,
    GDBusMethodInvocation *invocation);

  gboolean (*handle_set_thresholds) (
    SensorIntegerThreshold *object,
    GDBusMethodInvocation *invocation,
    gint arg_lower_critical,
    gint arg_lower_warning,
    gint arg_upper_warning,
    gint arg_upper_critical);

  gint  (*get_threshold_lower_warning) (SensorIntegerThreshold *object);

  gint  (*get_threshold_state) (SensorIntegerThreshold *object);

  gint  (*get_threshold_upper_critical) (SensorIntegerThreshold *object);

  gint  (*get_threshold_upper_warning) (SensorIntegerThreshold *object);

  void (*critical) (
    SensorIntegerThreshold *object);

  void (*warning) (
    SensorIntegerThreshold *object);

};

GType sensor_integer_threshold_get_type (void) G_GNUC_CONST;

GDBusInterfaceInfo *sensor_integer_threshold_interface_info (void);
guint sensor_integer_threshold_override_properties (GObjectClass *klass, guint property_id_begin);


/* D-Bus method call completion functions: */
void sensor_integer_threshold_complete_set_thresholds (
    SensorIntegerThreshold *object,
    GDBusMethodInvocation *invocation);

void sensor_integer_threshold_complete_get_threshold_state (
    SensorIntegerThreshold *object,
    GDBusMethodInvocation *invocation,
    gint threshold_state);



/* D-Bus signal emissions functions: */
void sensor_integer_threshold_emit_warning (
    SensorIntegerThreshold *object);

void sensor_integer_threshold_emit_critical (
    SensorIntegerThreshold *object);



/* D-Bus method calls: */
void sensor_integer_threshold_call_set_thresholds (
    SensorIntegerThreshold *proxy,
    gint arg_lower_critical,
    gint arg_lower_warning,
    gint arg_upper_warning,
    gint arg_upper_critical,
    GCancellable *cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data);

gboolean sensor_integer_threshold_call_set_thresholds_finish (
    SensorIntegerThreshold *proxy,
    GAsyncResult *res,
    GError **error);

gboolean sensor_integer_threshold_call_set_thresholds_sync (
    SensorIntegerThreshold *proxy,
    gint arg_lower_critical,
    gint arg_lower_warning,
    gint arg_upper_warning,
    gint arg_upper_critical,
    GCancellable *cancellable,
    GError **error);

void sensor_integer_threshold_call_get_threshold_state (
    SensorIntegerThreshold *proxy,
    GCancellable *cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data);

gboolean sensor_integer_threshold_call_get_threshold_state_finish (
    SensorIntegerThreshold *proxy,
    gint *out_threshold_state,
    GAsyncResult *res,
    GError **error);

gboolean sensor_integer_threshold_call_get_threshold_state_sync (
    SensorIntegerThreshold *proxy,
    gint *out_threshold_state,
    GCancellable *cancellable,
    GError **error);



/* D-Bus property accessors: */
gint sensor_integer_threshold_get_threshold_lower_warning (SensorIntegerThreshold *object);
void sensor_integer_threshold_set_threshold_lower_warning (SensorIntegerThreshold *object, gint value);

gint sensor_integer_threshold_get_threshold_upper_warning (SensorIntegerThreshold *object);
void sensor_integer_threshold_set_threshold_upper_warning (SensorIntegerThreshold *object, gint value);

gint sensor_integer_threshold_get_threshold_upper_critical (SensorIntegerThreshold *object);
void sensor_integer_threshold_set_threshold_upper_critical (SensorIntegerThreshold *object, gint value);

gint sensor_integer_threshold_get_threshold_state (SensorIntegerThreshold *object);
void sensor_integer_threshold_set_threshold_state (SensorIntegerThreshold *object, gint value);


/* ---- */

#define TYPE_SENSOR_INTEGER_THRESHOLD_PROXY (sensor_integer_threshold_proxy_get_type ())
#define SENSOR_INTEGER_THRESHOLD_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxy))
#define SENSOR_INTEGER_THRESHOLD_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxyClass))
#define SENSOR_INTEGER_THRESHOLD_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxyClass))
#define IS_SENSOR_INTEGER_THRESHOLD_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY))
#define IS_SENSOR_INTEGER_THRESHOLD_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY))

typedef struct _SensorIntegerThresholdProxy SensorIntegerThresholdProxy;
typedef struct _SensorIntegerThresholdProxyClass SensorIntegerThresholdProxyClass;
typedef struct _SensorIntegerThresholdProxyPrivate SensorIntegerThresholdProxyPrivate;

struct _SensorIntegerThresholdProxy
{
  /*< private >*/
  GDBusProxy parent_instance;
  SensorIntegerThresholdProxyPrivate *priv;
};

struct _SensorIntegerThresholdProxyClass
{
  GDBusProxyClass parent_class;
};

GType sensor_integer_threshold_proxy_get_type (void) G_GNUC_CONST;

void sensor_integer_threshold_proxy_new (
    GDBusConnection     *connection,
    GDBusProxyFlags      flags,
    const gchar         *name,
    const gchar         *object_path,
    GCancellable        *cancellable,
    GAsyncReadyCallback  callback,
    gpointer             user_data);
SensorIntegerThreshold *sensor_integer_threshold_proxy_new_finish (
    GAsyncResult        *res,
    GError             **error);
SensorIntegerThreshold *sensor_integer_threshold_proxy_new_sync (
    GDBusConnection     *connection,
    GDBusProxyFlags      flags,
    const gchar         *name,
    const gchar         *object_path,
    GCancellable        *cancellable,
    GError             **error);

void sensor_integer_threshold_proxy_new_for_bus (
    GBusType             bus_type,
    GDBusProxyFlags      flags,
    const gchar         *name,
    const gchar         *object_path,
    GCancellable        *cancellable,
    GAsyncReadyCallback  callback,
    gpointer             user_data);
SensorIntegerThreshold *sensor_integer_threshold_proxy_new_for_bus_finish (
    GAsyncResult        *res,
    GError             **error);
SensorIntegerThreshold *sensor_integer_threshold_proxy_new_for_bus_sync (
    GBusType             bus_type,
    GDBusProxyFlags      flags,
    const gchar         *name,
    const gchar         *object_path,
    GCancellable        *cancellable,
    GError             **error);


/* ---- */

#define TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON (sensor_integer_threshold_skeleton_get_type ())
#define SENSOR_INTEGER_THRESHOLD_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeleton))
#define SENSOR_INTEGER_THRESHOLD_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeletonClass))
#define SENSOR_INTEGER_THRESHOLD_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeletonClass))
#define IS_SENSOR_INTEGER_THRESHOLD_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON))
#define IS_SENSOR_INTEGER_THRESHOLD_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON))

typedef struct _SensorIntegerThresholdSkeleton SensorIntegerThresholdSkeleton;
typedef struct _SensorIntegerThresholdSkeletonClass SensorIntegerThresholdSkeletonClass;
typedef struct _SensorIntegerThresholdSkeletonPrivate SensorIntegerThresholdSkeletonPrivate;

struct _SensorIntegerThresholdSkeleton
{
  /*< private >*/
  GDBusInterfaceSkeleton parent_instance;
  SensorIntegerThresholdSkeletonPrivate *priv;
};

struct _SensorIntegerThresholdSkeletonClass
{
  GDBusInterfaceSkeletonClass parent_class;
};

GType sensor_integer_threshold_skeleton_get_type (void) G_GNUC_CONST;

SensorIntegerThreshold *sensor_integer_threshold_skeleton_new (void);


/* ---- */

#define TYPE_OBJECT (object_get_type ())
#define OBJECT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT, Object))
#define IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT))
#define OBJECT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_OBJECT, Object))

struct _Object;
typedef struct _Object Object;
typedef struct _ObjectIface ObjectIface;

struct _ObjectIface
{
  GTypeInterface parent_iface;
};

GType object_get_type (void) G_GNUC_CONST;

SensorIntegerThreshold *object_get_sensor_integer_threshold (Object *object);
SensorIntegerThreshold *object_peek_sensor_integer_threshold (Object *object);

#define TYPE_OBJECT_PROXY (object_proxy_get_type ())
#define OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_PROXY, ObjectProxy))
#define OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_PROXY, ObjectProxyClass))
#define OBJECT_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_PROXY, ObjectProxyClass))
#define IS_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_PROXY))
#define IS_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_PROXY))

typedef struct _ObjectProxy ObjectProxy;
typedef struct _ObjectProxyClass ObjectProxyClass;
typedef struct _ObjectProxyPrivate ObjectProxyPrivate;

struct _ObjectProxy
{
  /*< private >*/
  GDBusObjectProxy parent_instance;
  ObjectProxyPrivate *priv;
};

struct _ObjectProxyClass
{
  GDBusObjectProxyClass parent_class;
};

GType object_proxy_get_type (void) G_GNUC_CONST;
ObjectProxy *object_proxy_new (GDBusConnection *connection, const gchar *object_path);

#define TYPE_OBJECT_SKELETON (object_skeleton_get_type ())
#define OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_SKELETON, ObjectSkeleton))
#define OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_SKELETON, ObjectSkeletonClass))
#define OBJECT_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_SKELETON, ObjectSkeletonClass))
#define IS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_SKELETON))
#define IS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_SKELETON))

typedef struct _ObjectSkeleton ObjectSkeleton;
typedef struct _ObjectSkeletonClass ObjectSkeletonClass;
typedef struct _ObjectSkeletonPrivate ObjectSkeletonPrivate;

struct _ObjectSkeleton
{
  /*< private >*/
  GDBusObjectSkeleton parent_instance;
  ObjectSkeletonPrivate *priv;
};

struct _ObjectSkeletonClass
{
  GDBusObjectSkeletonClass parent_class;
};

GType object_skeleton_get_type (void) G_GNUC_CONST;
ObjectSkeleton *object_skeleton_new (const gchar *object_path);
void object_skeleton_set_sensor_integer_threshold (ObjectSkeleton *object, SensorIntegerThreshold *interface_);

/* ---- */

#define TYPE_OBJECT_MANAGER_CLIENT (object_manager_client_get_type ())
#define OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClient))
#define OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClientClass))
#define OBJECT_MANAGER_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClientClass))
#define IS_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_MANAGER_CLIENT))
#define IS_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_MANAGER_CLIENT))

typedef struct _ObjectManagerClient ObjectManagerClient;
typedef struct _ObjectManagerClientClass ObjectManagerClientClass;
typedef struct _ObjectManagerClientPrivate ObjectManagerClientPrivate;

struct _ObjectManagerClient
{
  /*< private >*/
  GDBusObjectManagerClient parent_instance;
  ObjectManagerClientPrivate *priv;
};

struct _ObjectManagerClientClass
{
  GDBusObjectManagerClientClass parent_class;
};

GType object_manager_client_get_type (void) G_GNUC_CONST;

GType object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data);

void object_manager_client_new (
    GDBusConnection        *connection,
    GDBusObjectManagerClientFlags  flags,
    const gchar            *name,
    const gchar            *object_path,
    GCancellable           *cancellable,
    GAsyncReadyCallback     callback,
    gpointer                user_data);
GDBusObjectManager *object_manager_client_new_finish (
    GAsyncResult        *res,
    GError             **error);
GDBusObjectManager *object_manager_client_new_sync (
    GDBusConnection        *connection,
    GDBusObjectManagerClientFlags  flags,
    const gchar            *name,
    const gchar            *object_path,
    GCancellable           *cancellable,
    GError                **error);

void object_manager_client_new_for_bus (
    GBusType                bus_type,
    GDBusObjectManagerClientFlags  flags,
    const gchar            *name,
    const gchar            *object_path,
    GCancellable           *cancellable,
    GAsyncReadyCallback     callback,
    gpointer                user_data);
GDBusObjectManager *object_manager_client_new_for_bus_finish (
    GAsyncResult        *res,
    GError             **error);
GDBusObjectManager *object_manager_client_new_for_bus_sync (
    GBusType                bus_type,
    GDBusObjectManagerClientFlags  flags,
    const gchar            *name,
    const gchar            *object_path,
    GCancellable           *cancellable,
    GError                **error);


G_END_DECLS

#endif /* __INTERFACES_SENSOR_THRESHOLD_H__ */
