Internalfunctions - SmartSlog KP Library
Macros | Functions
subscription_changes.c File Reference

Interface for changes of the property. More...

#include <string.h>
#include "ss_func.h"
#include "property_changes.h"
#include "utils/list.h"
#include "utils/kp_error.h"
#include "utils/kp_debug.h"
#include "utils/check_func.h"
#include "utils/util_func.h"
#include "subscription_changes_internal.h"

Macros

#define SBCR_CH_PRINT_FORMAT

Functions

SSLOG_EXTERN int sslog_sbcr_ch_get_sequence_number (subscription_changes_data_t *changes)
 Gets a suquence number of the changes.
SSLOG_EXTERN const list_t * sslog_sbcr_ch_get_individual_by_action (subscription_changes_data_t *changes, action_type action)
 Gets all individual's UUID by action.
SSLOG_EXTERN list_t * sslog_sbcr_ch_get_individual_all (subscription_changes_data_t *changes)
 Gets all individual's UUID.
SSLOG_EXTERN const list_t * sslog_sbcr_ch_get_property_by_action (subscription_changes_data_t *changes, action_type action)
 Gets all changed properties by action.
SSLOG_EXTERN list_t * sslog_sbcr_ch_get_property_all (subscription_changes_data_t *changes)
 Gets all changed properties.
SSLOG_EXTERN list_t * sslog_sbcr_ch_get_property_by_uuid (subscription_changes_data_t *changes, const char *uuid, action_type action)
 Gets all changed properties by action for individual's UUID.
SSLOG_EXTERN list_t * sslog_sbcr_ch_get_property_by_uuid_all (subscription_changes_data_t *changes, const char *uuid)
 Gets all changed properties for individual's UUID.
SSLOG_EXTERN void sslog_sbcr_ch_print (subscription_changes_data_t *changes)
 Prints information about changes.
