summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-06-01 10:30:22 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-06-01 10:30:22 +0200
commit090d38ec3cfff930366327fe7460aecb00ffaa02 (patch)
tree5a8f1c73fe13e9d65e9f8ccb9cc645f625165011 /src
parent7f4ca37aaae8229bbf0deae35d35b24f96b16e78 (diff)
downloadedoors-090d38ec3cfff930366327fe7460aecb00ffaa02.zip
edoors-090d38ec3cfff930366327fe7460aecb00ffaa02.tar.gz
add eiotas_particle_has_dst with tests
Diffstat (limited to 'src')
-rw-r--r--src/include/eiotas_particle.h12
-rw-r--r--src/lib/eiotas_particle.c7
2 files changed, 18 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;