Saving dataloaders in C++

Hi,
I want to have a C++ source file that only has a test function (testFunction.cpp). As such, I was wondering if it is possible to read data, create a dataloader and store the dataloader in a .pt file, then load that dataloader in testFunction.cpp .
Thank you,
AntMorais