blob: 5ea2215907bbd128e6e857e326eb9fff2c796101 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/* EIOTAS
* Copyright (C) 2012 Jérémy Zurcher
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EIOTAS_PARTICLE_H__
#define __EIOTAS_PARTICLE_H__
#include <time.h>
#include <eina_hash.h>
#include <eina_array.h>
#include <eina_inlist.h>
#include <eina_stringshare.h>
#include "eiotas_iota.h"
/**
* @typedef Eiotas_Particle
* Type for a Particle, holding data and spinning from Iotas to Iotas.
*/
typedef struct _Eiotas_Particle Eiotas_Particle;
/**
* @struct _Eiotas_Particle
* Struct for a Particle, holding data and spinning from Iotas to Iotas.
*/
struct _Eiotas_Particle {
EINA_INLIST; /**< the Eina_Inlist info */
time_t ts; /**< creation time */
Eiotas_Iota *src; /**< where it's born */
Eiotas_Iota *dst; /**< current destination */
Eina_Array *dsts; /**< array of destinatinon strings */
Eina_Hash *payload; /**< string data carried by this particle */
Eina_Inlist *merged; /**< list of merged particles */
Eina_Array *link_fields; /**< fields used to generate the link value */
Eina_Stringshare *link_value; /**< computed from link_fields and paylod, used for pearing particles */
};
/**
* @defgroup Eiotas_Particle Eiotas_Particle
*
* The central part of Eiotas. The Particle holds, the data, the destination list.
*
* @{
*/
/**
* @brief Free allocated resources.
*
* @param particle The @ref Eiotas_Particle to free.
*
* This function will free all the merged @ref Eiotas_Particle
*/
void eiotas_particle_free(Eiotas_Particle *particle);
/**
* @brief Allocate the resources.
*
* @return the new allocated @ref Eiotas_Particle @c NULL on failure
*/
Eiotas_Particle* eiotas_particle_alloc();
/**
* @brief Reset the @ref Eiotas_Particle so that it can be required later.
*
* @param particle The @ref Eiotas_Particle to reset
*/
EAPI void eiotas_particle_reset(Eiotas_Particle *particle);
/**
* @brief Set @c src and @c ts timestamp.
*
* @param particle The @ref Eiotas_Particle to init
* @param iota The @ref Eiotas_Iota wich will be set as @c src
*/
EAPI void eiotas_particle_init(Eiotas_Particle *particle, Eiotas_Iota *iota);
/**
* @brief Merge a particle into the other.
*
* @param particle The @ref Eiotas_Particle to hold @p p
* @param p The @ref Eiotas_Particle to be merged into @p particle
*/
EAPI void eiotas_particle_merge(Eiotas_Particle *particle, Eiotas_Particle *p);
/**
* @brief Add destinations to the @ref Eiotas_Particle
*
* @param particle The @ref Eiotas_Particle to add destinations to
* @param destinations A comma separated list of destination "/room0/room1/.../doorx?action"
*
* This function will append each destination found to the destination list of the @ref Eiotas_Particle.
*/
EAPI void eiotas_particle_add_destinations(Eiotas_Particle *particle, char* destinations);
/**
* @}
*/
#endif // __EIOTAS_PARTICLE_H__
|