I am not sure why you are testing the class type specifically - ths should not be necessary if you are virtualising the behaviours of the class via the class reference, but assuming you have reasons for needing to work with class identity of a class reference...
You do not say which platform you are working on, but on Java the Java class types work quite well for these purposes, without needing to use Oxygene class references:
method Class4.DoSomething(c: &Class<Object>): Integer;
begin
case c of
typeOf(Class2): result := 0;
typeOf(Class3): result := 1;
else
result := 2;
end;
end;
// Examples of usage:
c4.DoSomething(typeOf(Class1));
someC := new Class3;
c4.DoSomething(someC.Class);
If you are not working on Java or need a platform-portable approach, then you could incorporate an alternate class identity in the classes using virtual class methods:
Class1 = public class
class method classID: Integer; virtual;
end;
Implement this to return some constant identifying Class1. Override in descendant classes to return an appropriate ID for each class. Then in your DoSomething method:
method Class4.DoSomething(c: Class1Class): Integer;
begin
case c.classID of
CLASS_2: result := 0;
CLASS_3: result := 1;
else
result := 2;
end;
end;