core/systems/ForwardSys.cpp
changeset 430 ed37e9767ed4
parent 370 d3a484f98f6d
child 447 f072596618c9
     1.1 --- a/core/systems/ForwardSys.cpp	Sun Feb 04 08:01:07 2007 +0000
     1.2 +++ b/core/systems/ForwardSys.cpp	Sun Feb 04 22:41:44 2007 +0000
     1.3 @@ -177,6 +177,37 @@
     1.4  	return fwd;
     1.5  }
     1.6  
     1.7 +void CForwardManager::OnPluginPauseChange(IPlugin *plugin, bool paused)
     1.8 +{
     1.9 +	List<CForward *>::iterator iter;
    1.10 +	CForward *fwd;
    1.11 +
    1.12 +	if (paused)
    1.13 +	{
    1.14 +		for (iter=m_managed.begin(); iter!=m_managed.end(); iter++)
    1.15 +		{
    1.16 +			fwd = (*iter);
    1.17 +			fwd->PushPausedFunctions(plugin);
    1.18 +		}
    1.19 +		for (iter=m_unmanaged.begin(); iter!=m_unmanaged.end(); iter++)
    1.20 +		{
    1.21 +			fwd = (*iter);
    1.22 +			fwd->PushPausedFunctions(plugin);
    1.23 +		}
    1.24 +	} else {
    1.25 +		for (iter=m_managed.begin(); iter!=m_managed.end(); iter++)
    1.26 +		{
    1.27 +			fwd = (*iter);
    1.28 +			fwd->PopPausedFunctions(plugin);
    1.29 +		}
    1.30 +		for (iter=m_unmanaged.begin(); iter!=m_unmanaged.end(); iter++)
    1.31 +		{
    1.32 +			fwd = (*iter);
    1.33 +			fwd->PopPausedFunctions(plugin);
    1.34 +		}
    1.35 +	}
    1.36 +}
    1.37 +
    1.38  /*************************************
    1.39   * ACTUAL FORWARD API IMPLEMENTATION *
    1.40   *************************************/
    1.41 @@ -272,11 +303,6 @@
    1.42  	for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
    1.43  	{
    1.44  		func = (*iter);
    1.45 -		/* Ugh... */
    1.46 -		if (!func->GetParentContext()->IsRunnable())
    1.47 -		{
    1.48 -			continue;
    1.49 -		}
    1.50  
    1.51  		for (unsigned int i=0; i<num_params; i++)
    1.52  		{
    1.53 @@ -602,16 +628,22 @@
    1.54  {
    1.55  	bool found = false;
    1.56  	FuncIter iter;
    1.57 +	List<IPluginFunction *> *lst;
    1.58  
    1.59 -	for (iter=m_functions.begin(); iter!=m_functions.end();)
    1.60 +	if (func->GetParentContext()->IsRunnable())
    1.61 +	{
    1.62 +		lst = &m_functions;
    1.63 +	} else {
    1.64 +		lst = &m_paused;
    1.65 +	}
    1.66 +
    1.67 +	for (iter=lst->begin(); iter!=lst->end(); iter++)
    1.68  	{
    1.69  		if ((*iter) == func)
    1.70  		{
    1.71  			found = true;
    1.72 -			/* If this iterator is being used, swap in a new one !*/
    1.73 -			iter = m_functions.erase(iter);
    1.74 -		} else {
    1.75 -			iter++;
    1.76 +			lst->erase(iter);
    1.77 +			break;
    1.78  		}
    1.79  	}
    1.80  
    1.81 @@ -653,22 +685,65 @@
    1.82  	}
    1.83  
    1.84  	//:IDEA: eventually we will tell the plugin we're using it [?]
    1.85 -	m_functions.push_back(func);
    1.86 +	if (func->GetParentContext()->IsRunnable())
    1.87 +	{
    1.88 +		m_functions.push_back(func);
    1.89 +	} else {
    1.90 +		m_paused.push_back(func);
    1.91 +	}
    1.92  
    1.93  	return true;
    1.94  }
    1.95  
    1.96 -const char *CForward::GetForwardName()
    1.97 +const char *CForward::GetForwardName() const
    1.98  {
    1.99  	return m_name;
   1.100  }
   1.101  
   1.102 -unsigned int CForward::GetFunctionCount()
   1.103 +unsigned int CForward::GetFunctionCount() const
   1.104  {
   1.105  	return m_functions.size();
   1.106  }
   1.107  
   1.108 -ExecType CForward::GetExecType()
   1.109 +ExecType CForward::GetExecType() const
   1.110  {
   1.111  	return m_ExecType;
   1.112  }
   1.113 +
   1.114 +void CForward::PushPausedFunctions(IPlugin *plugin)
   1.115 +{
   1.116 +	FuncIter iter;
   1.117 +	IPluginFunction *func;
   1.118 +	IPluginContext *pContext = plugin->GetBaseContext();
   1.119 +
   1.120 +	for (iter=m_functions.begin(); iter!=m_functions.end();)
   1.121 +	{
   1.122 +		func = (*iter);
   1.123 +		if (func->GetParentContext() == pContext)
   1.124 +		{
   1.125 +			m_paused.push_back(func);
   1.126 +			iter = m_functions.erase(iter);
   1.127 +		} else {
   1.128 +			iter++;
   1.129 +		}
   1.130 +	}
   1.131 +}
   1.132 +
   1.133 +void CForward::PopPausedFunctions(IPlugin *plugin)
   1.134 +{
   1.135 +	FuncIter iter;
   1.136 +	IPluginFunction *func;
   1.137 +	IPluginContext *pContext = plugin->GetBaseContext();
   1.138 +
   1.139 +	for (iter=m_paused.begin(); iter!=m_paused.end();)
   1.140 +	{
   1.141 +		func = (*iter);
   1.142 +		if (func->GetParentContext() == pContext)
   1.143 +		{
   1.144 +			m_functions.push_back(func);
   1.145 +			iter = m_paused.erase(iter);
   1.146 +		} else {
   1.147 +			iter++;
   1.148 +		}
   1.149 +	}
   1.150 +}