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

76 lines
2.2 KiB
C

/*
* 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
* @Short_description: interface for objects that use a model
* @Title: DbModelHolder
* @See_also: #DbModel
*
* This interface should be implemented from any class that uses a #DbModel as
* 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.
**/
G_DEFINE_INTERFACE (DbModelHolder, db_model_holder, G_TYPE_INVALID);
/**
* db_model_holder_get_model:
* @obj: a #DbModelHolder
*
* Gets the model used by holder.
*
* Return value:(transfer none): the #DbModel
**/
DbModel * db_model_holder_get_model (DbModelHolder * obj)
{
g_return_val_if_fail (DB_IS_MODEL_HOLDER (obj), NULL);
return DB_MODEL_HOLDER_GET_INTERFACE (obj)->get_model (obj);
}
/**
* db_model_holder_set_model:
* @obj: a #DbModelHolder
* @model: the #DbModel
*
* Sets the model used by holder.
**/
void db_model_holder_set_model (DbModelHolder * obj, DbModel * model)
{
g_return_if_fail (DB_IS_MODEL_HOLDER (obj));
g_return_if_fail (DB_IS_MODEL (obj));
DB_MODEL_HOLDER_GET_INTERFACE (obj)->set_model (obj, model);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void db_model_holder_default_init (DbModelHolderInterface * iface)
{
g_object_interface_install_property (iface,
g_param_spec_object ("model"
,_("Model")
,_("The model used by the holder")
,DB_TYPE_MODEL
,G_PARAM_READWRITE
));
}