00001 // Search Graph context implementation -*- C++ -*- 00002 00003 // $Id: sgraphctx.h 634 2008-05-20 14:28:14Z herman $ 00004 // Copyright (C) 2003 Hermann Schichl 00005 // 00006 // This file is part of the COCONUT API. This library 00007 // is free software; you can redistribute it and/or modify it under the 00008 // terms of the Library GNU General Public License as published by the 00009 // Free Software Foundation; either version 2, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // Library GNU General Public License for more details. 00016 00017 // As a special exception, you may use this file as part of a free software 00018 // library without restriction. Specifically, if other files instantiate 00019 // templates or use macros or inline functions from this file, or you compile 00020 // this file and link it with other files to produce an executable, this 00021 // file does not by itself cause the resulting executable to be covered by 00022 // the Library GNU General Public License. This exception does not however 00023 // invalidate any other reasons why the executable file might be covered by 00024 // the Library GNU General Public License. 00025 00028 #ifndef _SGRAPHCTX_H_ 00029 #define _SGRAPHCTX_H_ 00030 00031 #include <list> 00032 #include <database> 00033 #include <db_method> 00034 00035 namespace coco { 00036 00038 00044 class search_graph_context : public vdbl::context 00045 { 00048 const gptr<search_graph>* __sg; 00050 bool __free; 00051 00052 public: 00054 search_graph_context() : __sg(NULL), __free(false) {} 00056 search_graph_context(const gptr<search_graph>* _i) : __sg(_i), __free(false) {} 00058 search_graph_context(search_graph& _i) 00059 : __sg(new const ptr<search_graph>(&_i)), __free(true) {} 00061 search_graph_context(const search_graph_context& _s) 00062 : __sg(_s.__sg), __free(_s.__free) {} 00064 virtual ~search_graph_context() { if(__free) delete __sg; } 00065 00067 search_graph_context& operator=(const search_graph_context& _s) 00068 { __sg = _s.__sg; return *this; } 00069 00072 const gptr<search_graph>* sg() const { return __sg; } 00073 }; 00074 00075 } // namespace coco 00076 00077 #endif // _SGRAPHCTX_H