File: mrp-storage-module.c

package info (click to toggle)
planner 0.14.92-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,676 kB
  • sloc: ansic: 68,177; xml: 6,112; sql: 890; makefile: 43; sh: 42; python: 26
file content (124 lines) | stat: -rw-r--r-- 3,332 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2004 Imendio AB
 * Copyright (C) 2001-2003 CodeFactory AB
 * Copyright (C) 2001-2003 Richard Hult <richard@imendio.com>
 * Copyright (C) 2001-2002 Mikael Hallendal <micke@imendio.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#include <config.h>
#include <gmodule.h>
#include "mrp-storage-module.h"
#include "mrp-project.h"
#include "mrp-private.h"

G_DEFINE_TYPE (MrpStorageModule, mrp_storage_module, G_TYPE_OBJECT)


static void
mrp_storage_module_init (MrpStorageModule *module)
{
}

static void
mrp_storage_module_class_init (MrpStorageModuleClass *klass)
{
}

gboolean
mrp_storage_module_load (MrpStorageModule  *module,
			 const gchar       *uri,
			 GError           **error)
{
	g_return_val_if_fail (MRP_IS_STORAGE_MODULE (module), FALSE);
	g_return_val_if_fail (uri != NULL, FALSE);

	if (MRP_STORAGE_MODULE_GET_CLASS (module)->load) {
		return MRP_STORAGE_MODULE_GET_CLASS (module)->load (module,
								    uri,
								    error);
	}

	return FALSE;
}

gboolean
mrp_storage_module_save (MrpStorageModule  *module,
			 const gchar       *uri,
			 gboolean           force,
			 GError           **error)
{
	g_return_val_if_fail (MRP_IS_STORAGE_MODULE (module), FALSE);
	g_return_val_if_fail (uri != NULL, FALSE);

	if (MRP_STORAGE_MODULE_GET_CLASS (module)->save) {
		return MRP_STORAGE_MODULE_GET_CLASS (module)->save (module,
								    uri,
								    force,
								    error);
	}

	return FALSE;
}

gboolean
mrp_storage_module_to_xml (MrpStorageModule  *module,
			   gchar            **str,
			   GError           **error)
{
	g_return_val_if_fail (MRP_IS_STORAGE_MODULE (module), FALSE);

	if (MRP_STORAGE_MODULE_GET_CLASS (module)->to_xml) {
		return MRP_STORAGE_MODULE_GET_CLASS (module)->to_xml (module,
								      str,
								      error);
	}

	return FALSE;
}

gboolean
mrp_storage_module_from_xml (MrpStorageModule  *module,
			     const gchar       *str,
			     GError           **error)
{
	g_return_val_if_fail (MRP_IS_STORAGE_MODULE (module), FALSE);
	g_return_val_if_fail (str != NULL, FALSE);

	if (MRP_STORAGE_MODULE_GET_CLASS (module)->from_xml) {
		return MRP_STORAGE_MODULE_GET_CLASS (module)->from_xml (module,
									str,
									error);
	}

	return FALSE;
}

void
imrp_storage_module_set_project (MrpStorageModule *module,
				 MrpProject       *project)
{
	g_return_if_fail (MRP_IS_STORAGE_MODULE (module));
	g_return_if_fail (MRP_IS_PROJECT (project));

	if (MRP_STORAGE_MODULE_GET_CLASS (module)->set_project) {
		MRP_STORAGE_MODULE_GET_CLASS (module)->set_project (module,
								    project);
	}
}