Files
UnrealEngineUWP/Engine/Source/Programs/UnrealHeaderTool/Private/Classes.h
Steve Robb 04c2da0cf2 #ttp 331467: Make UHT not depend on CoreUObject
#add FClass and FClasses added to encapsulate (and ultimately replace) UClass and FClassTree.
#add StringUtils contains a bunch of string-related functions which were in FHeaderParser for no real reason.
#change Replaced FClassTree with UHT and fixed up all the code which was affected.

#codereview robert.manuszewski

[CL 2045258 by Steve Robb in Main branch]
2014-04-23 18:42:01 -04:00

105 lines
3.6 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
Classes.h: Container structure for all the Classes.
=============================================================================*/
#pragma once
#include "ClassTree.h"
#define WIP_UHT_REFACTOR 1
class FClass;
class FClasses
{
public:
explicit FClasses(UPackage* InPackage);
/**
* Returns the root class (i.e. UObject)
*
* @return The root class.
*/
FClass* GetRootClass() const;
/**
* Determines whether the class hierarchy rooted at Suspect is
* dependent on the hierarchy rooted at Source.
*
* @param Suspect Root of hierarchy for suspect class
* @param Source Root of hierarchy for source class
* @return true if the hierarchy rooted at Suspect is dependent on the one rooted at Source, false otherwise
*/
bool IsDependentOn(const FClass* Suspect, const FClass* Source) const;
FClass* FindClass(const TCHAR* ClassName) const;
TArray<FClass*> GetDerivedClasses(FClass* Parent) const;
/**
* Attempts to find a script class based on the given name. Will attempt to strip
* the prefix of the given name while searching. Throws script errors when appropriate.
*
* @param InClassName Name w/ Unreal prefix to use when searching for a class
* @return The found class, or NULL if the class was not found.
*/
FClass* FindScriptClass(const FString& InClassName) const;
/**
* Attempts to find a script class based on the given name. Will attempt to strip
* the prefix of the given name while searching. Throws an exception with the script error
* if the class could not be found.
*
* @param InClassName Name w/ Unreal prefix to use when searching for a class
* @return The found class.
*/
FClass* FindScriptClassOrThrow(const FString& InClassName) const;
/**
* Attempts to find a script class based on the given name. Will attempt to strip
* the prefix of the given name while searching. Throws script errors when appropriate.
*
* @param InClassName Name w/ Unreal prefix to use when searching for a class
* @param OutErrorMsg Error message (if any) giving the caller flexibility in how they present an error
* @return The found class, or NULL if the class was not found.
*/
FClass* FindScriptClass(const FString& InClassName, FString& OutErrorMsg) const;
/**
* Returns an array of classes for the given package.
*
* @param InPackage The package to return the classes from.
* @return The classes in the specified package.
*/
TArray<FClass*> GetClassesInPackage(UPackage* InPackage = ANY_PACKAGE) const;
// Anything in here should eventually be removed when this class encapsulates its own data structure, rather than being 'poked' by the outside
#if WIP_UHT_REFACTOR
/**
* Move a class node in the hierarchy tree after a class has changed its SuperClass
*
* @param SearchClass the class that has changed parents
* @param InNewParentClass if non-null force reparenting to this instead of the SuperClass
*
* @return true if SearchClass was successfully moved to the new location
*/
void ChangeParentClass(FClass* Class);
/**
* Validates the state of the tree (shouldn't be needed once this class has well-defined invariants).
*/
void Validate();
#endif
private:
FClass* UObjectClass;
FClassTree ClassTree;
friend auto begin(const FClasses& Classes) -> decltype(begin(TObjectRange<FClass>())) { return begin(TObjectRange<FClass>()); }
friend auto end (const FClasses& Classes) -> decltype(end (TObjectRange<FClass>())) { return end (TObjectRange<FClass>()); }
};