bool AIObject::GetLastCommandRes()
{
	return GetStorage()->last_command_res;
}
bool AIObject::CanSuspend()
{
	Squirrel *squirrel = Company::Get(_current_company)->ai_instance->engine;
	return GetStorage()->allow_do_command && squirrel->CanSuspend();
}
Esempio n. 3
0
{
  m_listeners.erase(slotID);
}

void ActiveMapsLayout::DownloadMap(TIndex const & index, MapOptions const & options)
{
  MapOptions validOptions = ValidOptionsForDownload(options);
  Item * item = FindItem(index);
  if (item)
  {
    ASSERT(item != nullptr, ());
    item->m_downloadRequest = validOptions;
  }
  else
  {
    Storage const & s = GetStorage();
    vector<TIndex> arr = s.FindAllIndexesByFile(s.GetCountryFile(index).GetNameWithoutExt());
    int position = InsertInGroup(TGroup::ENewMap, { arr, TStatus::ENotDownloaded, validOptions, validOptions });
    NotifyInsertion(TGroup::ENewMap, position);
  }

  m_framework.DownloadCountry(index, validOptions);
}

void ActiveMapsLayout::DownloadMap(TGroup const & group, int position, MapOptions const & options)
{
  Item & item = GetItemInGroup(group, position);
  item.m_downloadRequest = ValidOptionsForDownload(options);
  m_framework.DownloadCountry(item.Index(), item.m_downloadRequest);
}
void AIObject::SetNewGroupID(GroupID group_id)
{
	GetStorage()->new_group_id = group_id;
}
void AIObject::SetAllowDoCommand(bool allow)
{
	GetStorage()->allow_do_command = allow;
}
void AIObject::SetNewSignID(SignID sign_id)
{
	GetStorage()->new_sign_id = sign_id;
}
void AIObject::SetNewTunnelEndtile(TileIndex tile)
{
	GetStorage()->new_tunnel_endtile = tile;
}
Esempio n. 8
0
UnicodeString TXmlStorage::GetSource()
{
  return GetStorage();
}
Esempio n. 9
0
	const CSection *CItem::GetSection(BYTE byID) const { return static_cast<const CSection *>(GetStorage(byID)); }
Esempio n. 10
0
LocalAndRemoteSizeT const ActiveMapsLayout::GetCountrySize(TIndex const & index, MapOptions const & options) const
{
  return GetStorage().CountrySizeInBytes(index, options);
}
Esempio n. 11
0
LocalAndRemoteSizeT const ActiveMapsLayout::GetRemoteCountrySizes(TIndex const & index) const
{
  platform::CountryFile const & c = GetStorage().CountryByIndex(index).GetFile();
  size_t const mapSize = c.GetRemoteSize(MapOptions::Map);
  return { mapSize, c.GetRemoteSize(MapOptions::CarRouting) };
}
Esempio n. 12
0
LocalAndRemoteSizeT const ActiveMapsLayout::GetDownloadableCountrySize(TIndex const & index) const
{
  Item const * item = FindItem(index);
  ASSERT(item, ());
  return GetStorage().CountrySizeInBytes(index, item->m_downloadRequest);
}
Esempio n. 13
0
LocalAndRemoteSizeT const ActiveMapsLayout::GetDownloadableCountrySize(TGroup const & group, int position) const
{
  Item const & item = GetItemInGroup(group, position);
  return GetStorage().CountrySizeInBytes(item.Index(), item.m_downloadRequest);
}
Esempio n. 14
0
string const & ActiveMapsLayout::GetCountryName(TIndex const & index) const
{
  return GetStorage().CountryName(index);
}
void AIObject::SetNewVehicleID(VehicleID vehicle_id)
{
	GetStorage()->new_vehicle_id = vehicle_id;
}
Esempio n. 16
0
	const CItem *CSection::GetItem(BYTE byID) const { return static_cast<const CItem *>(GetStorage(byID)); }
