{
}
-const std::string& Attribute::getName()
+const std::string& Attribute::getName() const
{
return __name;
}
{
}
-Attribute::Type IntegerAttribute::getType()
+Attribute::Type IntegerAttribute::getType() const
{
return Attribute::Type::INTEGER;
}
return *this;
}
-void IntegerAttribute::toJson(Json::Value& jsonNode)
+void IntegerAttribute::toJson(Json::Value& jsonNode) const
{
jsonNode[KEY_DATA_TYPE] = static_cast<int>(Type::INTEGER);
{
}
-Attribute::Type StringAttribute::getType()
+Attribute::Type StringAttribute::getType() const
{
return Attribute::Type::STRING;
}
return *this;
}
-void StringAttribute::toJson(Json::Value& jsonNode)
+void StringAttribute::toJson(Json::Value& jsonNode) const
{
jsonNode[KEY_DATA_TYPE] = static_cast<int>(Type::STRING);
public:
enum class Type {
INTEGER = 1,
+ //DOUBLE = 2,
STRING = 3
};
virtual ~Attribute();
- virtual Attribute::Type getType() = 0;
- virtual void toJson(Json::Value& jsonNode) = 0;
+ virtual Attribute::Type getType() const = 0;
+ virtual void toJson(Json::Value& jsonNode) const = 0;
- const std::string& getName();
+ const std::string& getName() const;
static Attribute* build(const std::string& name, Json::Value& jsonNode);
public:
IntegerAttribute(const std::string& name);
IntegerAttribute(const std::string& name, Json::Value& jsonNode);
-
~IntegerAttribute();
- Attribute::Type getType();
+ Attribute::Type getType() const;
IntegerAttribute& setClosedLowerBound(int bound);
IntegerAttribute& setClosedUpperBound(int bound);
IntegerAttribute& addTarget(int target);
IntegerAttribute& addNonTarget(int nonTarget);
- void toJson(Json::Value& jsonNode);
+ void toJson(Json::Value& jsonNode) const;
private:
int __closedLowerBound;
public:
StringAttribute(const std::string& name);
StringAttribute(const std::string& name, Json::Value& jsonNode);
-
~StringAttribute();
- Attribute::Type getType();
+ Attribute::Type getType() const;
StringAttribute& addTarget(const std::string& target);
StringAttribute& addNonTarget(const std::string& nonTarget);
- void toJson(Json::Value& jsonNode);
+ void toJson(Json::Value& jsonNode) const;
private:
std::set<std::string> __targets;
static bundle* __stringToBundle(const std::string& str)
{
- return bundle_decode(reinterpret_cast<const unsigned char*>(str.c_str()), str.size());
+ return bundle_decode(reinterpret_cast<const unsigned char*>(str.c_str()), strlen(str.c_str()));
}
JobAction::JobAction()
g_variant_unref(__parameters);
}
-JobAction::Type JobDBusCall::getType()
+JobAction::Type JobDBusCall::getType() const
{
return JobAction::Type::DBUS_METHOD;
}
-const std::string& JobDBusCall::getBusName()
+const std::string& JobDBusCall::getBusName() const
{
return __busName;
}
-const std::string& JobDBusCall::getObjectPath()
+const std::string& JobDBusCall::getObjectPath() const
{
return __objectPath;
}
-const std::string& JobDBusCall::getInterface()
+const std::string& JobDBusCall::getInterface() const
{
return __interface;
}
-const std::string& JobDBusCall::getMethodName()
+const std::string& JobDBusCall::getMethodName() const
{
return __methodName;
}
return __parameters;
}
-void JobDBusCall::toJson(Json::Value& jsonNode)
+void JobDBusCall::toJson(Json::Value& jsonNode) const
{
Json::Value& node = jsonNode[KEY_DBUS];
bundle_free(__appCtrlBundle);
}
-JobAction::Type JobAppControl::getType()
+JobAction::Type JobAppControl::getType() const
{
return JobAction::Type::APP_CONTROL;
}
return __appCtrlBundle;
}
-void JobAppControl::toJson(Json::Value& jsonNode)
+void JobAppControl::toJson(Json::Value& jsonNode) const
{
jsonNode[KEY_APP_CTRL][KEY_BUNDLE] = __bundleToString(__appCtrlBundle);
}
bundle_free(__appCtrlBundle);
}
-JobAction::Type JobNotification::getType()
+JobAction::Type JobNotification::getType() const
{
return JobAction::Type::NOTIFICATION;
}
-const std::string& JobNotification::getTitle()
+const std::string& JobNotification::getTitle() const
{
return __title;
}
-const std::string& JobNotification::getContent()
+const std::string& JobNotification::getContent() const
{
return __content;
}
-const std::string& JobNotification::getIconPath()
+const std::string& JobNotification::getIconPath() const
{
return __iconPath;
}
return __appCtrlBundle;
}
-void JobNotification::toJson(Json::Value& jsonNode)
+void JobNotification::toJson(Json::Value& jsonNode) const
{
Json::Value& node = jsonNode[KEY_NOTI];
};
virtual ~JobAction();
- virtual Type getType() = 0;
- virtual void toJson(Json::Value& jsonNode) = 0;
+
+ virtual Type getType() const = 0;
+
+ virtual void toJson(Json::Value& jsonNode) const = 0;
static JobAction* build(Json::Value& jsonNode);
JobDBusCall(const std::string& busName, const std::string& objPath,
const std::string& interface, const std::string& methodName, GVariant* param);
JobDBusCall(Json::Value& jsonNode);
-
~JobDBusCall();
- JobAction::Type getType();
+ JobAction::Type getType() const;
- const std::string& getBusName();
- const std::string& getObjectPath();
- const std::string& getInterface();
- const std::string& getMethodName();
+ const std::string& getBusName() const;
+ const std::string& getObjectPath() const;
+ const std::string& getInterface() const;
+ const std::string& getMethodName() const;
GVariant* getParameters();
- void toJson(Json::Value& jsonNode);
+ void toJson(Json::Value& jsonNode) const;
private:
std::string __busName;
public:
JobAppControl(bundle* appCtrlBundle);
JobAppControl(Json::Value& jsonNode);
-
~JobAppControl();
- JobAction::Type getType();
+ JobAction::Type getType() const;
bundle* getAppControl();
- void toJson(Json::Value& jsonNode);
+ void toJson(Json::Value& jsonNode) const;
private:
bundle* __appCtrlBundle;
JobNotification(const std::string& title, const std::string& content,
const std::string& iconPath, bundle* appCtrlBundle);
JobNotification(Json::Value& jsonNode);
-
~JobNotification();
- JobAction::Type getType();
+ JobAction::Type getType() const;
- const std::string& getTitle();
- const std::string& getContent();
- const std::string& getIconPath();
+ const std::string& getTitle() const;
+ const std::string& getContent() const;
+ const std::string& getIconPath() const;
bundle* getAppControl();
- void toJson(Json::Value& jsonNode);
+ void toJson(Json::Value& jsonNode) const;
private:
std::string __title;
}
}
-const std::string& JobContext::getUri()
+const std::string& JobContext::getUri() const
{
return __uri;
}
return true;
}
-JobContext& JobContext::setDisjunction(bool disjunction)
-{
- __disjunction = disjunction;
- return *this;
-}
-
-void JobContext::toJson(Json::Value& jsonNode)
+void JobContext::toJson(Json::Value& jsonNode) const
{
__toJson(jsonNode);
Json::Value& attrNode = jsonNode[KEY_ATTRIBUTE];
jsonNode[KEY_DISJUNCTION] = __disjunction;
}
+bool JobContext::isDisjunction() const
+{
+ return __disjunction;
+}
+
+JobContext& JobContext::setDisjunction(bool disjunction)
+{
+ __disjunction = disjunction;
+ return *this;
+}
+
JobTrigger::JobTrigger(const std::string& uri) :
JobContext(uri)
{
}
-JobContext::Type JobTrigger::getType()
+JobContext::Type JobTrigger::getType() const
{
return JobContext::Type::TRIGGER;
}
-void JobTrigger::__toJson(Json::Value& jsonNode)
+void JobTrigger::__toJson(Json::Value& jsonNode) const
{
}
{
}
-JobContext::Type JobRequirement::getType()
+JobContext::Type JobRequirement::getType() const
{
return JobContext::Type::REQUIREMENT;
}
-bool JobRequirement::isOptional()
+bool JobRequirement::isOptional() const
{
return __optional;
}
-void JobRequirement::__toJson(Json::Value& jsonNode)
+void JobRequirement::__toJson(Json::Value& jsonNode) const
{
jsonNode[KEY_OPTIONAL] = __optional;
}
virtual ~JobContext();
- virtual JobContext::Type getType() = 0;
+ virtual JobContext::Type getType() const = 0;
- const std::string& getUri();
+ const std::string& getUri() const;
Attribute* getAttribute(const std::string& attrName);
+
bool prepareAttributeInt(const std::string& attrName);
bool prepareAttributeStr(const std::string& attrName);
- void toJson(Json::Value& jsonNode);
+ void toJson(Json::Value& jsonNode) const;
/* Legacy support */
+ bool isDisjunction() const;
JobContext& setDisjunction(bool disjunction);
protected:
JobContext(const std::string& uri, Json::Value& jsonNode);
private:
- virtual void __toJson(Json::Value& jsonNode) = 0;
+ virtual void __toJson(Json::Value& jsonNode) const = 0;
std::string __uri;
std::list<Attribute*> __attributes;
public:
JobTrigger(const std::string& uri);
JobTrigger(const std::string& uri, Json::Value& jsonNode);
-
~JobTrigger();
- JobContext::Type getType();
+ JobContext::Type getType() const;
private:
- void __toJson(Json::Value& jsonNode);
+ void __toJson(Json::Value& jsonNode) const;
};
public:
JobRequirement(const std::string& uri, bool optional);
JobRequirement(const std::string& uri, Json::Value& jsonNode);
-
~JobRequirement();
- JobContext::Type getType();
+ JobContext::Type getType() const;
- bool isOptional();
+ bool isOptional() const;
private:
- void __toJson(Json::Value& jsonNode);
+ void __toJson(Json::Value& jsonNode) const;
bool __optional;
};
using namespace ctx;
JobInfo::JobInfo() :
+ __jobId(-1),
+ __started(false),
__oneTime(false),
__persistent(false),
__requirementTimeout(0),
__action(NULL),
- __jobId(-1),
- __started(false),
__disjunction(false)
{
}
delete __action;
}
-bool JobInfo::operator==(const JobInfo& rhs)
+int JobInfo::getId() const
{
- //TODO: compare two JobInfo, but ignore jobId & started flag
- return false;
+ return __jobId;
}
-const std::string& JobInfo::getUserData()
+bool JobInfo::isStarted() const
{
- return __userData;
+ return __started;
}
-JobInfo& JobInfo::setOneTime(bool oneTime)
+bool JobInfo::isOneTime() const
{
- __oneTime = oneTime;
- return *this;
+ return __oneTime;
}
-JobInfo& JobInfo::setPersistent(bool persistent)
+bool JobInfo::isPersistent() const
{
- __persistent = persistent;
+ return __persistent;
+}
+
+std::list<JobRequirement*>& JobInfo::getRequirements()
+{
+ return __requirements;
+}
+
+unsigned int JobInfo::getRequirementTimeout() const
+{
+ return __requirementTimeout;
+}
+
+JobAction* JobInfo::getAction()
+{
+ return __action;
+}
+
+const std::string& JobInfo::getUserData() const
+{
+ return __userData;
+}
+
+JobInfo& JobInfo::setId(int jobId)
+{
+ __jobId = jobId;
return *this;
}
-bool JobInfo::isPersistent()
+JobInfo& JobInfo::setStarted(bool started)
{
- return __persistent;
+ __started = started;
+ return *this;
}
-JobInfo& JobInfo::setRequirementTimeout(unsigned int timeoutMs)
+JobInfo& JobInfo::setOneTime(bool oneTime)
{
- __requirementTimeout = timeoutMs;
+ __oneTime = oneTime;
return *this;
}
-JobInfo& JobInfo::setUserData(const std::string& userData)
+JobInfo& JobInfo::setPersistent(bool persistent)
{
- __userData = userData;
+ __persistent = persistent;
return *this;
}
return *this;
}
-std::list<JobRequirement*>& JobInfo::getRequirements()
+JobInfo& JobInfo::setRequirementTimeout(unsigned int timeoutMs)
{
- return __requirements;
+ __requirementTimeout = timeoutMs;
+ return *this;
}
JobInfo& JobInfo::setAction(JobAction* action)
return *this;
}
-JobAction* JobInfo::getAction()
+JobInfo& JobInfo::setUserData(const std::string& userData)
{
- return __action;
+ __userData = userData;
+ return *this;
}
-std::string JobInfo::serialize()
+std::string JobInfo::serialize() const
{
Json::Value jsonRoot;
toJson(jsonRoot);
return fastWriter.write(jsonRoot);
}
-void JobInfo::toJson(Json::Value& jsonRoot)
+void JobInfo::toJson(Json::Value& jsonRoot) const
{
jsonRoot[KEY_JOB_TYPE] = static_cast<int>(getType());
jsonRoot[KEY_ONE_TIME] = __oneTime;
jsonRoot[KEY_DISJUNCTION] = __disjunction;
}
-void JobInfo::setId(int jobId)
+bool JobInfo::operator==(const JobInfo& rhs) const
{
- __jobId = jobId;
-}
-
-int JobInfo::getId()
-{
- return __jobId;
-}
-
-void JobInfo::setStarted(bool started)
-{
- __started = started;
+ //TODO: compare two JobInfo, but ignore jobId & started flag
+ return false;
}
-bool JobInfo::isStarted()
+bool JobInfo::isDisjunction() const
{
- return __started;
+ return __disjunction;
}
JobInfo& JobInfo::setDisjunction(bool disjunction)
return JobInfo::Type::PERIODIC;
}
-void PeriodicJobInfo::__toJson(Json::Value& jsonRoot)
+void PeriodicJobInfo::__toJson(Json::Value& jsonRoot) const
{
jsonRoot[KEY_INTERVAL] = __intervalMin;
jsonRoot[KEY_ANCHOR] = static_cast<int64_t>(__anchor);
{
}
+std::list<JobTrigger*>& OnDemandJobInfo::getTriggers()
+{
+ return __triggers;
+}
+
OnDemandJobInfo& OnDemandJobInfo::addTrigger(JobTrigger* trigger)
{
if (trigger)
return *this;
}
-std::list<JobTrigger*>& OnDemandJobInfo::getTriggers()
-{
- return __triggers;
-}
-
-void OnDemandJobInfo::__toJson(Json::Value& jsonRoot)
+void OnDemandJobInfo::__toJson(Json::Value& jsonRoot) const
{
for (auto& trig : __triggers) {
trig->toJson(jsonRoot[KEY_TRIGGER][trig->getUri()]);
virtual JobInfo::Type getType() const = 0;
- bool operator==(const JobInfo& rhs);
+ int getId() const;
- const std::string& getUserData();
+ bool isStarted() const;
+ bool isOneTime() const;
+ bool isPersistent() const;
+ std::list<JobRequirement*>& getRequirements();
+ unsigned int getRequirementTimeout() const;
+
+ JobAction* getAction();
+
+ const std::string& getUserData() const;
+
+ JobInfo& setId(int jobId);
+
+ JobInfo& setStarted(bool started);
JobInfo& setOneTime(bool oneTime);
JobInfo& setPersistent(bool persistent);
- bool isPersistent();
- JobInfo& setRequirementTimeout(unsigned int timeoutMs);
-
- // UserData should be a string that can be a string element of Json
- JobInfo& setUserData(const std::string& userData);
JobInfo& addRequirement(JobRequirement* req);
- std::list<JobRequirement*>& getRequirements();
+ JobInfo& setRequirementTimeout(unsigned int timeoutMs);
JobInfo& setAction(JobAction* action);
- JobAction* getAction();
- std::string serialize();
- void toJson(Json::Value& jsonRoot);
+ // UserData should be a string that can be a string element of Json
+ JobInfo& setUserData(const std::string& userData);
- void setId(int jobId);
- int getId();
+ std::string serialize() const;;
+ void toJson(Json::Value& jsonRoot) const;
- void setStarted(bool started);
- bool isStarted();
+ bool operator==(const JobInfo& rhs) const;
/* Legacy support */
+ bool isDisjunction() const;
JobInfo& setDisjunction(bool disjunction);
static JobInfo* deserialize(const std::string& serializedStr);
JobInfo(Json::Value& jsonRoot, const std::string& serializedStr);
private:
- virtual void __toJson(Json::Value& jsonRoot) = 0;
+ virtual void __toJson(Json::Value& jsonRoot) const = 0;
+ int __jobId;
+ bool __started;
bool __oneTime;
bool __persistent;
- unsigned int __requirementTimeout;
- std::string __userData;
std::list<JobRequirement*> __requirements;
+ unsigned int __requirementTimeout;
JobAction* __action;
-
- int __jobId;
- bool __started;
+ std::string __userData;
/* Legacy support */
bool __disjunction;
public:
PeriodicJobInfo(unsigned int intervalMin, time_t anchor);
PeriodicJobInfo(Json::Value& jsonRoot, const std::string& serializedStr);
-
~PeriodicJobInfo();
JobInfo::Type getType() const;
private:
- void __toJson(Json::Value& jsonRoot);
+ void __toJson(Json::Value& jsonRoot) const;
unsigned int __intervalMin;
time_t __anchor;
public:
OnDemandJobInfo();
OnDemandJobInfo(Json::Value& jsonRoot, const std::string& serializedStr);
-
~OnDemandJobInfo();
JobInfo::Type getType() const;
- OnDemandJobInfo& addTrigger(JobTrigger* trigger);
std::list<JobTrigger*>& getTriggers();
+ OnDemandJobInfo& addTrigger(JobTrigger* trigger);
+
private:
- void __toJson(Json::Value& jsonRoot);
+ void __toJson(Json::Value& jsonRoot) const;
std::list<JobTrigger*> __triggers;
};