示例#1
0
  std::vector<std::string> Template::slot_names() {
    DATA_OBJECT clipsdo;

    if ( !m_cobj )
      return std::vector<std::string>();

    EnvDeftemplateSlotNames( m_environment.cobj(), m_cobj, &clipsdo );
    return data_object_to_strings( clipsdo );
  }
示例#2
0
void ClipsRuleMgr::getTemplateFields()
{
		void *templatePtr;
		DATA_OBJECT theValue;
		void *theMultifield;
		
		DATA_OBJECT theValueOfType;
		void *theMultifieldOfType;
		int cnt1 = 0;
		int i = 1;
		int fieldType;
		void *fieldValue;
		m_templateItor = m_templateNames.begin();
		while(m_templateItor!=m_templateNames.end())
		{	
			cout<<"Rule Engine IntializeStream::m_templateNames:" <<*m_templateItor<<endl;
			templatePtr = EnvFindDeftemplate(m_theEnv,(*m_templateItor).c_str());
			EnvDeftemplateSlotNames(m_theEnv, templatePtr, &theValue);
			
			if (GetpType(&theValue) == MULTIFIELD)
			{
				cnt1 = GetpDOLength(&theValue);
				//theMultifield = theValue.value;
				theMultifield=GetValue(theValue);
				vector<Field> fields;
				for (i=1; i<=cnt1; i++)
				{
					
					fieldType = GetMFType(theMultifield,i);
					if (fieldType == SYMBOL)
					{
						Field tmp;
						fieldValue = (void*)ValueToString(GetMFValue(theMultifield,i));
						tmp.name = string((char*)fieldValue);
						tmp.type = 2;
						EnvDeftemplateSlotTypes(m_theEnv,templatePtr,(char *)fieldValue, &theValueOfType);
						if (GetpType(&theValueOfType) == MULTIFIELD)
						{
							GetpDOLength(&theValueOfType);
							theMultifieldOfType = theValueOfType.value;
							
							
							///default contraict to first one
							fieldType = GetMFType(theMultifieldOfType,1);	
						
							if (fieldType == SYMBOL)
							{
									fieldValue = GetMFValue(theMultifieldOfType,1);
									if (string(ValueToString(fieldValue)) == string("FLOAT"))
									{
										tmp.type = 0;
									}
									else if (string(ValueToString(fieldValue)) == string("INTEGER"))
									{
										tmp.type = 1;
									}
									else
									{
										tmp.type = 2;
									}
							}
							else
							{
									cout<<"Rule Engine IntializeStream::EnvDeftemplateSlotTypes get unknown field type when get slot type:" <<fieldType<<endl;
							}
						}
						
						fields.push_back(tmp);
					}
					else
					{
						cout<<"Rule Engine IntializeStream::get unknown field type when get slot name:" <<fieldType<<endl;
					}
				}
				tableSchema.insert(pair<string, vector<Field> >(*m_templateItor, fields));	
			}
			else
			{
					cout<<"Rule Engine IntializeStream:::EnvDeftemplateSlotNames return not multifiled" <<endl;
			}
		
			m_templateItor++;
		}
		
		
		//call streaming interface to set tableSchema here
		
}