Beispiel #1
0
bool BContainer::SaveConfigurationToAttributeList(char* algorithmName,GML::Utils::AttributeList*	attrList)
{
	BItem* element;
	char* objectName;
	GML::Utils::GString gStrTemp;
	CString temp,tempStr;
	CString complexValue;
	CString tempValue;
	CString connectorStr;
	bool	foundComplex;
	void* objectValue;
	unsigned char objectType;
	bool someBoolValue;
	GML::Utils::Attribute*	attr;
	unsigned int someUIntValue;
	int someIntValue;
	double someDoubleValue;
	BEdit* editValue;
	BCombo* comboValue;
	BCheckBox* boolItem;
	BFile* fileItem;
	int i;


	

	for(i=0;i<vElements.GetSize();i++)
	{
		
		element = (BItem*)vElements.GetPointer(i);
		if(element == NULL)
			return false;
		
		objectName = element->label;
		foundComplex = false;

		if(strcmp(objectName,"DataBases") == 0)
		{
			
			if(!GetComplexElement(&i,&temp))
				return false;
			if(!attrList->AddAttribute("DataBase",(char*)temp.GetString(),GML::Utils::AttributeList::STRING,1,NULL))
			{
				return false;
			}
			continue;
		}
		if(strcmp(objectName,"Notifiers") == 0)
		{
			
			if(!GetComplexElement(&i,&temp))
				return false;
			if(!attrList->AddAttribute("Notifier",(char*)temp.GetString(),GML::Utils::AttributeList::STRING,1,NULL))
			{
				return false;
			}
			continue;
		}
		if(strcmp(objectName,"Connectors")==0)
		{
			
			if(!GetConnectorsSaveString(&i,&temp))
				return false;
			if(!attrList->AddAttribute("Connector",(char*)temp.GetString(),GML::Utils::AttributeList::STRING,1,NULL))
			{
				return false;
			}
			continue;
		}
			
		switch(element->elementType)
		{
		case TYPE_HEADER:
			continue;
		case GML::Utils::AttributeList::STRING:
			
			editValue = (BEdit*)element;
			editValue->GetText(temp);
			objectValue = (char*)temp.GetString();
			objectType = GML::Utils::AttributeList::STRING;
			break;
		case TYPE_COMBO:
			
			comboValue = (BCombo*)element;
			comboValue->GetSelectedItem(temp);
			objectValue = (char*)temp.GetString();
			objectType = GML::Utils::AttributeList::STRING;
			break;
		case TYPE_FILE:
			
			fileItem = (BFile*) element;
			fileItem->GetText(temp);
			objectValue = (char*)temp.GetString();
			objectType = GML::Utils::AttributeList::STRING;
			break;
		case GML::Utils::AttributeList::BOOLEAN:
			
			boolItem = (BCheckBox*)element;
			someBoolValue = boolItem->IsChecked();
			objectValue = &someBoolValue;
			objectType = element->elementType;
			break;

		case GML::Utils::AttributeList::UINT32:
			
			editValue = (BEdit*)element;
			editValue->GetText(temp);
			gStrTemp.Set(temp.GetBuffer());
			if(!gStrTemp.ConvertToUInt32(&someUIntValue))
				return false;
			objectValue = &someUIntValue;
			objectType = element->elementType;
		case GML::Utils::AttributeList::INT32:
			
			editValue = (BEdit*)element;
			editValue->GetText(temp);
			gStrTemp.Set(temp.GetBuffer());
			if(!gStrTemp.ConvertToInt32(&someIntValue))
				return false;
			objectValue = &someIntValue;
			objectType = element->elementType;
			break;
			
	
		case GML::Utils::AttributeList::DOUBLE:
			
			editValue = (BEdit*)element;
			editValue->GetText(temp);
			gStrTemp.Set(temp.GetBuffer());
			if(!gStrTemp.ConvertToDouble(&someDoubleValue))
				return false;
			objectValue = &someDoubleValue;
			objectType = element->elementType;
			break;	
		default:
			continue;
			

		}
		
		if(!attrList->AddAttribute(objectName,objectValue,objectType,1,NULL))
		{
			
			return false;
		}
		
				
	}

	attr = attrList->Get("AlgorithmName");
	if(attr== NULL)
	{
		if(!attrList->AddAttribute("AlgorithmName",algorithmName,GML::Utils::AttributeList::STRING,1,NULL))
		{
			return false;
		}
	}
	return true;
}
Beispiel #2
0
bool BContainer::GetElementStr(BItem* element,CString* str)
{
	BCheckBox* boolItem;
	BEdit*	editItem;
	BCombo* comboItem;
	BFile* fileItem;
	BButton* buttonItem;
	CString temp;
	GML::Utils::GString gStrTemp;
	

	UINT someUIntValue;
	int	someIntValue;
	double someDoubleValue;


	switch(element->elementType)
	{
	case GML::Utils::AttributeList::BOOLEAN:
		boolItem = (BCheckBox*)element;
		if(boolItem->IsChecked())
			str->Format("%s=True;",boolItem->label);
		else
			str->Format("%s=False;",boolItem->label);
		return true;

	case GML::Utils::AttributeList::UINT32:
		editItem = (BEdit*)element;
		editItem->GetText(temp);
		gStrTemp.Set(temp.GetBuffer());
		if(!gStrTemp.ConvertToUInt32(&someUIntValue))
			return false;
		str->Format("%s=%u;",editItem->label,someUIntValue);
		return true;
	case GML::Utils::AttributeList::INT32:
		editItem = (BEdit*)element;
		editItem->GetText(temp);
		gStrTemp.Set(temp.GetBuffer());
		if(!gStrTemp.ConvertToInt32(&someIntValue))
			return false;
		str->Format("%s=%d;",editItem->label,someIntValue);
		return true;
	
	case GML::Utils::AttributeList::DOUBLE:
		editItem = (BEdit*)element;
		editItem->GetText(temp);
		gStrTemp.Set(temp.GetBuffer());
		if(!gStrTemp.ConvertToDouble(&someDoubleValue))
			return false;
		str->Format("%s=%lf;",editItem->label,someDoubleValue);
		return true;	
	case GML::Utils::AttributeList::STRING:
		editItem = (BEdit*)element;
		editItem->GetText(temp);
		if(temp.Compare("")==0)
		{
			return false;			
		}
		str->Format("%s=%s;",editItem->label,temp);
		return true;

	case TYPE_COMBO:
		comboItem = (BCombo*)element;
		comboItem->GetSelectedItem(temp);
		str->Format("%s=%s;",comboItem->label,temp);
		return true;
	case TYPE_FILE:
		fileItem = (BFile*)element;
		fileItem->GetText(temp);
		str->Format("%s=%s;",fileItem->label,temp);
		return true;
	case TYPE_ELEMENT_HEADER:
		buttonItem = (BButton*)element;
		buttonItem->GetString(&temp);
		str->Format("%s",temp);
		return true;
	}

	return false;
}