00001 /* 00002 Struct(Asset) - key abstraction: structural asset 00003 00004 Copyright (C) Lumiera.org 00005 2008, Hermann Vosseler <Ichthyostega@web.de> 00006 00007 This program is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License as 00009 published by the Free Software Foundation; either version 2 of the 00010 License, or (at your option) any later version. 00011 00012 This program 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 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 00021 * *****************************************************/ 00022 00023 00024 #include "proc/assetmanager.hpp" 00025 #include "proc/asset/struct.hpp" 00026 #include "proc/asset/procpatt.hpp" 00027 #include "proc/asset/track.hpp" 00028 #include "proc/asset/pipe.hpp" 00029 #include "common/configrules.hpp" 00030 00031 #include "proc/asset/structfactoryimpl.hpp" 00032 00033 #include "lib/util.hpp" 00034 #include "include/nobugcfg.h" 00035 00036 #include <boost/format.hpp> 00037 00038 using boost::format; 00039 00040 using lumiera::Symbol; 00041 using lumiera::query::normalizeID; 00042 using lumiera::query::QueryHandler; 00043 using lumiera::ConfigRules; 00044 00045 using util::contains; 00046 00047 00048 namespace asset 00049 { 00050 00051 /****** NOTE: not really implemented yet. What follows is partially a hack to build simple tests *******/ 00052 00053 00054 00057 const string 00058 Struct::queryStreamID() const 00059 { 00060 return lumiera::query::extractID ("stream", this->ident.name); 00061 } 00062 00065 const string 00066 Struct::queryPipeID() const 00067 { 00068 return lumiera::query::extractID ("pipe", this->ident.name); 00069 } 00070 00071 00072 00074 StructFactory Struct::create; 00075 00076 00078 StructFactory::StructFactory () 00079 : impl_(new StructFactoryImpl(*this)) 00080 { } 00081 00082 00083 00091 template<class STRU> 00092 P<STRU> 00093 StructFactory::operator() (const Query<STRU>& capabilities) 00094 { 00095 P<STRU> res; 00096 QueryHandler<STRU>& typeHandler = ConfigRules::instance(); 00097 typeHandler.resolve (res, capabilities); 00098 00099 if (res) 00100 return res; 00101 00102 // create new one, since the 00103 // ConfigQuery didn't yield any result 00104 STRU* pS = impl_->fabricate(capabilities); 00105 return AssetManager::instance().wrap (*pS); 00106 } 00107 00108 00109 00110 00120 P<Pipe> 00121 StructFactory::operator() (string pipeID, string streamID) 00122 { 00123 normalizeID (pipeID); 00124 normalizeID (streamID); 00125 static format descriptor("pipe(%s), stream(%s)."); 00126 Pipe* pP = impl_->fabricate (Query<Pipe> (descriptor % pipeID % streamID)); 00127 return AssetManager::instance().wrap (*pP); 00128 } 00129 00130 00131 00132 } // namespace asset 00133 00134 00135 00136 00137 /**************************************************/ 00138 /* explicit instantiations of the factory methods */ 00139 /**************************************************/ 00140 00141 #include "proc/asset/struct.hpp" 00142 #include "proc/asset/procpatt.hpp" 00143 #include "proc/asset/track.hpp" 00144 #include "proc/asset/pipe.hpp" 00145 00146 00147 namespace asset 00148 { 00149 00150 template P<Pipe> StructFactory::operator() (const Query<Pipe>& query); 00151 template P<Track> StructFactory::operator() (const Query<Track>& query); 00152 template PProcPatt StructFactory::operator() (const Query<const ProcPatt>& query); 00153 00154 00155 } // namespace asset
1.5.6