sci_base_observer.c revision 331722
1258945Sroberto/*- 2258945Sroberto * This file is provided under a dual BSD/GPLv2 license. When using or 3258945Sroberto * redistributing this file, you may do so under either license. 4258945Sroberto * 5258945Sroberto * GPL LICENSE SUMMARY 6258945Sroberto * 7258945Sroberto * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8258945Sroberto * 9258945Sroberto * This program is free software; you can redistribute it and/or modify 10258945Sroberto * it under the terms of version 2 of the GNU General Public License as 11258945Sroberto * published by the Free Software Foundation. 12258945Sroberto * 13258945Sroberto * This program is distributed in the hope that it will be useful, but 14258945Sroberto * WITHOUT ANY WARRANTY; without even the implied warranty of 15258945Sroberto * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16258945Sroberto * General Public License for more details. 17258945Sroberto * 18258945Sroberto * You should have received a copy of the GNU General Public License 19258945Sroberto * along with this program; if not, write to the Free Software 20258945Sroberto * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 21258945Sroberto * The full GNU General Public License is included in this distribution 22258945Sroberto * in the file called LICENSE.GPL. 23258945Sroberto * 24258945Sroberto * BSD LICENSE 25258945Sroberto * 26258945Sroberto * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 27258945Sroberto * All rights reserved. 28258945Sroberto * 29258945Sroberto * Redistribution and use in source and binary forms, with or without 30258945Sroberto * modification, are permitted provided that the following conditions 31258945Sroberto * are met: 32258945Sroberto * 33258945Sroberto * * Redistributions of source code must retain the above copyright 34258945Sroberto * notice, this list of conditions and the following disclaimer. 35258945Sroberto * * Redistributions in binary form must reproduce the above copyright 36258945Sroberto * notice, this list of conditions and the following disclaimer in 37258945Sroberto * the documentation and/or other materials provided with the 38258945Sroberto * distribution. 39258945Sroberto * 40258945Sroberto * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41258945Sroberto * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42258945Sroberto * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43258945Sroberto * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44258945Sroberto * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45258945Sroberto * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46258945Sroberto * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47258945Sroberto * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48258945Sroberto * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49258945Sroberto * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50258945Sroberto * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51258945Sroberto */ 52258945Sroberto 53258945Sroberto#include <sys/cdefs.h> 54258945Sroberto__FBSDID("$FreeBSD: stable/11/sys/dev/isci/scil/sci_base_observer.c 331722 2018-03-29 02:50:57Z eadler $"); 55258945Sroberto 56258945Sroberto/** 57258945Sroberto * @file 58258945Sroberto * 59258945Sroberto * @brief This file implements the functionality common to all observer 60258945Sroberto * objects. 61258945Sroberto */ 62258945Sroberto 63258945Sroberto#include <dev/isci/scil/sci_types.h> 64258945Sroberto#include <dev/isci/scil/sci_base_subject.h> 65258945Sroberto#include <dev/isci/scil/sci_base_observer.h> 66258945Sroberto 67258945Sroberto#if defined(SCI_LOGGING) 68258945Sroberto 69258945Sroberto//****************************************************************************** 70258945Sroberto//* P U B L I C M E T H O D S 71258945Sroberto//****************************************************************************** 72258945Sroberto 73258945Srobertovoid sci_base_observer_construct( 74258945Sroberto struct SCI_BASE_OBSERVER *this_observer, 75258945Sroberto SCI_BASE_OBSERVER_UPDATE_T update 76258945Sroberto) 77258945Sroberto{ 78258945Sroberto this_observer->next = NULL; 79258945Sroberto this_observer->update = update; 80258945Sroberto} 81258945Sroberto 82258945Sroberto// --------------------------------------------------------------------------- 83258945Sroberto 84258945Srobertovoid sci_base_observer_initialize( 85258945Sroberto SCI_BASE_OBSERVER_T * the_observer, 86258945Sroberto SCI_BASE_OBSERVER_UPDATE_T update, 87258945Sroberto SCI_BASE_SUBJECT_T * the_subject 88258945Sroberto) 89258945Sroberto{ 90258945Sroberto sci_base_observer_construct(the_observer, update); 91258945Sroberto sci_base_subject_attach_observer(the_subject, the_observer); 92258945Sroberto} 93258945Sroberto 94258945Sroberto// --------------------------------------------------------------------------- 95258945Sroberto 96258945Srobertovoid sci_base_observer_update( 97258945Sroberto SCI_BASE_OBSERVER_T *this_observer, 98258945Sroberto SCI_BASE_SUBJECT_T *the_subject 99) 100{ 101 if (this_observer->update != NULL) 102 { 103 this_observer->update(this_observer, the_subject); 104 } 105} 106 107#endif // defined(SCI_LOGGING) 108