return path;
}
+/*
+ This is a test function that will check if a certain source
+ and optionally an object are available.
+*/
+int td_graph_requires_source(td_graph* self, const char* name, const char* object) {
+ td_sources* sources = NULL;
+ td_source* source = NULL;
+ int r = 0;
+
+ // Fetch all sources
+ sources = td_daemon_get_sources(self->daemon);
+ if (!sources) {
+ r = -ENOTSUP;
+ goto ERROR;
+ }
+
+ // Fetch the source by its name
+ source = td_sources_get_by_name(sources, name);
+ if (!source) {
+ DEBUG(self->ctx, "Cannot render %s because source '%s' is not available\n",
+ td_graph_get_name(self), name);
+ r = -ENOENT;
+ goto ERROR;
+ }
+
+ // Cannot render if the source has been disabled
+ if (td_source_is_disabled(source)) {
+ DEBUG(self->ctx, "Cannot render %s because source '%s' is disabled\n",
+ td_graph_get_name(self), name);
+ r = -ENODATA;
+ goto ERROR;
+ }
+
+ // Check the object
+ if (object) {
+ r = td_source_has_object(source, object);
+ switch (r) {
+ // No match
+ case 0:
+ r = -ENODATA;
+ goto ERROR;
+
+ // Match
+ case 1:
+ break;
+
+ // Raise any other errors
+ default:
+ goto ERROR;
+ }
+ }
+
+ERROR:
+ if (sources)
+ td_sources_unref(sources);
+ if (source)
+ td_source_unref(source);
+
+ return r;
+}
+
int td_graph_load_source(td_graph* self,
td_args* args, const char* name, const char* object) {
td_sources* sources = NULL;
const char* td_graph_get_name(td_graph* self);
char* td_graph_get_bus_path(td_graph* self);
+int td_graph_requires_source(td_graph* self, const char* name, const char* object);
+
int td_graph_load_source(td_graph* self,
td_args* args, const char* name, const char* object);
int td_graph_load_sources(td_graph* self,