diff options
-rw-r--r-- | src/include/eiotas_particle.h | 12 | ||||
-rw-r--r-- | src/lib/eiotas_particle.c | 7 | ||||
-rw-r--r-- | tests/particle.c | 3 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/include/eiotas_particle.h b/src/include/eiotas_particle.h index f094904..4461945 100644 --- a/src/include/eiotas_particle.h +++ b/src/include/eiotas_particle.h @@ -43,6 +43,7 @@ struct _Eiotas_Particle { Eiotas_Iota *src; /**< where it's born */ Eiotas_Iota *dst; /**< current destination */ Eina_Array *dsts; /**< array of destinatinon strings */ + unsigned int cur_dst; /**< current destination index */ 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 */ @@ -97,6 +98,15 @@ EAPI void eiotas_particle_init(Eiotas_Particle *particle, Eiotas_Iota *iota); EAPI void eiotas_particle_merge(Eiotas_Particle *particle, const Eiotas_Particle *p); /** + * @brief Check if a current destination is defined + * + * @param particle The @ref Eiotas_Particle to check + * + * @return EINA_TRUE if a current destination is defined, EINA_FALSE otherwise. + */ +EAPI Eina_Bool eiotas_particle_has_dst(Eiotas_Particle *particle); + +/** * @brief Add destinations to the @ref Eiotas_Particle * * @param particle The @ref Eiotas_Particle to add destinations to @@ -147,7 +157,7 @@ EAPI Eina_Bool eiotas_particle_data_set(Eiotas_Particle *particle, const char *k EAPI Eina_Bool eiotas_particle_data_del(Eiotas_Particle *particle, const char *key); /** - * @brief Check if two @ref Eiotas_Particle have the same lnk_value + * @brief Check if two @ref Eiotas_Particle have the same link_value * * @param particle The @ref Eiotas_Particle to compare with * @param p The @ref Eiotas_Particle to compare with diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index 74e1d23..ea00b5c 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -33,6 +33,7 @@ Eiotas_Particle* eiotas_particle_alloc() particle->merged = NULL; particle->link_fields = eina_array_new(EIOTAS_PARTICLE_ARRAY_STEP); particle->link_value = NULL; + particle->cur_dst = 0; return particle; } @@ -91,6 +92,12 @@ EAPI void eiotas_particle_merge(Eiotas_Particle *particle, const Eiotas_Particle particle->merged = eina_inlist_append(particle->merged, EINA_INLIST_GET((Eiotas_Particle*)p)); } +EAPI Eina_Bool eiotas_particle_has_dst(Eiotas_Particle *particle) +{ + if(eina_array_count_get(particle->dsts)<=particle->cur_dst) return EINA_FALSE; + return ( (eina_array_data_get(particle->dsts,particle->cur_dst)==NULL) ? EINA_FALSE : EINA_TRUE ); +} + EAPI void eiotas_particle_destinations_add(Eiotas_Particle *particle, const char* destinations) { int n; diff --git a/tests/particle.c b/tests/particle.c index 823ac12..2734eff 100644 --- a/tests/particle.c +++ b/tests/particle.c @@ -11,7 +11,10 @@ void test_particle() p0 = eiotas_require_particle(dom0); + check_cond(!eiotas_particle_has_dst(p0),"should be no destination"); + eiotas_particle_destinations_add(p0,"dom0/room0/door0?get"); + check_cond(eiotas_particle_has_dst(p0),"should be a destination"); eiotas_particle_destinations_add(p0," dom0/room0/door0?get "); eiotas_particle_destinations_add(p0," dom0/room0/door0?get "); eiotas_particle_destinations_add(p0,"dom0/room0/room1/doorx?get,door?get,dom0/room0/door0?get"); |