Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Data Structures | Macros | Typedefs | Functions | Variables

Files

file  afw_adaptor_impl.h
 Helpers for adaptor implementation development.
 

Data Structures

struct  afw_adaptor_impl_core_object_type_s
 afw_adaptor_impl_t supported_core_object_types entry. More...
 
struct  afw_adaptor_impl_s
 Internal struct used by common adaptor code for all adaptors. More...
 
struct  afw_adaptor_impl_session_s
 Internal session info used by afw_adaptor_impl*() functions. More...
 
struct  afw_adaptor_impl_request_s
 Internal request info used by afw_adaptor_impl*() functions. More...
 

Macros

#define AFW_ADAPTOR_IMPL_LOCK_READ_BEGIN(adaptor)   AFW_LOCK_READ_BEGIN((adaptor)->impl->adaptor_lock_rw)
 Macro to begin an adaptor read lock section. More...
 
#define AFW_ADAPTOR_IMPL_LOCK_READ_END   AFW_LOCK_READ_END
 Macro to end an adaptor read lock section. More...
 
#define AFW_ADAPTOR_IMPL_LOCK_WRITE_BEGIN(adaptor)   AFW_LOCK_WRITE_BEGIN((adaptor)->impl->adaptor_lock_rw)
 Macro to begin an adaptor write lock section. More...
 
#define AFW_ADAPTOR_IMPL_LOCK_WRITE_END   AFW_LOCK_WRITE_END
 Macro to end an adaptor write lock section. More...
 
#define AFW_ADAPTOR_IMPL_ERROR_ADAPTOR_IMMUTABLE   AFW_THROW_ERROR_Z(read_only, "Adaptor is read-only.", xctx)
 

Typedefs

typedef struct afw_adaptor_impl_core_object_type_s afw_adaptor_impl_core_object_type_t
 afw_adaptor_impl_t supported_core_object_types entry.
 

Functions

afw_adaptor_tafw_adaptor_impl_create_cede_p (const afw_adaptor_inf_t *inf, afw_size_t instance_size, const afw_object_t *properties, const afw_pool_t *p, afw_xctx_t *xctx)
 Developers should call this in all create functions for afw_adaptor. More...
 
void afw_adaptor_impl_object_type_cache_initialize (afw_adaptor_object_type_cache_t *object_type_cache, const afw_adaptor_object_type_cache_inf_t *inf, const afw_adaptor_session_t *session, afw_boolean_t all_object_types_immutable, afw_xctx_t *xctx)
 Initialize object type cache instance. More...
 
void afw_adaptor_impl_set_object_types_fully_loaded (const afw_adaptor_t *adaptor, afw_xctx_t *xctx)
 Set object types fully loaded. More...
 
const afw_object_tafw_adaptor_impl_generic_object_type_object_get (const afw_adaptor_t *adaptor, const afw_utf8_t *object_type_id, const afw_pool_t *p, afw_xctx_t *xctx)
 Create a generic object type object. More...
 
void afw_adaptor_impl_push_qualifiers (const afw_adaptor_t *adaptor, afw_xctx_t *xctx)
 Push adaptor qualifiers to xctx. More...
 
void afw_adaptor_impl_throw_property_invalid (const afw_adaptor_t *adaptor, const afw_utf8_t *property_name, afw_xctx_t *xctx)
 Developers should call this for configuration property errors. More...
 
void afw_adaptor_impl_throw_property_required (const afw_adaptor_t *adaptor, const afw_utf8_t *property_name, afw_xctx_t *xctx)
 Developers should call this for missing required configuration property. More...
 
void afw_adaptor_impl_call_object_cb_from_list (const afw_list_t *list, void *context, afw_object_cb_t callback, afw_xctx_t *xctx)
 Call object cb from list. More...
 
afw_boolean_t afw_adaptor_impl_is_journal_entry_applicable (const afw_adaptor_journal_t *instance, const afw_object_t *entry, const afw_object_t *consumer, const afw_value_t *const *filter, afw_xctx_t *xctx)
 Determine whether a journal entry is applicable to a consumer. More...
 
