本文整理汇总了C++中CValue类的典型用法代码示例。如果您正苦于以下问题:C++ CValue类的具体用法?C++ CValue怎么用?C++ CValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Trigger
void SCA_ExpressionController::Trigger(SCA_LogicManager* logicmgr)
{
bool expressionresult = false;
if (!m_exprCache)
{
CParser parser;
parser.SetContext(this->AddRef());
m_exprCache = parser.ProcessText(m_exprText);
}
if (m_exprCache)
{
CValue* value = m_exprCache->Calculate();
if (value)
{
if (value->IsError())
{
printf("%s\n", value->GetText().ReadPtr());
} else
{
float num = (float)value->GetNumber();
expressionresult = !MT_fuzzyZero(num);
}
value->Release();
}
}
for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
!(i==m_linkedactuators.end());i++)
{
SCA_IActuator* actua = *i;
logicmgr->AddActiveActuator(actua,expressionresult);
}
}
示例2: CArg
double CArg(CValue a_c)
{
double pi_2 = 1.570796326795;
double b = 180/(2*pi_2);
double x = a_c.real();
double y = a_c.imag();
double a;
double s_x = (x != 0.0) ? x/fabs(x) : 1.0;
double s_y = (y != 0.0) ? y/fabs(y) : 1.0;
if(x != 0.0)
{ a = atan(fabs(y)/fabs(x));
if(s_x < 0 && s_y > 0)
a = 2*pi_2 - a;
if(s_x < 0 && s_y < 0)
a = a - 2*pi_2;
if(s_x > 0 && s_y < 0)
a = -a;
return(a*b);
}
else
{ if(y == 0)
return(0.);
if(s_y > 0)
a = pi_2;
else
a = -pi_2;
return(a*b);
}
}
示例3: CMicroForm
void CDynControl::CreateMicroForm()
{
CString csFileName;
if(m_csObjName.Find(":")==1||m_csObjName.Left(2)=="\\\\")
csFileName=m_csObjName;
CValue FormParam;
FormParam.CreateObject("Структура");//String("Микроформа");
FormParam.SetAt("Микроформа",m_Property);
CMicroForm* pControl = new CMicroForm();
pControl->m_bConfigMode=m_bConfigMode;
pControl->m_csObjName=m_csObjName;
//eventVal - хранится контекст формы
OpenFormExt(m_csObjName,eventVal,FormParam,csFileName,"",0, 0,0,FormParam, pControl,m_pParentWnd);
//OpenFormExt(m_csObjName,eventVal,CValue(),csFileName,"",0, 0,0,FormParam, pControl,m_pParentWnd);
if(m_bVisible||m_bConfigMode)
pControl->ShowWindow(SW_SHOW);
m_pWnd = pControl;
m_hWnd = pControl->GetSafeHwnd();
pControl->SetDlgCtrlID(m_nID);
pControl->SetFont(&m_fontDefault);
FillDataArray();//доп. параметры объекта (задаваемые из конфигуратора)
}
示例4: ProcessReplica
void CValue::ProcessReplica() /* was AddDataToReplica in 2.48 */
{
m_refcount = 1;
#ifdef _DEBUG
//gRefCountValue++;
#endif
PyObjectPlus::ProcessReplica();
m_ValFlags.RefCountDisabled = false;
/* copy all props */
if (m_pNamedPropertyArray)
{
std::map<STR_String,CValue*> *pOldArray = m_pNamedPropertyArray;
m_pNamedPropertyArray=NULL;
std::map<STR_String,CValue*>::iterator it;
for (it= pOldArray->begin(); (it != pOldArray->end()); it++)
{
CValue *val = (*it).second->GetReplica();
SetProperty((*it).first,val);
val->Release();
}
}
}
示例5: GetParent
void SCA_KeyboardSensor::LogKeystrokes()
{
CValue *tprop = GetParent()->GetProperty(m_targetprop);
SCA_IInputDevice *inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
const std::wstring typedtext = inputdev->GetText();
std::wstring proptext = converter.from_bytes(tprop->GetText());
/* Convert all typed key in the prop string, if the key are del or
* backspace we remove the last string item.
*/
for (std::wstring::const_iterator it = typedtext.begin(), end = typedtext.end(); it != end; ++it) {
const wchar_t item = *it;
if (item == '\b' || item == 127) {
if (proptext.size()) {
proptext.resize(proptext.size() - 1);
}
}
else if (item == '\r') {
// Do nothing
}
else {
proptext.push_back(item);
}
}
CStringValue *newstringprop = new CStringValue(converter.to_bytes(proptext), m_targetprop);
GetParent()->SetProperty(m_targetprop, newstringprop);
newstringprop->Release();
}
示例6: GetProperty
CValue* CValue::FindIdentifier(const STR_String& identifiername)
{
CValue* result = NULL;
int pos = 0;
// if a dot exists, explode the name into pieces to get the subcontext
if ((pos=identifiername.Find('.'))>=0)
{
const STR_String rightstring = identifiername.Right(identifiername.Length() -1 - pos);
const STR_String leftstring = identifiername.Left(pos);
CValue* tempresult = GetProperty(leftstring);
if (tempresult)
{
result=tempresult->FindIdentifier(rightstring);
}
} else
{
result = GetProperty(identifiername);
if (result)
return result->AddRef();
}
if (!result)
{
// warning here !!!
result = new CErrorValue(identifiername+" not found");
}
return result;
}
示例7: SCA_ISensor
SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr,
SCA_IObject* gameobj,
const STR_String& propname,
const STR_String& propval,
const STR_String& propmaxval,
KX_PROPSENSOR_TYPE checktype)
: SCA_ISensor(gameobj,eventmgr),
m_checktype(checktype),
m_checkpropval(propval),
m_checkpropmaxval(propmaxval),
m_checkpropname(propname),
m_range_expr(NULL)
{
//CParser pars;
//pars.SetContext(this->AddRef());
//CValue* resultval = m_rightexpr->Calculate();
CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
if (!orgprop->IsError())
{
m_previoustext = orgprop->GetText();
}
orgprop->Release();
if (m_checktype==KX_PROPSENSOR_INTERVAL)
{
PrecalculateRangeExpression();
}
Init();
}
示例8: VDB_Node_VolumeToMesh_BeginEvaluate
SICALLBACK VDB_Node_VolumeToMesh_BeginEvaluate(ICENodeContext& ctxt)
{
Application().LogMessage(L"[VDB_Node_VolumeToMesh] BeginEvaluate");
CValue userData = ctxt.GetUserData();
VDB_Node_VolumeToMesh* vdbNode;
if (userData.IsEmpty())
{
vdbNode = new VDB_Node_VolumeToMesh;
}
else
{
vdbNode = (VDB_Node_VolumeToMesh*)(CValue::siPtrType)userData;
}
CICEPortState vdbGridPortState(ctxt, kVDBGrid);
CICEPortState isoPortState(ctxt, kIsoValue);
CICEPortState adaptPortState(ctxt, kAdaptivity);
bool vdbGridDirty = vdbGridPortState.IsDirty(CICEPortState::siAnyDirtyState);
bool isoDirty = isoPortState.IsDirty(CICEPortState::siAnyDirtyState);
bool adaptDirty = adaptPortState.IsDirty(CICEPortState::siAnyDirtyState);
vdbGridPortState.ClearState();
isoPortState.ClearState();
adaptPortState.ClearState();
if (vdbGridDirty || isoDirty || adaptDirty)
{
vdbNode->Cache(ctxt);
}
ctxt.PutUserData((CValue::siPtrType)vdbNode);
return CStatus::OK;
}
示例9: PyErr_SetString
static PyObject *listvalue_buffer_item(PyObject *self, Py_ssize_t index)
{
CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self));
CValue *cval;
if (list==NULL) {
PyErr_SetString(PyExc_SystemError, "val = CList[i], "BGE_PROXY_ERROR_MSG);
return NULL;
}
int count = list->GetCount();
if (index < 0)
index = count+index;
if (index < 0 || index >= count) {
PyErr_SetString(PyExc_IndexError, "CList[i]: Python ListIndex out of range in CValueList");
return NULL;
}
cval= list->GetValue(index);
PyObject *pyobj = cval->ConvertValueToPython();
if (pyobj)
return pyobj;
else
return cval->GetProxy();
}
示例10: ConvertPythonToValue
PyObject *CListValue::Pyindex(PyObject *value)
{
PyObject *result = NULL;
CValue* checkobj = ConvertPythonToValue(value, "val = cList[i]: CValueList, ");
if (checkobj==NULL)
return NULL; /* ConvertPythonToValue sets the error */
int numelem = GetCount();
for (int i=0;i<numelem;i++)
{
CValue* elem = GetValue(i);
if (checkobj==elem || CheckEqual(checkobj,elem))
{
result = PyLong_FromLong(i);
break;
}
}
checkobj->Release();
if (result==NULL) {
PyErr_SetString(PyExc_ValueError, "CList.index(x): x not in CListValue");
}
return result;
}
示例11: Calculate
CValue* CIfExpr::Calculate()
/*
pre:
ret: a new object containing the value of m_e1 if m_guard is a boolean TRUE
a new object containing the value of m_e2 if m_guard is a boolean FALSE
an new errorvalue if m_guard is not a boolean
*/
{
CValue *guardval;
guardval = m_guard->Calculate();
const STR_String& text = guardval->GetText();
guardval->Release();
if (&text == &CBoolValue::sTrueString)
{
return m_e1->Calculate();
}
else if (&text == &CBoolValue::sFalseString)
{
return m_e2->Calculate();
}
else
{
return new CErrorValue("Guard should be of boolean type");
}
}
示例12: SetVariable
BOOL SetVariable( CStr &varName, CValue value )
{
VarError.Empty();
int pos;
CValue *val;
if ( varName.GetLength() > 0 && varName.GetAt(0) == L'[' )
{
CStr expression = varName.Mid( 1 );
CInterpreter parser;
CValue result = parser.EvaluateExpression( expression, FALSE );
int subPos = parser.GetErrorPosition();
if ( parser.GetError() != 0 )
{
VarError = CStr( L"Error in variable reference: " ) + parser.GetErrorMessage();
return FALSE;
}
if ( expression[subPos] != L']' )
{
VarError = L"Variable reference not closed (missing ']')";
return FALSE;
}
val = GetVariable( (CStr)result, TRUE, &pos );
}
else{
val = GetVariable( varName, TRUE, &pos );
}
val->CopyFrom( value );
return (pos != -1);
}
示例13: SCA_DelaySensor
CValue* SCA_DelaySensor::GetReplica()
{
CValue* replica = new SCA_DelaySensor(*this);
// this will copy properties and so on...
replica->ProcessReplica();
return replica;
}
示例14: CBoolValue
CValue* SCA_ILogicBrick::Calc(VALUE_OPERATOR op, CValue *val)
{
CValue* temp = new CBoolValue(false,"");
CValue* result = temp->Calc(op,val);
temp->Release();
return result;
}
示例15: SCA_AlwaysSensor
CValue* SCA_AlwaysSensor::GetReplica()
{
CValue* replica = new SCA_AlwaysSensor(*this);//m_float,GetName());
// this will copy properties and so on...
replica->ProcessReplica();
return replica;
}