本文整理汇总了C++中CFunction类的典型用法代码示例。如果您正苦于以下问题:C++ CFunction类的具体用法?C++ CFunction怎么用?C++ CFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void ReactionsWidget1::slotNewFunction()
{
// FunctionWidget1 * fw = new FunctionWidget1(NULL);
// fw->show();
// TODO: we could think about calling the function widget as a dialogue here...
std::string name = std::string("Rate Law for ") + mpObject->getObjectName();
std::string nname = name;
size_t i = 0;
CCopasiVectorN<CFunction>& FunctionList
= CCopasiRootContainer::getFunctionList()->loadedFunctions();
CFunction* pFunc;
while (FunctionList.getIndex(nname) != C_INVALID_INDEX)
{
i++;
nname = name + "_";
nname += TO_UTF8(QString::number(i));
}
CCopasiRootContainer::getFunctionList()->add(pFunc = new CKinFunction(nname), true);
protectedNotify(ListViews::FUNCTION, ListViews::ADD, pFunc->getKey());
mpListView->switchToOtherWidget(C_INVALID_INDEX, pFunc->getKey());
}
示例2: CFunction
CFunction* CGeneratorContext::AddFunction(const char* name)
{
CFunction* function = new CFunction();
function->SetName(name);
mFunctions.push_back(function);
return function;
}
示例3: FillFunctionList
void CInsertFunctionDialog::FillFunctionList( int category )
{
mFunctionList->clear();
//NamesToListBox( CMapFunction::GetInstance(), *GetFunctionList(), category );
auto &mapf = CMapFunction::GetInstance();
for ( CMapFunction::const_iterator it = mapf.begin(); it != mapf.end(); it++ )
{
CFunction* value = dynamic_cast< CFunction* >( it->second );
if ( value != nullptr )
{
if ( category != -1 )
{
if ( value->GetCategory() != category )
{
continue;
}
}
QListWidgetItem *item = new QListWidgetItem( value->GetName().c_str(), mFunctionList );
Q_UNUSED( item );
}
}
//int sel = 0;
//GetFunctionList()->SetSelection( sel );
//FunctionList( sel );
mFunctionList->setCurrentRow( 0 );
}
示例4: add_c_override
CFunction * add_c_override(Module &mod, c_function f
, const std::string &protomod, const std::string &protoname
, const std::string &name, uint8_t argc
, const std::string ¶m_types)
{
CFunction *cfunc = add_c_function(mod, f, name, argc, param_types);
cfunc->set_protocol(protomod, protoname);
}
示例5: return
bool FunctionWidget1::functionParametersChanged()
{
CFunction* func = dynamic_cast<CFunction*>(CCopasiRootContainer::getKeyFactory()->get(mKey));
if (!func) return false;
return (!(func->getVariables() == mpFunction->getVariables()));
}
示例6: switch
C_INT32 CFunctionDB::load(CReadConfig &configbuffer)
{
CFunction Function;
CFunction * pFunction = NULL;
C_INT32 Size = 0;
C_INT32 Fail = 0;
configbuffer.getVariable("TotalUDKinetics", "C_INT32", &Size,
CReadConfig::LOOP);
for (C_INT32 i = 0; i < Size; i++)
{
Function.load(configbuffer);
switch (Function.getType())
{
case CEvaluationTree::Function:
pFunction = new CFunction(Function);
break;
case CEvaluationTree::MassAction:
pFunction = new CMassAction(Function);
break;
case CEvaluationTree::PreDefined:
case CEvaluationTree::UserDefined:
pFunction = new CKinFunction(Function,
&configbuffer);
break;
default:
fatalError();
break;
}
pFunction->compile();
if (!mLoadedFunctions.add(pFunction, true))
{
pdelete(pFunction);
// We ignore:
// CCopasiVector (2): Object '%s' allready exists.
if ((MCCopasiVector + 2) != CCopasiMessage::peekLastMessage().getNumber())
return Fail = 1;
// Remove the ignored meesage.
CCopasiMessage::getLastMessage();
}
}
return Fail;
}
示例7: Start
/*
* Manual page at process.def
*/
INT32 CGEN_PUBLIC CProcess::Start()
{
const SMic* pMic = NULL; // Method invocation context of Start()
CFunction* iCaller = NULL; // Function calling Start()
CFunction* iFnc = NULL; // Process function
StkItm* pStkItm = NULL; // Stack item
INT32 nArgs = 0; // Number of process function arguments
// Validate and initialize // ------------------------------------
if (m_nState!=0) // Not virginal
return IERROR(this,PRC_CANTSTART,"multiple starts not allowed",0,0); // Forget it!
if (!(pMic = CDlpObject_MicGet(_this))) return -1; // Get method invocation context
iCaller = (CFunction*)CDlpObject_OfKind("function",pMic->iCaller); // Get calling CFunction
if (!iCaller) return -1; // Must be a function!
// Initialize process // ------------------------------------
sprintf(m_psTmpFile,"%s%ld",dlp_tempnam(NULL,"~dLabPro#process#"),(long)dlp_time());// Initialize temp. file name prefix
// Marshal arguments // ------------------------------------
if (!(pStkItm=iCaller->StackGet(0))) return IERROR(this,PRC_TOOFEWARGS,0,0,0);// Get stack top
if (pStkItm->nType==T_INSTANCE) // Stack top is an instance
iFnc = (CFunction*)CDlpObject_OfKind("function",pStkItm->val.i); // Get function to be called
if (iFnc) // This process is a function call
{ // >>
IFIELD_RESET(CDlpObject,"dto"); // Create data transfer object
nArgs = CData_GetNRecs(iFnc->m_idArg); // Get number of function arguments
Marshal(m_iDto,iCaller,nArgs); // Marshal arguments for transfer
} // <<
else // This process is a program call
dlp_strcpy(m_psCmdLine,iCaller->PopString(0)); // Get program command line
#ifdef USE_FORK
if (iFnc) // This process is a function call
{ // >>
m_hPid=fork(); // Fork the process
if(m_hPid>0){ // Parent process >>
m_nState |= PRC_DATASENT; // Remember data have been sent
m_nState |= PRC_RUNNING; // Set running flag
m_hThread = 0; // Clear thread handle
return O_K; // Everything is fine
} // <<
if(m_hPid==0) return DoJobFork(iCaller,iFnc); // The child process runs the function
return IERROR(this,PRC_CANTSTART,"fork() failed",0,0); // On error (fid<0) we return
} // <<
#endif
// Start job in watcher thread // ------------------------------------
m_hPid = 0; // Reset process id
SendData(); // Send transfer data
m_hThread = dlp_create_thread(DoJob,this); // Do the job and watch it
return O_K; // Yo!
}
示例8: CFunction
CFunction * CFunction::createCopy() const
{
CFunction* newFunction = new CFunction();
//newFunction->mVariables = this->mVariables; //WRONG! only shallow copy!!
newFunction->mReversible = this->mReversible;
if (this->mpRoot)
newFunction->setRoot(this->mpRoot->copyBranch());
//newFunction->mInfix = newFunction->mpRoot->getInfix();
return newFunction;
}
示例9: assert
bool CQFunctionDM::removeRows(QModelIndexList rows, const QModelIndex&)
{
if (rows.isEmpty())
return false;
assert(mpDataModel != NULL);
CModel * pModel = mpDataModel->getModel();
if (pModel == NULL)
return false;
//Build the list of pointers to items to be deleted
//before actually deleting any item.
QList <CEvaluationTree *> pFunctions;
CFunction * pFunction;
QModelIndexList::const_iterator i;
for (i = rows.begin(); i != rows.end(); ++i)
{
if (!isDefaultRow(*i) &&
(pFunction = &CRootContainer::getFunctionList()->loadedFunctions()[i->row()]) != NULL &&
!pFunction->isReadOnly())
pFunctions.append(&CRootContainer::getFunctionList()->loadedFunctions()[i->row()]);
}
QList <CEvaluationTree *>::const_iterator j;
for (j = pFunctions.begin(); j != pFunctions.end(); ++j)
{
CEvaluationTree * pFunction = *j;
size_t delRow =
CRootContainer::getFunctionList()->loadedFunctions().CDataVector< CFunction >::getIndex(pFunction);
if (delRow != C_INVALID_INDEX)
{
QMessageBox::StandardButton choice =
CQMessageBox::confirmDelete(NULL, "function",
FROM_UTF8(pFunction->getObjectName()),
pFunction);
if (choice == QMessageBox::Ok)
removeRow((int) delRow);
}
}
return true;
}
示例10: if
bool FunctionWidget1::saveToFunction()
{
CFunction* func = dynamic_cast<CFunction*>(CCopasiRootContainer::getKeyFactory()->get(mKey));
if (!func) return false;
//radio buttons
TriLogic tmpl;
if (RadioButton1->isChecked() == true)
{
tmpl = TriTrue;
}
else if (RadioButton2->isChecked() == true)
{
tmpl = TriFalse;
}
else
{
tmpl = TriUnspecified;
}
if (tmpl != func->isReversible())
{
func->setReversible(tmpl);
flagChanged = true;
}
if (flagChanged)
{
copyFunctionContentsToFunction(mpFunction, func);
protectedNotify(ListViews::FUNCTION, ListViews::CHANGE, mKey);
if (mpDataModel != NULL)
{
mpDataModel->changed();
}
flagChanged = false;
}
func->compile();
return true;
}
示例11: flux
std::vector<CFunction*>
CFunctionDB::suitableFunctions(const unsigned C_INT32 noSubstrates,
const unsigned C_INT32 noProducts,
const TriLogic reversibility)
{
std::vector<CFunction*> ret;
CFunction *pFunction;
unsigned C_INT32 i, imax = mLoadedFunctions.size();
for (i = 0; i < imax; i++)
{
pFunction = dynamic_cast<CFunction *>(mLoadedFunctions[i]);
if (!pFunction) continue;
if (pFunction->isSuitable(noSubstrates, noProducts, reversibility))
ret.push_back(pFunction);
}
//always add constant flux it is is missing
if (reversibility == TriTrue)
{
if ((noSubstrates > 0) || (noProducts > 0)) //constant flux was not yet added
{
pFunction = dynamic_cast<CFunction*>(findFunction("Constant flux (reversible)"));
if (!pFunction) fatalError();
ret.push_back(pFunction);
}
}
else //irreversible
{
if (noSubstrates > 0) //constant flux was not yet added
{
pFunction = dynamic_cast<CFunction*>(findFunction("Constant flux (irreversible)"));
if (!pFunction) fatalError();
ret.push_back(pFunction);
}
}
return ret;
}
示例12: beginInsertRows
bool CQFunctionDM::insertRows(int position, int rows, const QModelIndex & parent)
{
beginInsertRows(parent, position, position + rows - 1);
for (int row = 0; row < rows; ++row)
{
CFunction *pFunc;
QString Name = createNewName(mNewName, COL_NAME_FUNCTIONS);
CRootContainer::getFunctionList()->add(pFunc = new CKinFunction(TO_UTF8(Name)), true);
emit notifyGUI(ListViews::ObjectType::FUNCTION, ListViews::ADD, pFunc->getCN());
}
endInsertRows();
mNewName = "function";
return true;
}
示例13: while
//! Slot for being activated wehenver New button is clicked
void FunctionWidget1::slotBtnNew()
{
std::string name = "function_1";
int i = 1;
CFunction* pFunc;
CCopasiVectorN<CFunction>& FunctionList
= CCopasiRootContainer::getFunctionList()->loadedFunctions();
while (FunctionList.getIndex(name) != C_INVALID_INDEX)
{
i++;
name = "function_";
name += TO_UTF8(QString::number(i));
}
CCopasiRootContainer::getFunctionList()->add(pFunc = new CKinFunction(name), true);
std::string key = pFunc->getKey();
protectedNotify(ListViews::FUNCTION, ListViews::ADD, key);
// enter(key);
mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}
示例14: MarshalRetval
/*
* Manual page at process.def
*/
INT16 CGEN_PUBLIC CProcess::MarshalRetval()
{
CDlpObject* iDto = NULL; // Data transfer object
const SMic* pMic = NULL; // Current method invocation context
CFunction* iCaller = NULL; // Calling function
StkItm* pStkItm = NULL; // Stack item to marshal
// Validate and initialize // ------------------------------------
if (!(pMic = CDlpObject_MicGet(_this))) return -1; // Get method invocation context
iCaller = (CFunction*)CDlpObject_OfKind("function",pMic->iCaller); // Get calling CFunction
if (!iCaller) return -1; // Must be a function!
// Pack second stack element into the CDlpObject on the stack top // ------------------------------------
iDto = iCaller->PopInstance(0); // Get instance on stack top
if (!iDto) return NOT_EXEC; // No instance on stack top --> puuh!
if (iCaller->StackGetLength()==0) return O_K; // Nothing more on the stack --> ok
pStkItm = iCaller->StackGet(0); // Get stack top
Pack(iDto,NULL,pStkItm,PRC_S_RETV); // Pack it as "~iRetv"
iCaller->Pop(0); // Remove stack top
return O_K; // Ok
}
示例15: ASTNode
ASTNode* CEvaluationNodeCall::toAST(const CCopasiDataModel* pDataModel) const
{
ASTNode* pNode = NULL;
pNode = new ASTNode(AST_FUNCTION);
const std::string funName = this->getData();
CFunction * pFun = CCopasiRootContainer::getFunctionList()->findFunction(funName);
assert(pFun != NULL);
if (pFun == NULL || pFun->getSBMLId().empty()) fatalError();
pNode->setName(pFun->getSBMLId().c_str());
const CEvaluationNode* child = static_cast<const CEvaluationNode*>(this->getChild());
while (child)
{
pNode->addChild(child->toAST(pDataModel));
child = static_cast<const CEvaluationNode*>(child->getSibling());
}
return pNode;
}