void afw_adaptor_impl_set_supported_core_object_type (const afw_adaptor_t *adaptor, const afw_utf8_t *object_type_id, afw_boolean_t allow_entity, afw_boolean_t allow_write, afw_xctx_t *xctx)
 Indicates support of a core object type. More...
 

Variables

 afw_adaptor_impl_object_type_cache_inf
 inf for an implementation of afw_adaptor_object_type_cache. More...
 

Detailed Description

Helpers for afw_adapor implementations.

Macro Definition Documentation

◆ AFW_ADAPTOR_IMPL_LOCK_READ_BEGIN

#define AFW_ADAPTOR_IMPL_LOCK_READ_BEGIN (   adaptor)    AFW_LOCK_READ_BEGIN((adaptor)->impl->adaptor_lock_rw)

Macro to begin an adaptor read lock section.

Parameters
adaptor
xctxof caller.

Usage:

AFW_ADAPTOR_IMPL_LOCK_READ_BEGIN(adaptor, xctx) { ... a very small amount of code that doesn't call anything that might lock this again. } AFW_ADAPTOR_IMPL_LOCK_READ_END;

Definition at line 43 of file afw_adaptor_impl.h.

◆ AFW_ADAPTOR_IMPL_LOCK_READ_END

#define AFW_ADAPTOR_IMPL_LOCK_READ_END   AFW_LOCK_READ_END

Macro to end an adaptor read lock section.

See AFW_ADAPTOR_IMPL_LOCK_READ_BEGIN for usage.

Definition at line 52 of file afw_adaptor_impl.h.

◆ AFW_ADAPTOR_IMPL_LOCK_WRITE_BEGIN

#define AFW_ADAPTOR_IMPL_LOCK_WRITE_BEGIN (   adaptor)    AFW_LOCK_WRITE_BEGIN((adaptor)->impl->adaptor_lock_rw)

Macro to begin an adaptor write lock section.

Parameters
adaptor
xctxof caller.

Usage:

AFW_ADAPTOR_IMPL_LOCK_WRITE_BEGIN(adaptor, xctx) { ... a very small amount of code that doesn't call anything that might lock this again. } AFW_ADAPTOR_IMPL_LOCK_WRITE_END;

Definition at line 69 of file afw_adaptor_impl.h.

◆ AFW_ADAPTOR_IMPL_LOCK_WRITE_END

#define AFW_ADAPTOR_IMPL_LOCK_WRITE_END   AFW_LOCK_WRITE_END

Macro to end an adaptor write lock section.

See AFW_ADAPTOR_IMPL_LOCK_WRITE_BEGIN for usage.

Definition at line 78 of file afw_adaptor_impl.h.

Function Documentation

◆ afw_adaptor_impl_call_object_cb_from_list()

void afw_adaptor_impl_call_object_cb_from_list ( const afw_list_t list,
void *  context,
afw_object_cb_t  callback,
afw_xctx_t xctx 
)

Call object cb from list.

Parameters
list
context
callback
xctxof caller.
Returns
afw_adaptor_session_retrieve_objects_result instance.

Definition at line 446 of file afw_adaptor_impl.c.

◆ afw_adaptor_impl_create_cede_p()

afw_adaptor_t* afw_adaptor_impl_create_cede_p ( const afw_adaptor_inf_t inf,
afw_size_t  instance_size,
const afw_object_t properties,
const afw_pool_t p,
afw_xctx_t xctx 
)

Developers should call this in all create functions for afw_adaptor.

Parameters
infafw_adaptor_inf_t pointer for implementation.
instance_size0 or size greater than sizeof(afw_adaptor_t).
propertiesconfig object.
startis function to call to start adaptor.
stopis function to call to stop adaptor.
pto use as parent when creating adaptor pool.
xctxof caller.
Returns
instance of afw_adaptor_t that optionally with extra memory based on instance_size parameter.

This function creates and initializes an afw_adaptor instance. After calling this function, the caller should do additional adaptor type specific processing. The instance_size parameter can be specified to get a larger instance size than sizeof(afw_adaptor_t) for adaptor type specific use.

A new pool is created in the callings xctx's pool for use by the adaptor.

This function validates and normalizes the adaptor properties based on /afw/_AdaptiveObjectType_/_AdaptiveConf_adaptor_<adaptorType>, where <adaptorType> is the value of the adaptorType property.

All properties from /afw/_AdaptiveObjectType_/_AdaptiveConf_adaptor are processed.

Some additional properties are processed if they pass validation. Properties isModelLocation and isPolicyLocation cause the appropriate core object types to be supported.

If this adaptorId is the layout adaptorId, the appropriate core object types are supported.

See afw_adaptor_impl_s for more information on how on how common adaptor code uses this information.

Todo:
FIXME: Reuse if already exists or reuse correct pool.
Todo:
FIXME: have way for extension to add these. If isPolicyLocation is true, provide appropriate object types. b = afw_object_old_get_property_as_boolean_deprecated(properties, &afw_s_isPolicyLocation, xctx); if (b) { impl->policy_location = afw_authorization_policy_internal_location_create( adaptor, p, xctx); afw_adaptor_impl_set_supported_core_object_type(adaptor, &afw_s__AdaptiveAuthorizationAdviceExpression_, false, true, xctx); afw_adaptor_impl_set_supported_core_object_type(adaptor, &afw_s__AdaptiveAuthorizationCombinerParameter_, false, true, xctx); afw_adaptor_impl_set_supported_core_object_type(adaptor, &afw_s__AdaptiveAuthorizationObligationExpression_, false, true, xctx); afw_adaptor_impl_set_supported_core_object_type(adaptor, &afw_s__AdaptiveAuthorizationPolicy_, true, true, xctx); afw_adaptor_impl_set_supported_core_object_type(adaptor, &afw_s__AdaptiveAuthorizationPolicyIssuer_, false, true, xctx); afw_adaptor_impl_set_supported_core_object_type(adaptor, &afw_s__AdaptiveAuthorizationPolicySet_, true, true, xctx); afw_adaptor_impl_set_supported_core_object_type(adaptor, &afw_s__AdaptiveAuthorizationRule_, false, true, xctx); afw_adaptor_impl_set_supported_core_object_type(adaptor, &afw_s__AdaptiveHybridProperties_, false, true, xctx); }

Definition at line 212 of file afw_adaptor_impl.c.

◆ afw_adaptor_impl_generic_object_type_object_get()

const afw_object_t* afw_adaptor_impl_generic_object_type_object_get ( const afw_adaptor_t adaptor,
const afw_utf8_t object_type_id,
const afw_pool_t p,
afw_xctx_t xctx 
)

Create a generic object type object.

Parameters
adaptor_id.
object_type_id.
pto use for result.
xctxof caller.
Returns
generic object type object (like AdaptiveObject).

This can be used by adaptors that don't have specific object types to create generic object types to return on get_object.

Todo:
FIXME: These can be cached off of impl.

Definition at line 580 of file afw_adaptor_impl.c.

◆ afw_adaptor_impl_is_journal_entry_applicable()

afw_boolean_t afw_adaptor_impl_is_journal_entry_applicable ( const afw_adaptor_journal_t instance,
const afw_object_t entry,
const afw_object_t consumer,
const afw_value_t *const *  filter,
afw_xctx_t xctx 
)

Determine whether a journal entry is applicable to a consumer.

Parameters
afw_adaptor_journalinstance.
entryfrom journal.
consumerobject.
filtershould be initialized to NULL on first call and anytime the filter has changed. The value returned should be passed to subsequent calls. This holds the evaluated expression from the consumer filter property.
xctxof caller.
Returns
true if journal entry applies to consumer.

Definition at line 470 of file afw_adaptor_impl.c.

◆ afw_adaptor_impl_object_type_cache_initialize()

void afw_adaptor_impl_object_type_cache_initialize ( afw_adaptor_object_type_cache_t object_type_cache,
const afw_adaptor_object_type_cache_inf_t inf,
const afw_adaptor_session_t session,
afw_boolean_t  all_object_types_immutable,
afw_xctx_t xctx 
)

Initialize object type cache instance.

Parameters
object_type_cacheto initialize.
inffor instance.
sessionfor instance.
all_object_types_immutablefor instance.
xctxof caller.

This can be used in implementation of method afw_adaptor_session_get_index_interface to initialize afw_adaptor_object_type_cache_t to return. Parameter should probably be defined in the sessions self.

Definition at line 618 of file afw_adaptor_impl.c.

◆ afw_adaptor_impl_push_qualifiers()

void afw_adaptor_impl_push_qualifiers ( const afw_adaptor_t adaptor,
afw_xctx_t xctx 
)

Push adaptor qualifiers to xctx.

Parameters
adaptor.
xctxof caller.

Call this to add adaptor related qualifiers to xctx. Make sure to save and restore xctx->qualifier_stack->nelts.

Definition at line 194 of file afw_adaptor_impl.c.

◆ afw_adaptor_impl_set_object_types_fully_loaded()

void afw_adaptor_impl_set_object_types_fully_loaded ( const afw_adaptor_t adaptor,
afw_xctx_t xctx 
)

Set object types fully loaded.

This can be called by adaptor implementation to indicate that all object types that last for life of adaptor have been accessed at least once. This allows gets for unknown object types to fail quicker.

Definition at line 634 of file afw_adaptor_impl.c.

◆ afw_adaptor_impl_set_supported_core_object_type()

void afw_adaptor_impl_set_supported_core_object_type ( const afw_adaptor_t adaptor,
const afw_utf8_t object_type_id,
afw_boolean_t  allow_entity,
afw_boolean_t  allow_write,
afw_xctx_t xctx 
)

Indicates support of a core object type.

Parameters
adaptor.
object_type_id.
allow_entityindicates adaptor allows entities of this type.
allow_writeindicates adaptor can store instances of this type.
xctxof caller.

afw_adaptor_impl_create_cede_p() calls this for AdaptiveObjectType with allow_write false. Other common conf parameters can cause allow_write to change to true and for other object types to be added.

After return from afw_adaptor_impl_create_cede_p(), an implementation can call this to add additional ids.

The common session impl code will use this information before calling a custom adaptor type implementation. This includes returning these object types for get/retrieve requests and insuring the objects are not modified if allow_write is false.

Todo:
FIXME: This is where object wrapper would be good to just hold deltas.

Definition at line 525 of file afw_adaptor_impl.c.

◆ afw_adaptor_impl_throw_property_invalid()

void afw_adaptor_impl_throw_property_invalid ( const afw_adaptor_t adaptor,
const afw_utf8_t property_name,
afw_xctx_t xctx 
)

Developers should call this for configuration property errors.

Parameters
adaptor.
property_namethis is in error.
xctxof caller.

Definition at line 137 of file afw_adaptor_impl.c.

◆ afw_adaptor_impl_throw_property_required()

void afw_adaptor_impl_throw_property_required ( const afw_adaptor_t adaptor,
const afw_utf8_t property_name,
afw_xctx_t xctx 
)

Developers should call this for missing required configuration property.

Parameters
adaptor.
property_namethis is in error.
xctxof caller.

Definition at line 158 of file afw_adaptor_impl.c.

Variable Documentation

◆ afw_adaptor_impl_object_type_cache_inf

afw_adaptor_impl_object_type_cache_inf

inf for an implementation of afw_adaptor_object_type_cache.

This is the inf for an implementation of afw_adaptor_object_type_cache that provided life of the adaptor cache support for object types. The address of this can be passed as the inf parameter of afw_adaptor_impl_object_type_cache_initialize() if this meets the needs of the adaptor implementation.

Definition at line 334 of file afw_adaptor_impl.h.