Add an internal API function ctx_sched_job_serialize() 89/140589/2
authorMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 25 Jul 2017 12:11:19 +0000 (21:11 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 25 Jul 2017 12:29:12 +0000 (21:29 +0900)
This function is for testing purpose.

Change-Id: I296ff90fc926d7a544f5ef85291bf4df205d107d
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/job_scheduler_internal.h
src/client-dummy/job_scheduler.cpp
src/client/job_scheduler.cpp

index 714a136ef5aa0c0aa466873f4639dc4d3deffb06..ba0426ed167a026b174250992a04133fdcafd199 100644 (file)
@@ -221,6 +221,14 @@ int ctx_sched_job_create_on_demand(ctx_sched_job_h* job);
  */
 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.
index 1aa7a3bb01e081b36a84b78736e8d97a56fc55de..3c9fc7484c2e27203159b90f9173585876443e82 100644 (file)
@@ -109,6 +109,11 @@ EXPORT_API int ctx_sched_job_destroy(ctx_sched_job_h job)
        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;
index 2dcab3a6e75f325529acad31d727922ac02c84dc..8e6bfffc3433452c0617d57d92bf8228140d8cdb 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <algorithm>
+#include <json/json.h>
 #include <JobSchedulerTypesPrivate.h>
 #include <job_scheduler_internal.h>
 #include <JobInfo.h>
@@ -304,6 +305,19 @@ EXPORT_API int ctx_sched_job_destroy(ctx_sched_job_h job)
        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);