plaintext/plugin_impl/render_settings_impl.cpp

Go to the documentation of this file.
00001 /*
00002  * File Name: render_settings_impl.cpp
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-plaintext.
00007  *
00008  * uds-plugin-plaintext is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-plaintext is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 #include "render_settings_impl.h"
00028 
00029 namespace text
00030 {
00031 
00032 utils::ObjectTable<PluginRenderSettingsImpl> PluginRenderSettingsImpl::g_instances_table;
00033 
00034 PluginRenderSettingsImpl::PluginRenderSettingsImpl(void)
00035 {
00036     // IPluginUnknown
00037     query_interface = query_interface_impl;
00038     release         = release_impl;
00039 
00040     // IPluginClone
00041     create_clone_object = create_clone_object_impl;
00042     
00043     // IPluginRenderSettings, no method yet.
00044 
00045     // IPluginZoom
00046     // set_zoom_factor     = set_zoom_factor_impl;
00047     // get_zoom_factor     = get_zoom_factor_impl;
00048 
00049     // IPluginRotation
00050     // set_rotation = set_rotation_impl;
00051     // get_rotation = get_rotation_impl;
00052 
00053     g_instances_table.add_interface<IPluginUnknown>(this);
00054     g_instances_table.add_interface<IPluginClone>(this);
00055     g_instances_table.add_interface<IPluginRenderSettings>(this);
00056 
00057     // There is not zoom and rotation interface for plain text plugin.
00058     // g_instances_table.add_interface<IPluginZoom>(this);
00059     // g_instances_table.add_interface<IPluginRotation>(this);
00060 }
00061 
00062 PluginRenderSettingsImpl::PluginRenderSettingsImpl(const PluginRenderSettingsImpl &ref)
00063 {
00064     // IPluginUnknown
00065     query_interface = query_interface_impl;
00066     release         = release_impl;
00067 
00068     // IPluginClone
00069     create_clone_object = create_clone_object_impl;
00070     
00071     // IPluginRenderSettings, no method yet.
00072 
00073     // IPluginZoom. No such interface.
00074     // IPluginRotation. No such interface.
00075 
00076 
00077     g_instances_table.add_interface<IPluginUnknown>(this);
00078     g_instances_table.add_interface<IPluginClone>(this);
00079     g_instances_table.add_interface<IPluginRenderSettings>(this);
00080 }
00081 
00082 PluginRenderSettingsImpl::~PluginRenderSettingsImpl(void)
00083 {
00084     g_instances_table.remove(this);
00085 }
00086 
00087 PluginRenderSettingsImpl * 
00088 PluginRenderSettingsImpl::query_instance(IPluginUnknown * thiz)
00089 {
00090     return g_instances_table.get_object(thiz);
00091 }
00092 
00093 PluginStatus 
00094 PluginRenderSettingsImpl::query_interface_impl(IPluginUnknown    *thiz,
00095                                                const UDSString   *id, 
00096                                                void              **ptr)
00097 {
00098     PluginRenderSettingsImpl * instance = g_instances_table.get_object(thiz);
00099     if (g_instances_table.query_interface(instance, id->get_buffer(id), ptr))
00100     {
00101         return PLUGIN_OK;
00102     }
00103     return PLUGIN_FAIL;
00104 }
00105 
00106 int 
00107 PluginRenderSettingsImpl::release_impl(IPluginUnknown  *thiz)
00108 {
00109     // Have to handle the object cloned and object created by view.
00110     // For cloned object, its life cycle is not limited.
00111     // For object created by view, view keeps a reference to it, so
00112     // it should notify view when it's to be released.
00113     PluginRenderSettingsImpl * instance = g_instances_table.get_object(thiz);
00114     if (instance->release_signal.count())
00115     {
00116         instance->release_signal.safe_broadcast(instance);
00117     }
00118     else
00119     {
00120         delete instance;
00121     }
00122     return 0;
00123 }
00124 
00125 IPluginUnknown* 
00126 PluginRenderSettingsImpl::create_clone_object_impl(IPluginUnknown *thiz)
00127 {
00128     PluginRenderSettingsImpl * instance = g_instances_table.get_object(thiz);
00129     PluginRenderSettingsImpl * another_instance 
00130         = new PluginRenderSettingsImpl(*instance);
00131 
00132     // DON'T need to connect the release signal.
00133     return static_cast<IPluginUnknown *>(another_instance);
00134 }
00135 
00136 }   // namespace text
00137 
Generated by  doxygen 1.6.2-20100208