1.1 --- a/core/systems/ForwardSys.cpp Fri Mar 28 06:21:34 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,732 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod
1.8 - * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This program is free software; you can redistribute it and/or modify it under
1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
1.13 - * Free Software Foundation.
1.14 - *
1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 - * details.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License along with
1.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 - *
1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.26 - * by the Valve Corporation. You must obey the GNU General Public License in
1.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.28 - * this exception to all derivative works. AlliedModders LLC defines further
1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.30 - * or <http://www.sourcemod.net/license.php>.
1.31 - *
1.32 - * Version: $Id$
1.33 - */
1.34 -
1.35 -#include <assert.h>
1.36 -#include <stdarg.h>
1.37 -#include <string.h>
1.38 -#include "ForwardSys.h"
1.39 -#include "PluginSys.h"
1.40 -#include "ShareSys.h"
1.41 -#include "DebugReporter.h"
1.42 -
1.43 -CForwardManager g_Forwards;
1.44 -
1.45 -/**
1.46 - * Genesis turns to its source, reduction occurs stepwise although the essence is all one.
1.47 - * End of line. FTL system check.
1.48 - *
1.49 - * :TODO: WHAT NEEDS TO BE TESTED IN THIS BEAST
1.50 - * VARARG FUNCTIONS:
1.51 - * - Pushing no varargs
1.52 - */
1.53 -
1.54 -// :TODO: IMPORTANT!!! The result pointer arg in the execute function maybe invalid if the forward fails
1.55 -// so later evaluation of this result may cause problems on higher levels of abstraction. DOCUMENT OR FIX ALL FORWARDS!
1.56 -
1.57 -CForwardManager::~CForwardManager()
1.58 -{
1.59 - CStack<CForward *>::iterator iter;
1.60 - for (iter=m_FreeForwards.begin(); iter!=m_FreeForwards.end(); iter++)
1.61 - {
1.62 - delete (*iter);
1.63 - }
1.64 - m_FreeForwards.popall();
1.65 -}
1.66 -
1.67 -void CForwardManager::OnSourceModAllInitialized()
1.68 -{
1.69 - g_PluginSys.AddPluginsListener(this);
1.70 - g_ShareSys.AddInterface(NULL, this);
1.71 -}
1.72 -
1.73 -IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned int num_params, const ParamType *types, ...)
1.74 -{
1.75 - CForward *fwd;
1.76 - va_list ap;
1.77 - va_start(ap, types);
1.78 -
1.79 - fwd = CForward::CreateForward(name, et, num_params, types, ap);
1.80 -
1.81 - va_end(ap);
1.82 -
1.83 - if (fwd)
1.84 - {
1.85 - g_PluginSys.AddFunctionsToForward(name, fwd);
1.86 -
1.87 - m_managed.push_back(fwd);
1.88 - }
1.89 -
1.90 - return fwd;
1.91 -}
1.92 -
1.93 -IChangeableForward *CForwardManager::CreateForwardEx(const char *name, ExecType et, int num_params, const ParamType *types, ...)
1.94 -{
1.95 - CForward *fwd;
1.96 - va_list ap;
1.97 - va_start(ap, types);
1.98 -
1.99 - fwd = CForward::CreateForward(name, et, num_params, types, ap);
1.100 -
1.101 - va_end(ap);
1.102 -
1.103 - if (fwd)
1.104 - {
1.105 - m_unmanaged.push_back(fwd);
1.106 - }
1.107 -
1.108 - return fwd;
1.109 -}
1.110 -
1.111 -void CForwardManager::OnPluginLoaded(IPlugin *plugin)
1.112 -{
1.113 - /* Attach any globally managed forwards */
1.114 - List<CForward *>::iterator iter;
1.115 - CForward *fwd;
1.116 -
1.117 - for (iter=m_managed.begin(); iter!=m_managed.end(); iter++)
1.118 - {
1.119 - fwd = (*iter);
1.120 - IPluginFunction *pFunc = plugin->GetBaseContext()->GetFunctionByName(fwd->GetForwardName());
1.121 - if (pFunc)
1.122 - {
1.123 - fwd->AddFunction(pFunc);
1.124 - }
1.125 - }
1.126 -}
1.127 -
1.128 -void CForwardManager::OnPluginUnloaded(IPlugin *plugin)
1.129 -{
1.130 - List<CForward *>::iterator iter;
1.131 - CForward *fwd;
1.132 -
1.133 - for (iter=m_managed.begin(); iter!=m_managed.end(); iter++)
1.134 - {
1.135 - fwd = (*iter);
1.136 - fwd->RemoveFunctionsOfPlugin(plugin);
1.137 - }
1.138 -
1.139 - for (iter=m_unmanaged.begin(); iter!=m_unmanaged.end(); iter++)
1.140 - {
1.141 - fwd = (*iter);
1.142 - fwd->RemoveFunctionsOfPlugin(plugin);
1.143 - }
1.144 -}
1.145 -
1.146 -IForward *CForwardManager::FindForward(const char *name, IChangeableForward **ifchng)
1.147 -{
1.148 - List<CForward *>::iterator iter;
1.149 - CForward *fwd;
1.150 -
1.151 - for (iter=m_managed.begin(); iter!=m_managed.end(); iter++)
1.152 - {
1.153 - fwd = (*iter);
1.154 - if (strcmp(fwd->GetForwardName(), name) == 0)
1.155 - {
1.156 - if (ifchng)
1.157 - {
1.158 - *ifchng = NULL;
1.159 - }
1.160 - return fwd;
1.161 - }
1.162 - }
1.163 -
1.164 - for (iter=m_unmanaged.begin(); iter!=m_unmanaged.end(); iter++)
1.165 - {
1.166 - fwd = (*iter);
1.167 - if (strcmp(fwd->GetForwardName(), name) == 0)
1.168 - {
1.169 - if (ifchng)
1.170 - {
1.171 - *ifchng = fwd;
1.172 - }
1.173 - return fwd;
1.174 - }
1.175 - }
1.176 -
1.177 - if (ifchng)
1.178 - {
1.179 - *ifchng = NULL;
1.180 - }
1.181 -
1.182 - return NULL;
1.183 -}
1.184 -
1.185 -void CForwardManager::ReleaseForward(IForward *forward)
1.186 -{
1.187 - ForwardFree(static_cast<CForward *>(forward));
1.188 -}
1.189 -
1.190 -void CForwardManager::ForwardFree(CForward *fwd)
1.191 -{
1.192 - m_FreeForwards.push(fwd);
1.193 - m_managed.remove(fwd);
1.194 -}
1.195 -
1.196 -CForward *CForwardManager::ForwardMake()
1.197 -{
1.198 - CForward *fwd;
1.199 - if (m_FreeForwards.empty())
1.200 - {
1.201 - fwd = new CForward;
1.202 - } else {
1.203 - fwd = m_FreeForwards.front();
1.204 - m_FreeForwards.pop();
1.205 - }
1.206 - return fwd;
1.207 -}
1.208 -
1.209 -void CForwardManager::OnPluginPauseChange(IPlugin *plugin, bool paused)
1.210 -{
1.211 - /* No longer used */
1.212 -}
1.213 -
1.214 -/*************************************
1.215 - * ACTUAL FORWARD API IMPLEMENTATION *
1.216 - *************************************/
1.217 -
1.218 -CForward *CForward::CreateForward(const char *name, ExecType et, unsigned int num_params, const ParamType *types, va_list ap)
1.219 -{
1.220 - ParamType _types[SP_MAX_EXEC_PARAMS];
1.221 -
1.222 - if (num_params > SP_MAX_EXEC_PARAMS)
1.223 - {
1.224 - return NULL;
1.225 - }
1.226 -
1.227 - if (types == NULL && num_params)
1.228 - {
1.229 - for (unsigned int i=0; i<num_params; i++)
1.230 - {
1.231 - _types[i] = (ParamType)va_arg(ap, int);
1.232 - if (_types[i] == Param_VarArgs && (i != num_params - 1))
1.233 - {
1.234 - return NULL;
1.235 - }
1.236 - }
1.237 - types = _types;
1.238 - } else {
1.239 - for (unsigned int i=0; i<num_params; i++)
1.240 - {
1.241 - _types[i] = types[i];
1.242 - if (types[i] == Param_VarArgs && (i != num_params - 1))
1.243 - {
1.244 - return NULL;
1.245 - }
1.246 - }
1.247 - }
1.248 -
1.249 - /* First parameter can never be varargs */
1.250 - if (num_params && _types[0] == Param_VarArgs)
1.251 - {
1.252 - return NULL;
1.253 - }
1.254 -
1.255 - CForward *pForward = g_Forwards.ForwardMake();
1.256 - pForward->m_curparam = 0;
1.257 - pForward->m_ExecType = et;
1.258 - snprintf(pForward->m_name, FORWARDS_NAME_MAX, "%s", name ? name : "");
1.259 -
1.260 - for (unsigned int i=0; i<num_params; i++)
1.261 - {
1.262 - pForward->m_types[i] = _types[i];
1.263 - }
1.264 -
1.265 - if (num_params && _types[num_params-1] == Param_VarArgs)
1.266 - {
1.267 - pForward->m_varargs = num_params--;
1.268 - } else {
1.269 - pForward->m_varargs = false;
1.270 - }
1.271 -
1.272 - pForward->m_numparams = num_params;
1.273 - pForward->m_errstate = SP_ERROR_NONE;
1.274 -
1.275 - pForward->m_functions.clear();
1.276 -
1.277 - return pForward;
1.278 -}
1.279 -
1.280 -int CForward::Execute(cell_t *result, IForwardFilter *filter)
1.281 -{
1.282 - if (m_errstate)
1.283 - {
1.284 - int err = m_errstate;
1.285 - Cancel();
1.286 - return err;
1.287 - }
1.288 -
1.289 - if (filter)
1.290 - {
1.291 - filter->OnExecuteBegin();
1.292 - }
1.293 -
1.294 - FuncIter iter = m_functions.begin();
1.295 - IPluginFunction *func;
1.296 - cell_t cur_result = 0;
1.297 - cell_t high_result = 0;
1.298 - int err;
1.299 - unsigned int failed=0, success=0;
1.300 - unsigned int num_params = m_curparam;
1.301 - FwdParamInfo temp_info[SP_MAX_EXEC_PARAMS];
1.302 - FwdParamInfo *param;
1.303 - ParamType type;
1.304 -
1.305 - /* Save local, reset */
1.306 - memcpy(temp_info, m_params, sizeof(m_params));
1.307 - m_curparam = 0;
1.308 -
1.309 - for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
1.310 - {
1.311 - func = (*iter);
1.312 -
1.313 - for (unsigned int i=0; i<num_params; i++)
1.314 - {
1.315 - int err = SP_ERROR_PARAM;
1.316 - param = &temp_info[i];
1.317 - if (i >= m_numparams || m_types[i] == Param_Any)
1.318 - {
1.319 - type = param->pushedas;
1.320 - } else {
1.321 - type = m_types[i];
1.322 - }
1.323 - if ((i >= m_numparams) || (type & SP_PARAMFLAG_BYREF))
1.324 - {
1.325 - /* If we're byref or we're vararg, we always push everything by ref.
1.326 - * Even if they're byval, we must push them byref.
1.327 - */
1.328 - if (type == Param_String)
1.329 - {
1.330 - err = func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags);
1.331 - } else if (type == Param_Float || type == Param_Cell) {
1.332 - err = func->PushCellByRef(¶m->val);
1.333 - } else {
1.334 - err = func->PushArray(param->byref.orig_addr, param->byref.cells, param->byref.flags);
1.335 - assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef);
1.336 - }
1.337 - } else {
1.338 - /* If we're not byref or not vararg, our job is a bit easier. */
1.339 - assert(type == Param_Cell || type == Param_Float);
1.340 - err = func->PushCell(param->val);
1.341 - }
1.342 - if (err != SP_ERROR_NONE)
1.343 - {
1.344 - if (!filter || !filter->OnErrorReport(this, func, err))
1.345 - {
1.346 - g_DbgReporter.GenerateError(func->GetParentContext(),
1.347 - func->GetFunctionID(),
1.348 - err,
1.349 - "Failed to push parameter while executing forward");
1.350 - }
1.351 - continue;
1.352 - }
1.353 - }
1.354 -
1.355 - /* Call the function and deal with the return value. */
1.356 - if ((err=func->Execute(&cur_result)) != SP_ERROR_NONE)
1.357 - {
1.358 - if (filter)
1.359 - {
1.360 - filter->OnErrorReport(this, func, err);
1.361 - }
1.362 - failed++;
1.363 - } else {
1.364 - success++;
1.365 - switch (m_ExecType)
1.366 - {
1.367 - case ET_Event:
1.368 - {
1.369 - if (cur_result > high_result)
1.370 - {
1.371 - high_result = cur_result;
1.372 - }
1.373 - break;
1.374 - }
1.375 - case ET_Hook:
1.376 - {
1.377 - if (cur_result > high_result)
1.378 - {
1.379 - high_result = cur_result;
1.380 - if ((ResultType)high_result == Pl_Stop)
1.381 - {
1.382 - goto done;
1.383 - }
1.384 - }
1.385 - break;
1.386 - }
1.387 - case ET_Custom:
1.388 - {
1.389 - if (filter)
1.390 - {
1.391 - if (filter->OnFunctionReturn(this, func, &cur_result) == Pl_Stop)
1.392 - {
1.393 - goto done;
1.394 - }
1.395 - }
1.396 - break;
1.397 - }
1.398 - default:
1.399 - {
1.400 - break;
1.401 - }
1.402 - }
1.403 - }
1.404 - }
1.405 -
1.406 -done:
1.407 - if (success)
1.408 - {
1.409 - if (m_ExecType == ET_Event || m_ExecType == ET_Hook)
1.410 - {
1.411 - cur_result = high_result;
1.412 - } else if (m_ExecType == ET_Ignore) {
1.413 - cur_result = 0;
1.414 - }
1.415 - if (result)
1.416 - {
1.417 - *result = cur_result;
1.418 - }
1.419 - }
1.420 -
1.421 - if (filter)
1.422 - {
1.423 - filter->OnExecuteEnd(&cur_result, success, failed);
1.424 - }
1.425 -
1.426 - return SP_ERROR_NONE;
1.427 -}
1.428 -
1.429 -int CForward::PushCell(cell_t cell)
1.430 -{
1.431 - if (m_curparam < m_numparams)
1.432 - {
1.433 - if (m_types[m_curparam] == Param_Any)
1.434 - {
1.435 - m_params[m_curparam].pushedas = Param_Cell;
1.436 - } else if (m_types[m_curparam] != Param_Cell) {
1.437 - return SetError(SP_ERROR_PARAM);
1.438 - }
1.439 - } else {
1.440 - if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
1.441 - {
1.442 - return SetError(SP_ERROR_PARAMS_MAX);
1.443 - }
1.444 - m_params[m_curparam].pushedas = Param_Cell;
1.445 - }
1.446 -
1.447 - m_params[m_curparam++].val = cell;
1.448 -
1.449 - return SP_ERROR_NONE;
1.450 -}
1.451 -
1.452 -int CForward::PushFloat(float number)
1.453 -{
1.454 - if (m_curparam < m_numparams)
1.455 - {
1.456 - if (m_types[m_curparam] == Param_Any)
1.457 - {
1.458 - m_params[m_curparam].pushedas = Param_Float;
1.459 - } else if (m_types[m_curparam] != Param_Float) {
1.460 - return SetError(SP_ERROR_PARAM);
1.461 - }
1.462 - } else {
1.463 - if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
1.464 - {
1.465 - return SetError(SP_ERROR_PARAMS_MAX);
1.466 - }
1.467 - m_params[m_curparam].pushedas = Param_Float;
1.468 - }
1.469 -
1.470 - m_params[m_curparam++].val = *(cell_t *)&number;
1.471 -
1.472 - return SP_ERROR_NONE;
1.473 -}
1.474 -
1.475 -int CForward::PushCellByRef(cell_t *cell, int flags)
1.476 -{
1.477 - if (m_curparam < m_numparams)
1.478 - {
1.479 - if (m_types[m_curparam] == Param_Any)
1.480 - {
1.481 - m_params[m_curparam].pushedas = Param_CellByRef;
1.482 - } else if (m_types[m_curparam] != Param_CellByRef) {
1.483 - return SetError(SP_ERROR_PARAM);
1.484 - }
1.485 - } else {
1.486 - if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
1.487 - {
1.488 - return SetError(SP_ERROR_PARAMS_MAX);
1.489 - }
1.490 - m_params[m_curparam].pushedas = Param_CellByRef;
1.491 - }
1.492 -
1.493 - _Int_PushArray(cell, 1, flags);
1.494 - m_curparam++;
1.495 -
1.496 - return SP_ERROR_NONE;
1.497 -}
1.498 -
1.499 -int CForward::PushFloatByRef(float *num, int flags)
1.500 -{
1.501 - if (m_curparam < m_numparams)
1.502 - {
1.503 - if (m_types[m_curparam] == Param_Any)
1.504 - {
1.505 - m_params[m_curparam].pushedas = Param_FloatByRef;
1.506 - } else if (m_types[m_curparam] != Param_FloatByRef) {
1.507 - return SetError(SP_ERROR_PARAM);
1.508 - }
1.509 - } else {
1.510 - if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
1.511 - {
1.512 - return SetError(SP_ERROR_PARAMS_MAX);
1.513 - }
1.514 - m_params[m_curparam].pushedas = Param_FloatByRef;
1.515 - }
1.516 -
1.517 - _Int_PushArray((cell_t *)num, 1, flags);
1.518 - m_curparam++;
1.519 -
1.520 - return SP_ERROR_NONE;
1.521 -}
1.522 -
1.523 -void CForward::_Int_PushArray(cell_t *inarray, unsigned int cells, int flags)
1.524 -{
1.525 - m_params[m_curparam].byref.cells = cells;
1.526 - m_params[m_curparam].byref.flags = flags;
1.527 - m_params[m_curparam].byref.orig_addr = inarray;
1.528 -}
1.529 -
1.530 -int CForward::PushArray(cell_t *inarray, unsigned int cells, int flags)
1.531 -{
1.532 - /* We don't allow this here */
1.533 - if (!inarray)
1.534 - {
1.535 - return SetError(SP_ERROR_PARAM);
1.536 - }
1.537 -
1.538 - if (m_curparam < m_numparams)
1.539 - {
1.540 - if (m_types[m_curparam] == Param_Any)
1.541 - {
1.542 - m_params[m_curparam].pushedas = Param_Array;
1.543 - } else if (m_types[m_curparam] != Param_Array) {
1.544 - return SetError(SP_ERROR_PARAM);
1.545 - }
1.546 - } else {
1.547 - if (!m_varargs || m_curparam > SP_MAX_EXEC_PARAMS)
1.548 - {
1.549 - return SetError(SP_ERROR_PARAMS_MAX);
1.550 - }
1.551 - m_params[m_curparam].pushedas = Param_Array;
1.552 - }
1.553 -
1.554 - _Int_PushArray(inarray, cells, flags);
1.555 -
1.556 - m_curparam++;
1.557 -
1.558 - return SP_ERROR_NONE;
1.559 -}
1.560 -
1.561 -void CForward::_Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags)
1.562 -{
1.563 - m_params[m_curparam].byref.cells = cells; /* Notice this contains the char count not cell count */
1.564 - m_params[m_curparam].byref.flags = cp_flags;
1.565 - m_params[m_curparam].byref.orig_addr = inarray;
1.566 - m_params[m_curparam].byref.sz_flags = sz_flags;
1.567 -}
1.568 -
1.569 -int CForward::PushString(const char *string)
1.570 -{
1.571 - if (m_curparam < m_numparams)
1.572 - {
1.573 - if (m_types[m_curparam] == Param_Any)
1.574 - {
1.575 - m_params[m_curparam].pushedas = Param_String;
1.576 - } else if (m_types[m_curparam] != Param_String) {
1.577 - return SetError(SP_ERROR_PARAM);
1.578 - }
1.579 - } else {
1.580 - if (!m_varargs || m_curparam > SP_MAX_EXEC_PARAMS)
1.581 - {
1.582 - return SetError(SP_ERROR_PARAMS_MAX);
1.583 - }
1.584 - m_params[m_curparam].pushedas = Param_String;
1.585 - }
1.586 -
1.587 - _Int_PushString((cell_t *)string, strlen(string)+1, SM_PARAM_STRING_COPY, 0);
1.588 - m_curparam++;
1.589 -
1.590 - return SP_ERROR_NONE;
1.591 -}
1.592 -
1.593 -int CForward::PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags)
1.594 -{
1.595 - if (m_curparam < m_numparams)
1.596 - {
1.597 - if (m_types[m_curparam] == Param_Any)
1.598 - {
1.599 - m_params[m_curparam].pushedas = Param_String;
1.600 - } else if (m_types[m_curparam] != Param_String) {
1.601 - return SetError(SP_ERROR_PARAM);
1.602 - }
1.603 - } else {
1.604 - if (!m_varargs || m_curparam > SP_MAX_EXEC_PARAMS)
1.605 - {
1.606 - return SetError(SP_ERROR_PARAMS_MAX);
1.607 - }
1.608 - m_params[m_curparam].pushedas = Param_String;
1.609 - }
1.610 -
1.611 - _Int_PushString((cell_t *)buffer, length, sz_flags, cp_flags);
1.612 - m_curparam++;
1.613 -
1.614 - return SP_ERROR_NONE;
1.615 -}
1.616 -
1.617 -void CForward::Cancel()
1.618 -{
1.619 - if (!m_curparam)
1.620 - {
1.621 - return;
1.622 - }
1.623 -
1.624 - m_curparam = 0;
1.625 - m_errstate = SP_ERROR_NONE;
1.626 -}
1.627 -
1.628 -bool CForward::AddFunction(IPluginContext *pContext, funcid_t index)
1.629 -{
1.630 - IPluginFunction *pFunc = pContext->GetFunctionById(index);
1.631 -
1.632 - if (!pFunc)
1.633 - {
1.634 - return false;
1.635 - }
1.636 -
1.637 - return AddFunction(pFunc);
1.638 -}
1.639 -
1.640 -bool CForward::RemoveFunction(IPluginContext *pContext, funcid_t index)
1.641 -{
1.642 - IPluginFunction *pFunc = pContext->GetFunctionById(index);
1.643 -
1.644 - if (!pFunc)
1.645 - {
1.646 - return false;
1.647 - }
1.648 -
1.649 - return RemoveFunction(pFunc);
1.650 -}
1.651 -
1.652 -bool CForward::RemoveFunction(IPluginFunction *func)
1.653 -{
1.654 - bool found = false;
1.655 - FuncIter iter;
1.656 - List<IPluginFunction *> *lst;
1.657 -
1.658 - if (func->IsRunnable())
1.659 - {
1.660 - lst = &m_functions;
1.661 - } else {
1.662 - lst = &m_paused;
1.663 - }
1.664 -
1.665 - for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
1.666 - {
1.667 - if ((*iter) == func)
1.668 - {
1.669 - found = true;
1.670 - lst->erase(iter);
1.671 - break;
1.672 - }
1.673 - }
1.674 -
1.675 - /* Cancel a call, if any */
1.676 - if (found || m_curparam)
1.677 - {
1.678 - func->Cancel();
1.679 - }
1.680 -
1.681 - return found;
1.682 -}
1.683 -
1.684 -unsigned int CForward::RemoveFunctionsOfPlugin(IPlugin *plugin)
1.685 -{
1.686 - FuncIter iter;
1.687 - IPluginFunction *func;
1.688 - unsigned int removed = 0;
1.689 - IPluginContext *pContext = plugin->GetBaseContext();
1.690 - for (iter=m_functions.begin(); iter!=m_functions.end();)
1.691 - {
1.692 - func = (*iter);
1.693 - if (func->GetParentContext() == pContext)
1.694 - {
1.695 - iter = m_functions.erase(iter);
1.696 - removed++;
1.697 - } else {
1.698 - iter++;
1.699 - }
1.700 - }
1.701 -
1.702 - return removed;
1.703 -}
1.704 -
1.705 -bool CForward::AddFunction(IPluginFunction *func)
1.706 -{
1.707 - if (m_curparam)
1.708 - {
1.709 - return false;
1.710 - }
1.711 -
1.712 - if (func->IsRunnable())
1.713 - {
1.714 - m_functions.push_back(func);
1.715 - } else {
1.716 - m_paused.push_back(func);
1.717 - }
1.718 -
1.719 - return true;
1.720 -}
1.721 -
1.722 -const char *CForward::GetForwardName()
1.723 -{
1.724 - return m_name;
1.725 -}
1.726 -
1.727 -unsigned int CForward::GetFunctionCount()
1.728 -{
1.729 - return m_functions.size();
1.730 -}
1.731 -
1.732 -ExecType CForward::GetExecType()
1.733 -{
1.734 - return m_ExecType;
1.735 -}