2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * ADR Object Model
2N/A *
2N/A * These are a set of interfaces for defining a basic object model,
2N/A * built using ADR types.
2N/A */
2N/A
2N/A#ifndef _ADR_OBJECT_H
2N/A#define _ADR_OBJECT_H
2N/A
2N/A#include <sys/types.h>
2N/A#include <stdio.h>
2N/A#include <rad/adr.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/* Number of stability classes: 3 (private, uncommitted, committed) */
2N/A#define NSTABILITY 3
2N/A
2N/A/* A method parameter */
2N/Atypedef struct adr_parameter {
2N/A const char *ap_name; /* argument's name */
2N/A adr_type_t *ap_type; /* argument's type */
2N/A boolean_t ap_nullable; /* can this argument be "null"? */
2N/A} adr_parameter_t;
2N/A
2N/A/* An object method */
2N/Atypedef struct adr_method {
2N/A const char *am_name; /* method's name */
2N/A adr_stability_t am_stability; /* method stability classification */
2N/A int am_nargs; /* number of arguments */
2N/A adr_type_t *am_result; /* result type */
2N/A adr_type_t *am_error; /* error type */
2N/A boolean_t am_nullable; /* can the result be "null"? */
2N/A adr_parameter_t *am_args; /* method's arguments */
2N/A} adr_method_t;
2N/A
2N/A/* An object attribute */
2N/Atypedef struct adr_attribute {
2N/A const char *aa_name; /* attribute's name */
2N/A adr_stability_t aa_stability; /* attribute stability classification */
2N/A adr_type_t *aa_type; /* attribute's type */
2N/A adr_type_t *aa_read_error; /* attribute's read error type */
2N/A adr_type_t *aa_write_error; /* attribute's write error type */
2N/A boolean_t aa_nullable; /* can this attribute be "null"? */
2N/A boolean_t aa_readable; /* can this attribute be read */
2N/A boolean_t aa_writeable; /* can this attribute be written */
2N/A} adr_attribute_t;
2N/A
2N/A/* An object event */
2N/Atypedef struct adr_event {
2N/A const char *ae_name; /* event's name */
2N/A adr_stability_t ae_stability; /* event's stability classification */
2N/A adr_type_t *ae_type; /* event's type */
2N/A} adr_event_t;
2N/A
2N/A/* An object version */
2N/Atypedef struct adr_version {
2N/A adr_stability_t av_stability; /* stability classification */
2N/A int av_major; /* major version */
2N/A int av_minor; /* minor version */
2N/A} adr_version_t;
2N/A
2N/A/* An object, consisting of attributes and methods */
2N/Atypedef struct adr_object {
2N/A const char *ao_aname; /* name of api */
2N/A const char *ao_ifname; /* name of interface */
2N/A adr_version_t ao_versions[NSTABILITY]; /* versions */
2N/A int ao_nattributes; /* # attributes */
2N/A int ao_nmethods; /* # methods */
2N/A int ao_nevents; /* # events */
2N/A int ao_nparents; /* # parents */
2N/A adr_attribute_t **ao_attributes; /* attributes */
2N/A adr_method_t **ao_methods; /* methods */
2N/A adr_event_t *ao_events; /* events */
2N/A struct adr_object **ao_parents; /* parent types (for versioning) */
2N/A} adr_object_t;
2N/A
2N/Avoid adr_free(adr_object_t *);
2N/A
2N/Aint adr_lookup_attr_index(adr_object_t *, const char *);
2N/Aadr_attribute_t *adr_lookup_attr(adr_object_t *, const char *);
2N/Aadr_attribute_t *adr_get_attr(adr_object_t *, int);
2N/A
2N/Aint adr_lookup_method_index(adr_object_t *, const char *);
2N/Aadr_method_t *adr_lookup_method(adr_object_t *, const char *);
2N/Aadr_method_t *adr_get_method(adr_object_t *, int);
2N/A
2N/Aint adr_lookup_event_index(adr_object_t *, const char *);
2N/Aadr_event_t *adr_lookup_event(adr_object_t *, const char *);
2N/Aadr_event_t *adr_get_event(adr_object_t *, int);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _ADR_OBJECT_H */