*/
int ctx_sched_job_destroy(ctx_sched_job_h job);
-/**
- * @brief Serializes a job handle.
- * @remarks This function is not thread safe.
- * @param[in] job Job handle
- * @return The Json representation of @c job
- */
-const char* ctx_sched_job_serialize(ctx_sched_job_h job);
-
/**
* @brief Adds a trigger context to a job.
int ctx_sched_publish_context_json(ctx_sched_h scheduler, const char* uri, const char* json_payload);
+/**
+ * @brief Serializes a job handle.
+ * @remarks This function is not thread safe.
+ * @param[in] job Job handle
+ * @return The Json representation of @c job
+ */
+const char* ctx_sched_job_serialize(ctx_sched_job_h job);
+
+/**
+ * @brief Serializes a job context handle.
+ * @remarks This function is not thread safe.
+ * @param[in] job_context Job context handle
+ * @return The Json representation of @c job_context
+ */
+const char* ctx_sched_job_context_serialize(ctx_sched_job_context_h job_context);
+
+// Job context handler duplicator
+ctx_sched_job_context_h ctx_sched_job_context_duplicate(ctx_sched_job_context_h job_context);
+
// Logical-disjunction modifiers to support legacy Context-Trigger API.
// NOT recommended to use.
int ctx_sched_job_set_disjunction(ctx_sched_job_h job, bool disjunction);
int ctx_sched_custom_unregister(ctx_sched_h scheduler, const char* uri);
int ctx_sched_custom_is_registered(ctx_sched_h scheduler, const char* uri, const char* pkg_id, bool* registered);
-// Job context handler duplicator
-ctx_sched_job_context_h ctx_sched_job_context_duplicate(ctx_sched_job_context_h job_context);
-
/**
* @}
*/
return E_SUPPORT;
}
-EXPORT_API const char* ctx_sched_job_serialize(ctx_sched_job_h job)
-{
- return EMPTY_STR;
-}
-
EXPORT_API int ctx_sched_job_add_trigger(ctx_sched_job_h job, ctx_sched_job_context_h trigger)
{
return E_SUPPORT;
return E_SUPPORT;
}
+EXPORT_API const char* ctx_sched_job_serialize(ctx_sched_job_h job)
+{
+ return EMPTY_STR;
+}
+
+EXPORT_API const char* ctx_sched_job_context_serialize(ctx_sched_job_context_h job_context)
+{
+ return EMPTY_STR;
+}
+
+EXPORT_API ctx_sched_job_context_h ctx_sched_job_context_duplicate(ctx_sched_job_context_h job_context)
+{
+ return NULL;
+}
+
EXPORT_API int ctx_sched_job_set_disjunction(ctx_sched_job_h job, bool disjunction)
{
return E_SUPPORT;
{
return E_SUPPORT;
}
-
-EXPORT_API ctx_sched_job_context_h ctx_sched_job_context_duplicate(ctx_sched_job_context_h job_context)
-{
- return NULL;
-}
return E_NONE;
}
-EXPORT_API const char* ctx_sched_job_serialize(ctx_sched_job_h job)
-{
- static std::string serialized;
-
- Json::Value jsonRoot;
- Json::StyledWriter writer;
-
- job->jobInfo->toJson(jsonRoot);
- serialized = writer.write(jsonRoot);
-
- return serialized.c_str();
-}
-
EXPORT_API int ctx_sched_job_add_trigger(ctx_sched_job_h job, ctx_sched_job_context_h trigger)
{
IF_FAIL_RETURN(job && trigger, E_PARAM);
return scheduler->jobManager.publishContext(uri, json_payload);
}
+EXPORT_API const char* ctx_sched_job_serialize(ctx_sched_job_h job)
+{
+ static std::string serialized;
+
+ Json::Value jsonRoot;
+ Json::StyledWriter writer;
+
+ job->jobInfo->toJson(jsonRoot);
+ serialized = writer.write(jsonRoot);
+
+ return serialized.c_str();
+}
+
+EXPORT_API const char* ctx_sched_job_context_serialize(ctx_sched_job_context_h job_context)
+{
+ static std::string serialized;
+
+ Json::Value jsonRoot;
+ Json::StyledWriter writer;
+
+ job_context->jobContext->toJson(jsonRoot);
+ serialized = writer.write(jsonRoot);
+
+ return serialized.c_str();
+}
+
+EXPORT_API ctx_sched_job_context_h ctx_sched_job_context_duplicate(ctx_sched_job_context_h job_context)
+{
+ IF_FAIL_RETURN(job_context, NULL);
+
+ ctx_sched_job_context_s* dup = new(std::nothrow) ctx_sched_job_context_s();
+ IF_FAIL_RETURN_TAG(dup, NULL, _E, E_STR_ALLOC);
+
+ if (!job_context->jobContext)
+ return dup;
+
+ if (job_context->jobContext->getType() == JobContext::Type::TRIGGER)
+ dup->jobContext = new(std::nothrow) JobTrigger(*static_cast<JobTrigger*>(job_context->jobContext));
+ else
+ dup->jobContext = new(std::nothrow) JobRequirement(*static_cast<JobRequirement*>(job_context->jobContext));
+
+ if (!dup->jobContext) {
+ _E_ALLOC;
+ delete dup;
+ return NULL;
+ }
+
+ return dup;
+}
+
EXPORT_API int ctx_sched_job_set_disjunction(ctx_sched_job_h job, bool disjunction)
{
IF_FAIL_RETURN(job, E_PARAM);
return E_NONE;
}
-
-EXPORT_API ctx_sched_job_context_h ctx_sched_job_context_duplicate(ctx_sched_job_context_h job_context)
-{
- IF_FAIL_RETURN(job_context, NULL);
-
- ctx_sched_job_context_s* dup = new(std::nothrow) ctx_sched_job_context_s();
- IF_FAIL_RETURN_TAG(dup, NULL, _E, E_STR_ALLOC);
-
- if (!job_context->jobContext)
- return dup;
-
- if (job_context->jobContext->getType() == JobContext::Type::TRIGGER)
- dup->jobContext = new(std::nothrow) JobTrigger(*static_cast<JobTrigger*>(job_context->jobContext));
- else
- dup->jobContext = new(std::nothrow) JobRequirement(*static_cast<JobRequirement*>(job_context->jobContext));
-
- if (!dup->jobContext) {
- _E_ALLOC;
- delete dup;
- return NULL;
- }
-
- return dup;
-}