Maybe there is an easy way around this that I don't see, so hopefully someone can explain this to me.
Let's say I have a class:
class A { public: const double parameter; const std::string name; const std:: string fileName; A(const double parameter, const std::string name, const std::string fileName) : parameter(parameter), name(name), fileName(fileName) {}; };
And the generator for this class:
class AReader { public: ifstream dataFile; AReader(const std::string filename); A* readObject(const std::string objectName); };
I would like to use boost::flyweight
to process these A
objects, because they will have potentially millions of references to them, and in fact they contain a lot of data. They will be hashed on name
and fileName
together.
What do I need to do for this job? I need boost::flyweight
call AReader.readObject
and hash / save the resulting class A
Does AReader
need to become a full factory and be used as a custom factory? Or can you use the factory default in flies and somehow use AReader
to generate A
instances (as opposed to implementing the entire storage template required by the factory), perhaps by creating AReader
an example argument in something in flies? Or can you get the public variables const
(i.e. when they are set, they don't change) from an external data source without resorting to the second class?
Edit
I am also open to other offers not using Boost. I can, of course, write my own fly implementation or any other template if it works better. But if I can use what already exists, that would be better. Whatever reduces the amount of code I need to write, because, as always, there are short deadlines.
tpg2114
source share