Beispiel #1
0
void Structure::Graph::drawWithNames()
{
	for (int i = 0; i < nbNodes(); i++)
	{
		nodes[i]->drawWithName(i);
	}
}
Beispiel #2
0
Structure::Node* Structure::Graph::getNode( int idx )
{
	if (idx >= 0 && idx < nbNodes())
		return this->nodes[idx];
	else
		return nullptr;
}
Beispiel #3
0
bool Structure::Graph::selectNode( int nid )
{
	if (nid >= 0 && nid < nbNodes())
	{
		nodes[nid]->flipSelect();
		return nodes[nid]->isSelected;
	}

	return false;
}
		void VDVSubscriptionService::_setFromParametersMap(const ParametersMap& map)
		{
			string content(map.getDefault<string>(PARAMETER_POST_DATA));

			XMLResults results;
			XMLNode allNode = XMLNode::parseString(content.c_str(), "AboAnfrage", &results);
			if(	results.error != eXMLErrorNone ||
				allNode.isEmpty()
			){
				_errorNumber = "100";
				_errorText = "Malformed XML";
				return;
			}

			try
			{
				string sender(allNode.getAttribute("Sender"));
				_client = &DataExchangeModule::GetVDVClient(sender);

				// Trace
				_client->trace("AboAnfrage", content);

				// Check if the client is declared as active
				if(!_client->get<Active>())
				{
					_errorNumber = "300";
					_errorText = "Sender is forbidden right now";
					return;
				}

				// Subscriptions cleaning
				XMLNode cleanNode(allNode.getChildNode("AboLoeschenAlle"));
				if(!cleanNode.isEmpty())
				{
					string cleanNodeStr(cleanNode.getText());
					if(	cleanNodeStr == "true" ||
						cleanNodeStr == "1"
					){
						_client->cleanSubscriptions();
					}
				}

				// New subscriptions
				size_t nbNodes(allNode.nChildNode("AboAZB"));
				for(size_t i(0); i<nbNodes; ++i)
				{
					XMLNode aboAZBNode(allNode.getChildNode("AboAZB", static_cast<int>(i)));
					string id(aboAZBNode.getAttribute("AboID"));
					if(id.empty())
					{
						continue;
					}

					boost::shared_ptr<VDVClientSubscription> subscription(new VDVClientSubscription(id, *_client));

					if(aboAZBNode.nChildNode("AZBID"))
					{
						XMLNode azbidNode(aboAZBNode.getChildNode("AZBID"));
						StopArea* stopArea(
							_client->get<DataSource>()->getObjectByCode<StopArea>(azbidNode.getText())
						);
						if(!stopArea)
						{
							continue;
						}
						subscription->setStopArea(stopArea);
					}

					if(aboAZBNode.nChildNode("LinienID"))
					{
						XMLNode linienNode(aboAZBNode.getChildNode("LinienID"));
						CommercialLine* line(
							_client->get<DataSource>()->getObjectByCode<CommercialLine>(linienNode.getText())
						);
						if(!line)
						{
							continue;
						}
						subscription->setLine(line);
					}

					// Direction filter
					if(aboAZBNode.nChildNode("RichtungsID"))
					{
						XMLNode linienNode(aboAZBNode.getChildNode("RichtungsID"));
						subscription->setDirectionFilter(linienNode.getText());
					}

					XMLNode durationNode(aboAZBNode.getChildNode("Vorschauzeit"));
					if(!durationNode.isEmpty())
					{
						try
						{
							time_duration timeSpan(
								minutes(
									lexical_cast<long>(durationNode.getText())
							)	);
							subscription->setTimeSpan(timeSpan);
						}
						catch(bad_lexical_cast&)
						{
						}
					}

					XMLNode hysteresisNode(aboAZBNode.getChildNode("Hysterese"));
					if(!hysteresisNode.isEmpty())
					{
						try
						{
							time_duration hysteresis(
								seconds(
									lexical_cast<long>(hysteresisNode.getText())
							)	);
							subscription->setHysteresis(hysteresis);
						}
						catch(bad_lexical_cast&)
						{
						}
					}
					
					_client->addSubscription(subscription);
				}

			}
			catch (Exception&)
			{
				_errorNumber = "200";
				_errorText = "Invalid sender";
				return;
			}

			// Error if the VDV server is inactive
			if(!DataExchangeModule::GetVDVServerActive())
			{
				_errorNumber = "400";
				_errorText = "Service temporary unavailable";
				return;
			}
		}