00001 // Search Node computation hook implementation -*- C++ -*- 00002 00003 // Copyright (C) 2003 Hermann Schichl 00004 // 00005 // This file is part of the COCONUT API. This library 00006 // is free software; you can redistribute it and/or modify it under the 00007 // terms of the Library GNU General Public License as published by the 00008 // Free Software Foundation; either version 2, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // Library GNU General Public License for more details. 00015 00016 // As a special exception, you may use this file as part of a free software 00017 // library without restriction. Specifically, if other files instantiate 00018 // templates or use macros or inline functions from this file, or you compile 00019 // this file and link it with other files to produce an executable, this 00020 // file does not by itself cause the resulting executable to be covered by 00021 // the Library GNU General Public License. This exception does not however 00022 // invalidate any other reasons why the executable file might be covered by 00023 // the Library GNU General Public License. 00024 00027 #ifndef _COMP_HOOK_H 00028 #define _COMP_HOOK_H 00029 00030 #include <dbtools.h> 00031 #include <search_node.h> 00032 00033 class work_node_comp_hook 00034 { 00035 private: 00036 std::string __name; 00037 std::list<std::string> __managed_cols; 00038 00039 protected: 00040 template <class _CI> 00041 bool _init_column(vdbl::standard_table& stable, const std::string& colname, 00042 const _CI& c); 00043 00044 template <class _CI> 00045 bool _init_column(vdbl::standard_table& stable, const char* colname, 00046 const _CI& c) 00047 { return _init_column(stable, std::string(colname), c); } 00048 00049 bool _drop_columns(vdbl::standard_table& stable); 00050 00051 // accessors to the work_node class 00052 search_node_relation parent_relation(const work_node& wn) const; 00053 00054 search_node_id node_id(const work_node& wn) const; 00055 00056 public: 00057 work_node_comp_hook(const std::string& name) : __name(name), __managed_cols() 00058 {} 00059 00060 virtual ~work_node_comp_hook() {} 00061 00062 virtual void operator()(const work_node& wn, dbt_row& dbr) = 0; 00063 00064 virtual bool init_columns(vdbl::standard_table& stable) { return false; } 00065 00066 virtual bool drop_columns(vdbl::standard_table& stable) { return false; } 00067 00068 const std::string& name() { return __name; } 00069 }; 00070 00071 #endif // _COMP_HOOK_H