subscription_changes_data_tnew_subscription_changes ()
 Creates new subscription chnages data structure (.
void free_subscription_changes (subscription_changes_data_t *changes)
 Free subscription changes data structure (.
void clean_changes_data (subscription_changes_data_t *changes)
void set_sequence_number (subscription_changes_data_t *changes, int sequence_number)
void inc_sequence_number (subscription_changes_data_t *changes)
bool add_individual_to_changes (subscription_changes_data_t *changes, individual_t *individual, action_type action)
 Adds individual to the changes by action.
bool add_individual_uuid_to_changes (subscription_changes_data_t *changes, const char *uuid, action_type action)
bool add_property_to_changes (subscription_changes_data_t *changes, individual_t *owner, property_t *property, const void *new_data, const void *old_data, action_type action)
 Adds property to the changes by action.

Detailed Description

Interface for changes of the property.

Author:
Aleksandr A. Lomov lomov.nosp@m.@cs..nosp@m.karel.nosp@m.ia.r.nosp@m.u
Date:
Created on April 28, 2012, 5:17 PM

LICENSE

SmartSlog KP Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

SmartSlog KP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SmartSlog KP Library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

DESCRIPTION

subscription_changes.c - interface for changes of the subscription. Subscription changes contains iformation about chnages that were perfomed under subscribed data. This file is part of SmartSlog KP Library.

Copyright (C) 2012 - SmartSlog Team (Aleksandr A. Lomov). All rights reserved.


Macro Definition Documentation

#define SBCR_CH_PRINT_FORMAT
Value:
"\nSubscription chnages (seq = '%i'):" \
"\n\tInserted individuals: %i" \
"\n\tUpdated individuals: %i" \
"\n\tRemoved individuals: %i" \
"\n\tInserted properties: %i" \
"\n\tUpdated properties: %i" \
"\n\tRemoved properties: %i"

Function Documentation

void add_individual_to_changes ( subscription_changes_data_t changes,
individual_t individual,
action_type  action 
)

Adds individual to the changes by action.

This function adds an individual only once, if you pass an individual twice, then it does nothing.

Parameters:
[in]changessubscription changes to add (
See also:
subscription_changes_data_s).
Parameters:
[in]individualindividual that will be added to the changes (
See also:
individual_s)
Parameters:
[in]actionaction that was perfomed under individual: insert, remove, update.
Returns:
true on success(individual has been added or was already in the changes) or false otherwise.
bool add_individual_uuid_to_changes ( subscription_changes_data_t changes,
const char *  uuid,
action_type  action 
)
bool add_property_to_changes ( subscription_changes_data_t changes,
individual_t owner,
property_t property,
const void *  new_data,
const void *  old_data,
action_type  action 
)

Adds property to the changes by action.

Also the function adds owner(individual) to changes as updated individual. You do not need to add individual by youself. Owner will be add to the changes only once.

Parameters:
[in]changessubscription changes to add (
See also:
subscription_changes_data_s).
Parameters:
[in]ownerindividual who has changed property (
See also:
individual_s).
Parameters:
[in]propertyproperty that was changed (
See also:
property_s).
Parameters:
[in]new_datacurrent data(string or individual) of the property.
[in]old_dataprevious data(string or individual) of the property.
[in]actionaction that was perfomed under property: insert, update, remove.
Returns:
true on success or false otherwise.
void clean_changes_data ( subscription_changes_data_t changes)
free_subscription_changes ( subscription_changes_data_t changes)

Free subscription changes data structure (.

See also:
subscription_changes_data_s).
Parameters:
[in]changesstructure for free, if parameter is NULL then it does nothing.
void inc_sequence_number ( subscription_changes_data_t changes)
subscription_changes_data_t * new_subscription_changes ( )

Creates new subscription chnages data structure (.

See also:
subscription_changes_data_s).
Returns:
new struct on success or NULL otherwise.
void set_sequence_number ( subscription_changes_data_t changes,
int  sequence_number 
)
SSLOG_EXTERN list_t* sslog_sbcr_ch_get_individual_all ( subscription_changes_data_t changes)

Gets all individual's UUID.

It make one list with all individual's UUIDs, that are were inserted, updated or removed.

You need to free the returned list, but without data relesed. Use #list_free_with_nodes with NULL as argument for free function.

Known bug: if under the individual was perfomed more that one actions, for example it was inserted and updated, then UUID will be inserted to list more that once. This will be fixed later.

This function sets a global error if it can't perfome operation, you can get an error code using #get_error_code function.

Parameters:
[in]changeschanges to get individuals UUIDs.
Returns:
list with UUIDs (list with strings) on success or NULL otherwise.
SSLOG_EXTERN const list_t* sslog_sbcr_ch_get_individual_by_action ( subscription_changes_data_t changes,
action_type  action 
)

Gets all individual's UUID by action.

Individuals can be inserted, removed or updated. Updated means that some properties of the individual were changed.

Do not modify or free returned list.

This function sets a global error if it can't perfome operation, you can get an error code using #get_error_code function.

Parameters:
[in]changessubscription chnages data structure.
[in]actionaction that was perfom under individuals: insert, remove, update.
Returns:
list with individuals UUIDs (list with strings) or NULL if given changes or action is incorrect.
SSLOG_EXTERN list_t* sslog_sbcr_ch_get_property_all ( subscription_changes_data_t changes)

Gets all changed properties.

You need to free the returned list, but without data relesed. Use #list_free_with_nodes with NULL as argument for free function.

This function sets a global error if it can't perfome operation, you can get an error code using #get_error_code function.

Parameters:
[in]changeschanges to get properties.
Returns:
list with properties changes (list with property_changes_data_s) on success or NULL otherwise.
See also:
property_changes_data_s
SSLOG_EXTERN const list_t* sslog_sbcr_ch_get_property_by_action ( subscription_changes_data_t changes,
action_type  action 
)

Gets all changed properties by action.

Do not modify or free returned list.

This function sets a global error if it can't perfome operation, you can get an error code using #get_error_code function.

Parameters:
[in]changeschanges to get properties.
[in]actionaction that was perfom under properties: insert, remove, update.
Returns:
list with properties changes (list with property_changes_data_s) or NULL if given changes or action is incorrect.
See also:
property_changes_data_s
SSLOG_EXTERN list_t* sslog_sbcr_ch_get_property_by_uuid ( subscription_changes_data_t changes,
const char *  uuid,
action_type  action 
)

Gets all changed properties by action for individual's UUID.

This function can returns list for updated individuals, for other returned list will be empty.

You need to free the returned list, but without data relesed. Use #list_free_with_nodes with NULL as argument for free function.

This function sets a global error if it can't perfome operation, you can get an error code using #get_error_code function.

Parameters:
[in]changeschanges to get properties.
[in]uuidindividual's UUID to get properties.
[in]actionaction that was perfom under properties: insert, remove, update.
Returns:
list with properties changes (list with property_changes_data_s) or NULL if given changes or action is incorrect.
See also:
property_changes_data_s
SSLOG_EXTERN list_t* sslog_sbcr_ch_get_property_by_uuid_all ( subscription_changes_data_t changes,
const char *  uuid 
)

Gets all changed properties for individual's UUID.

This function can returns list for updated individuals, for other returned list will be empty.

You need to free the returned list, but without data relesed. Use #list_free_with_nodes with NULL as argument for free function.

This function sets a global error if it can't perfome operation, you can get an error code using #get_error_code function.

Parameters:
[in]changeschanges to get properties.
[in]uuidindividual's UUID to get properties.
Returns:
list with properties changes (list with property_changes_data_s) or NULL if given changes or action is incorrect.
See also:
property_changes_data_s
SSLOG_EXTERN int sslog_sbcr_ch_get_sequence_number ( subscription_changes_data_t changes)

Gets a suquence number of the changes.

Changes are made based on data that were received with notification. This number is sequence of indication that was used to make changes. Firts changes are made while perfoming subscription operation, this changes has '1' as this number.

This function sets a global error if it can't perfome operation, you can get an error code using #get_error_code function.

Parameters:
[in]changessubscription chnages data structure.
Returns:
sequence number of the chnages.
SSLOG_EXTERN void sslog_sbcr_ch_print ( subscription_changes_data_t changes)

Prints information about changes.

It prints sequence number and how manu individuals and properties were inserted, updated or removed.

Parameters:
[in]changeschanges to print information about changes.