This repository has been archived on 2024-07-15. You can view files and clone it, but cannot push or open issues or pull requests.
hedera/db/db-model-holder.c

77 lines
2.3 KiB
C
Raw Normal View History

2013-10-11 23:07:35 +00:00
/*
* Copyright (C) 2013 - Juan Ferrer Toribio
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "db-model-holder.h"
/**
* SECTION: db-model-holder
2013-10-14 12:08:06 +00:00
* @Short_description: interface for objects that use a model
2013-10-11 23:07:35 +00:00
* @Title: DbModelHolder
* @See_also: #DbModel
*
* This interface should be implemented from any class that uses a #DbModel as
2013-10-14 12:08:06 +00:00
* data source. This interface offers a #DbModel as a virtual property that has
* to be overwritten by the classes implementing it, as well as the
* db_model_holder_get_model() and db_model_holder_set_model() methods.
2013-10-11 23:07:35 +00:00
**/
2013-10-14 12:08:06 +00:00
G_DEFINE_INTERFACE (DbModelHolder, db_model_holder, G_TYPE_INVALID);
2013-10-11 23:07:35 +00:00
/**
* db_model_holder_get_model:
* @self: a #DbModelHolder
2013-10-11 23:07:35 +00:00
*
* Gets the model used by holder.
*
2013-10-14 12:08:06 +00:00
* Return value:(transfer none): the #DbModel
2013-10-11 23:07:35 +00:00
**/
DbModel * db_model_holder_get_model (DbModelHolder * self)
2013-10-11 23:07:35 +00:00
{
g_return_val_if_fail (DB_IS_MODEL_HOLDER (self), NULL);
2013-10-11 23:07:35 +00:00
return DB_MODEL_HOLDER_GET_INTERFACE (self)->get_model (self);
2013-10-11 23:07:35 +00:00
}
/**
2013-10-14 12:08:06 +00:00
* db_model_holder_set_model:
* @self: a #DbModelHolder
2013-11-07 15:35:24 +00:00
* @model:(allow-none): the #DbModel
2013-10-11 23:07:35 +00:00
*
2013-11-07 15:35:24 +00:00
* Sets the model used by holder. If @model is NULL, then it will unset the
* model.
2013-10-11 23:07:35 +00:00
**/
void db_model_holder_set_model (DbModelHolder * self, DbModel * model)
2013-10-11 23:07:35 +00:00
{
g_return_if_fail (DB_IS_MODEL_HOLDER (self));
g_return_if_fail (DB_IS_MODEL (self));
2013-10-11 23:07:35 +00:00
DB_MODEL_HOLDER_GET_INTERFACE (self)->set_model (self, model);
2013-10-11 23:07:35 +00:00
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
2013-10-14 12:08:06 +00:00
static void db_model_holder_default_init (DbModelHolderInterface * iface)
{
g_object_interface_install_property (iface,
2013-10-11 23:07:35 +00:00
g_param_spec_object ("model"
2013-10-14 12:08:06 +00:00
,_("Model")
,_("The model used by the holder")
2013-10-11 23:07:35 +00:00
,DB_TYPE_MODEL
,G_PARAM_READWRITE
));
}