Exemplo n.º 1
0
			Cycle                                            * XeoTerm::defaultCycle(QString _context, QDateTime _time){
				if(contain(_context)){
					VariableContextSpec * pcs = (*this->contextCollection)[_context];
					if(pcs->get_defCycle()!=NULL){
						Cycle * v = new Cycle();
						v->set_context(_context);
						for(std::list<std::pair<QDateTime, QString> >::iterator it = pcs->get_defCycle()->get_vals()->begin();it!=pcs->get_defCycle()->get_vals()->end();++it)
						{
							std::pair<DynamicValueBase*,QDateTime> p =std::make_pair(new DynamicValue(it->first,it->second),_time);
							v->add_cycleValue(p);
						}
						if(pcs->get_unitSet()->get_defUnit()!=NULL)
						{
							v->set_unit(pcs->get_unitSet()->get_defUnit()->get_symbol());
						}
						v->set_timepoint(_time);
						return v;
					}
					else
						return NULL;
				}
				else{
					return NULL;
				}
			}
Exemplo n.º 2
0
			DynamicValue                                     * XeoTerm::defaultdynamicValue(QString _context, QDateTime _time){
				if(contain(_context)){
					VariableContextSpec * pcs = (*this->contextCollection)[_context];
					DynamicValue * v = new DynamicValue();
					v->set_context(_context);
					QString tmp=pcs->get_defValue();
					if((!tmp.isEmpty())||(!tmp.size()==0)){
						v->set_value(pcs->get_defValue());
					}
					else
					{
						if(this->hasDefaultCycle(_context))
						{
							v->set_value(static_cast<DynamicValue*>(this->defaultCycle(_context)->get_cycleValues()->front().first)->get_value());
						}
						else
						{
							switch (pcs->get_typeDefine()->get_baseType())
							{
								case Xeml::Document::Number:
								{
									v->set_doubleValue(0.0);
									break;
								}
								case Xeml::Document::Text:
								{
									v->set_value("");
									break;
								}
								case Xeml::Document::Bool:
								{
									v->set_booleanValue(false);
									break;
								}
								default:
									v->set_value("");
									break;

							}
						}
					}
					if(pcs->get_unitSet()->get_defUnit()!=NULL)
					{
						v->set_unit(pcs->get_unitSet()->get_defUnit()->get_symbol());
					}
					v->set_timepoint(_time);
					return v;
				}
				else{
					return NULL;
				}



			}
Exemplo n.º 3
0
			QString                                        XeoTerm::defaultUnitSymbol(QString _context){
				if(this->hasDefaultUnit(_context))
				{
					VariableContextSpec * pcs = (*this->contextCollection)[_context];
					return pcs->get_unitSet()->get_defUnit()->get_symbol();
				}
				else
				{
					return NULL;
				}
			}
Exemplo n.º 4
0
			bool                                               XeoTerm::hasDefaultUnit(QString _context){
				if (this->contain(_context))
				{

					VariableContextSpec * pcs = (*this->contextCollection)[_context];
					return pcs->get_unitSet()->get_defUnit() != NULL;
				}
				else
				{
					std::cerr <<"exception thrown" << std::endl;
					throw exception();
				}
			}
Exemplo n.º 5
0
			std::vector<std::pair<QString,QString> > * XeoTerm::listUnits(QString _context){
				if (this->contain(_context))
				{
					std::vector<std::pair<QString,QString> > * ret =new std::vector<std::pair<QString,QString> >();
					VariableContextSpec * pcs = (*this->contextCollection)[_context];
					if(pcs!=NULL)
					{
						if(pcs->get_unitSet()->get_defUnit()!=NULL)
						{
							ret->push_back(std::make_pair(pcs->get_unitSet()->get_defUnit()->get_name(),pcs->get_unitSet()->get_defUnit()->get_symbol()));
						}
						for(std::list<ConvertableUnit*>::iterator it=pcs->get_unitSet()->get_convUnits()->begin();it!=pcs->get_unitSet()->get_convUnits()->end();++it)
						{
							ret->push_back(std::make_pair((*it)->get_name(),(*it)->get_symbol()));
						}
					}
					return ret;
				}
				else
				{
					throw exception();
				}
			}