If you are writing a library, and the client of your library knows the exact type desired, then they should pass to you the class's default instance (C++ and Java; in Python they might as well pass the class itself). In C++ this is MyType::default_instance(), in Java MyType.getDefaultInstance(). Given the default instance, you can call various methods on the interface to do everything you need. E.g. to parse:
C++:
Message* instance = default_instance->New();
instance->ParseFromString(data);
Java:
Message.Builder builder = defaultInstance.newBuilderForType().mergeFrom(data);
if (!builder.isInitialized()) {
return false;
}
Message instance = builder.build();