In my example data is passed between objects using a Data_Source. I want
to hide the method data is passed from what the value is of the data. So
a object receiving it does not need to be concerned with whether the
data is coming from a file or database.
In my situation I have three data sources for information: a file,
memory pointer or database. Each of these data sources can handle a
std::string, a Memory_Object, and a Graph_Object type as its internal
data structure. The question I want to understand is how to create a
generic interface to create the appropriate factory.
Here is the table of the possible data source combinations (3 types * 3
sources = 9 possible). So more types and more sources can make creating
the right Data_Source an ugly experience for maintaining the code. I
don't want to have to have 9 separate functions.
-----------------------------------------------------------
| File_Data_Src | Memory_Data_Src | Graph_Data_Src
-----------------------------------------------------------------------
std::string | x | x | x
------------------------------------------------------------------------
Memory Obj | x | x | x
------------------------------------------------------------------------
Graph Obj | x | x | x
------------------------------------------------------------------------
At initialization I give a interger the Data_Source_Factory_Creator to
represent what kind of factory I want. When a call is made to the
Data_Source_Factory_Creator::get_Factory I want the apporpriate factory
returned based upon the integer value given during initialization. Right
now I get the right compilor error for
Data_Source_Factory_Creator::get_Factory() because given
Data_Source_Factory is a template class I need to instantiate this
template correctly. I don't know how to make this function return a
generic type so that I can do:
Data_Source_Factory
participants (1)
-
Stephen torri