VehicleID AIObject::GetNewVehicleID()
{
	return GetStorage()->new_vehicle_id;
}
Esempio n. 18
0
wxString pgType::GetSql(ctlTree *browser)
{
	if (sql.IsNull())
	{
		sql = wxT("-- Type: ") + GetQuotedFullIdentifier() + wxT("\n\n")
		      + wxT("-- DROP TYPE ") + GetQuotedFullIdentifier() + wxT(";")
		      + wxT("\n\nCREATE TYPE ") + GetQuotedFullIdentifier();
		if (GetTypeClass() == TYPE_COMPOSITE)
		{
			sql += wxT(" AS\n   (");
			sql += GetQuotedTypesList();
		}
		else if (GetTypeClass() == TYPE_ENUM)
		{
			sql += wxT(" AS ENUM\n   (");
			sql += GetQuotedLabelList();
		}
		else if (GetTypeClass() == TYPE_RANGE)
		{
			sql += wxT(" AS RANGE\n   (")
			       wxT("SUBTYPE=") + rngsubtypestr;
			if (!rngsubopcstr.IsEmpty())
				sql += wxT(",\n    SUBTYPE_OPCLASS=") + rngsubopcstr;
			if (!rngcollationstr.IsEmpty())
				sql += wxT(",\n    COLLATION=") + rngcollationstr;
			if (!rngcanonical.IsEmpty())
				sql += wxT(",\n    CANONICAL=") + rngcanonical;
			if (!rngsubdiff.IsEmpty())
				sql += wxT(",\n    SUBTYPE_DIFF=") + rngsubdiff;
		}
		else
		{
			sql += wxT("\n   (INPUT=") + qtIdent(GetInputFunction())
			       + wxT(",\n       OUTPUT=") + qtIdent(GetOutputFunction());
			if (GetConnection()->BackendMinimumVersion(7, 4))
			{
				if (!GetReceiveFunction().IsEmpty())
				{
					sql += wxT(",\n       RECEIVE=") + GetReceiveFunction();
				}
				if (!GetSendFunction().IsEmpty())
				{
					sql += wxT(",\n       SEND=") + GetSendFunction();
				}
			}
			if (GetConnection()->BackendMinimumVersion(8, 3))
			{
				if (!GetTypmodinFunction().IsEmpty())
					sql += wxT(",\n       TYPMOD_IN=") + GetTypmodinFunction();
				if (!GetTypmodoutFunction().IsEmpty())
					sql += wxT(",\n       TYPMOD_OUT=") + GetTypmodoutFunction();
				if (GetAnalyzeFunction() != wxEmptyString)
					sql += wxT(",\n       ANALYZE=") + GetAnalyzeFunction();
			}
			if (GetConnection()->BackendMinimumVersion(8, 4))
			{
				sql += wxT(",\n       CATEGORY=") + qtDbString(GetCategory());
				if (GetPrefered())
					sql += wxT(",\n       PREFERRED=true");
			}
			if (GetPassedByValue())
				sql += wxT(",\n    PASSEDBYVALUE");
			AppendIfFilled(sql, wxT(", DEFAULT="), qtDbString(GetDefault()));
			if (!GetElement().IsNull())
			{
				sql += wxT(",\n       ELEMENT=") + GetElement()
				       + wxT(", DELIMITER='") + GetDelimiter() + wxT("'");
			}
			sql += wxT(",\n       INTERNALLENGTH=") + NumToStr(GetInternalLength())
			       + wxT(", ALIGNMENT=" + GetAlignment()
			             + wxT(", STORAGE=") + GetStorage());
			if (GetConnection()->BackendMinimumVersion(9, 1) && GetCollatable())
			{
				sql += wxT(",\n       COLLATABLE=true");
			}
			if (GetConnection()->BackendMinimumVersion(9, 1) && GetCollatable())
			{
				sql += wxT(",\n       COLLATABLE=true");
			}
		}
		sql += wxT(");\n")
		       + GetOwnerSql(8, 0)
		       + GetCommentSql();

		if (GetConnection()->BackendMinimumVersion(9, 1))
			sql += GetSeqLabelsSql();
	}

	return sql;
}
SignID AIObject::GetNewSignID()
{
	return GetStorage()->new_sign_id;
}
Esempio n. 20
0
void pgType::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	wxString query;
	wxString collation;

	if (!expandedKids)
	{
		expandedKids = true;
		if (GetTypeClass() == TYPE_COMPOSITE)
		{
			query = wxT("SELECT attname, format_type(t.oid,NULL) AS typname, attndims, atttypmod, nsp.nspname,\n")
			        wxT("       (SELECT COUNT(1) from pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup");
			if (GetConnection()->BackendMinimumVersion(9, 1))
				query += wxT(",\n       collname, nspc.nspname as collnspname");
			query += wxT("\n  FROM pg_attribute att\n")
			         wxT("  JOIN pg_type t ON t.oid=atttypid\n")
			         wxT("  JOIN pg_namespace nsp ON t.typnamespace=nsp.oid\n")
			         wxT("  LEFT OUTER JOIN pg_type b ON t.typelem=b.oid\n");
			if (GetConnection()->BackendMinimumVersion(9, 1))
				query += wxT("  LEFT OUTER JOIN pg_collation c ON att.attcollation=c.oid\n")
				         wxT("  LEFT OUTER JOIN pg_namespace nspc ON c.collnamespace=nspc.oid\n");
			query += wxT(" WHERE att.attrelid=") + NumToStr(relOid) + wxT("\n")
			         wxT(" ORDER by attnum");
			pgSet *set = ExecuteSet(query);
			if (set)
			{
				int anzvar = 0;
				while (!set->Eof())
				{
					wxString element;
					if (anzvar++)
					{
						typesList += wxT(", ");
						quotedTypesList += wxT(",\n    ");
					}
					typesList += set->GetVal(wxT("attname")) + wxT(" ");
					typesArray.Add(set->GetVal(wxT("attname")));
					quotedTypesList += qtIdent(set->GetVal(wxT("attname"))) + wxT(" ");

					pgDatatype dt(set->GetVal(wxT("nspname")), set->GetVal(wxT("typname")),
					              set->GetBool(wxT("isdup")), set->GetLong(wxT("attndims")) > 0, set->GetLong(wxT("atttypmod")));

					wxString nspname = set->GetVal(wxT("nspname"));

					typesList += dt.GetSchemaPrefix(GetDatabase()) + dt.FullName();
					typesArray.Add(dt.GetSchemaPrefix(GetDatabase()) + dt.FullName());
					quotedTypesList += dt.GetQuotedSchemaPrefix(GetDatabase()) + dt.QuotedFullName();

					if (GetConnection()->BackendMinimumVersion(9, 1))
					{
						if (set->GetVal(wxT("collname")).IsEmpty() || (set->GetVal(wxT("collname")) == wxT("default") && set->GetVal(wxT("collnspname")) == wxT("pg_catalog")))
							collation = wxEmptyString;
						else
						{
							collation = qtIdent(set->GetVal(wxT("collnspname"))) + wxT(".") + qtIdent(set->GetVal(wxT("collname")));
							quotedTypesList += wxT(" COLLATE ") + collation;
						}
						collationsArray.Add(collation);
					}
					typesArray.Add(collation);

					set->MoveNext();
				}
				delete set;
			}
		}
		else if (GetTypeClass() == TYPE_ENUM)
		{
			query = wxT("SELECT enumlabel\n")
			        wxT("  FROM pg_enum\n")
			        wxT(" WHERE enumtypid=") + GetOidStr() + wxT("\n");
			if (GetConnection()->BackendMinimumVersion(9, 1))
				query += wxT(" ORDER by enumsortorder");
			else
				query += wxT(" ORDER by oid");
			pgSet *set = ExecuteSet(query);
			if (set)
			{
				int anzvar = 0;
				while (!set->Eof())
				{
					wxString element;
					if (anzvar++)
					{
						labelList += wxT(", ");
						quotedLabelList += wxT(",\n    ");
					}
					labelList += set->GetVal(wxT("enumlabel"));
					labelArray.Add(set->GetVal(wxT("enumlabel")));
					quotedLabelList += GetDatabase()->connection()->qtDbString(set->GetVal(wxT("enumlabel")));

					set->MoveNext();
				}
				delete set;
			}
		}
		else if (GetTypeClass() == TYPE_RANGE)
		{
			query = wxT("SELECT rngsubtype, st.typname, ")
			        wxT("rngcollation, col.collname, ")
			        wxT("rngsubopc, opc.opcname, ")
			        wxT("rngcanonical, rngsubdiff\n")
			        wxT("FROM pg_range\n")
			        wxT("LEFT JOIN pg_type st ON st.oid=rngsubtype\n")
			        wxT("LEFT JOIN pg_collation col ON col.oid=rngcollation\n")
			        wxT("LEFT JOIN pg_opclass opc ON opc.oid=rngsubopc\n")
			        wxT("WHERE rngtypid=") + GetOidStr();
			pgSet *set = ExecuteSet(query);
			if (set)
			{
				iSetSubtypeFunction(set->GetLong(wxT("rngsubtype")));
				iSetSubtypeFunctionStr(set->GetVal(wxT("typname")));
				iSetCollationFunction(set->GetLong(wxT("rngcollation")));
				iSetCollationFunctionStr(set->GetVal(wxT("collname")));
				iSetSubtypeOpClassFunction(set->GetLong(wxT("rngsubopc")));
				iSetSubtypeOpClassFunctionStr(set->GetVal(wxT("opcname")));
				if (set->GetVal(wxT("rngcanonical")) != wxT("-"))
					iSetCanonical(set->GetVal(wxT("rngcanonical")));
				if (set->GetVal(wxT("rngsubdiff")) != wxT("-"))
					iSetSubtypeDiff(set->GetVal(wxT("rngsubdiff")));
			}
		}
	}

	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Owner"), GetOwner());
		if (GetConnection()->BackendMinimumVersion(9, 2))
			properties->AppendItem(_("ACL"), GetAcl());
		properties->AppendItem(_("Alias"), GetAlias());
		if (GetTypeClass() == TYPE_COMPOSITE)
		{
			properties->AppendItem(_("Members"), GetTypesList());
		}
		if (GetTypeClass() == TYPE_ENUM)
		{
			properties->AppendItem(_("Labels"), GetLabelList());
		}
		else if (GetTypeClass() == TYPE_RANGE)
		{
			properties->AppendItem(_("Subtype"), GetSubtypeFunctionStr());
			properties->AppendItem(_("Collation"), GetCollationFunctionStr());
			properties->AppendItem(_("Subtype OpClass"), GetSubtypeOpClassFunctionStr());
			properties->AppendItem(_("Canonical"), GetCanonical());
			properties->AppendItem(_("Subtype diff"), GetSubtypeDiff());
		}
		else
		{
			properties->AppendItem(_("Alignment"), GetAlignment());
			properties->AppendItem(_("Internal length"), GetInternalLength());
			properties->AppendItem(_("Default"), GetDefault());
			properties->AppendItem(_("Passed by Value?"), BoolToYesNo(GetPassedByValue()));
			if (!GetElement().IsEmpty())
			{
				properties->AppendItem(_("Element"), GetElement());
				properties->AppendItem(_("Delimiter"), GetDelimiter());
			}
			properties->AppendItem(_("Input function"), GetInputFunction());
			properties->AppendItem(_("Output function"), GetOutputFunction());
			if (GetConnection()->BackendMinimumVersion(7, 4))
			{
				properties->AppendItem(_("Receive function"), GetReceiveFunction());
				properties->AppendItem(_("Send function"), GetSendFunction());
				properties->AppendItem(_("Analyze function"), GetAnalyzeFunction());
			}
			if (GetConnection()->BackendMinimumVersion(8, 4))
			{
				properties->AppendItem(_("Category"), GetCategory());
				properties->AppendItem(_("Prefered?"), BoolToYesNo(GetPrefered()));
			}
			if (GetConnection()->BackendMinimumVersion(8, 3))
			{
				if (GetTypmodinFunction().Length() > 0)
					properties->AppendItem(_("Typmod in function"), GetTypmodinFunction());
				if (GetTypmodoutFunction().Length() > 0)
					properties->AppendItem(_("Typmod out function"), GetTypmodoutFunction());
			}
			properties->AppendItem(_("Storage"), GetStorage());
			if (GetConnection()->BackendMinimumVersion(9, 1))
				properties->AppendItem(_("Collatable?"), BoolToYesNo(GetCollatable()));
		}
		properties->AppendYesNoItem(_("System type?"), GetSystemObject());
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));

		if (!GetLabels().IsEmpty())
		{
			wxArrayString seclabels = GetProviderLabelArray();
			if (seclabels.GetCount() > 0)
			{
				for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2)
				{
					properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1));
				}
			}
		}
	}
}
TileIndex AIObject::GetNewTunnelEndtile()
{
	return GetStorage()->new_tunnel_endtile;
}
UnicodeString TRegistryStorage::GetSource()
{
  return RootKeyToStr(FRegistry->GetRootKey()) + L"\\" + GetStorage();
}
GroupID AIObject::GetNewGroupID()
{
	return GetStorage()->new_group_id;
}
void AIObject::SetRailType(RailType rail_type)
{
	GetStorage()->rail_type = rail_type;
}
bool AIObject::GetAllowDoCommand()
{
	return GetStorage()->allow_do_command;
}
RailType AIObject::GetRailType()
{
	return GetStorage()->rail_type;
}
void AIObject::SetCallbackVariable(int index, int value)
{
	if ((size_t)index >= GetStorage()->callback_value.size()) GetStorage()->callback_value.resize(index + 1);
	GetStorage()->callback_value[index] = value;
}
	VSSStorageHelper(	VSTRING_CONST	pszFileName,
						VBOOL			bCreateIfNeeded = VTRUE,
						VDWORD			nMode = VSS_DEFAULT_MODE)
		: VSSObjectHelper(VSS_RTTI_STORAGE, NULL, NULL)
	{
		m_nMode = nMode;
		OpenFile(pszFileName, bCreateIfNeeded);
	}

	/** Copy the contents of this storage object to another.*/
	VBOOL				CopyTo(IStorage* pDestStorage) const
	{
		VASSERT(pDestStorage && GetStorage())

		return (SUCCEEDED(GetStorage()->CopyTo(	0,
												NULL,
												NULL,
												pDestStorage)))
												? VTRUE : VFALSE;
	}

	/** Create a named storage as a sub-storage of this object, returning a
	pointer to it on success, NULL on failure. The object returned from this
	function is owned by this class, and its lifetime is controlled here.
	Client code should not attempt to Release() or delete this object.*/
	VSSStorageHelper*	CreateStorage(VSTRING_CONST pszName)
		{ return CreateOrOpenStorage(pszName, VTRUE); }

	/** Create a named stream as a sub-stream of this object, returning a
	pointer to it on success, NULL on failure. The object returned from
	this function is owned by this class, and its lifetime is controlled here.
	Client code should not attempt to Release() or delete this object.*/