Guest User

Untitled

a guest
Jul 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public class EventStoreInterface{
  2. // this will be our virtual class
  3. // it will contains abstract functions/methods addOccation, checkOccation, etc
  4. }
  5.  
  6. class CSVEventStore: public EventStoreInterface{
  7. // We have inherited EventStoreInterface
  8. // Here we have implementation of functions like addOccation, checkOccation, etc specifically for CSV
  9. }
  10.  
  11. class XMLEventStore: public EventStoreInterface{
  12. // We have inherited EventStoreInterface
  13. // Here we have implementation of functions like addOccation, checkOccation, etc specifically for XML
  14. }
  15.  
  16.  
  17. // Now the main function would look something like this
  18. int main(int argc, char *argv[])
  19. {
  20. if(argv[1] == "xml")
  21. {
  22. EventStoreInterface Event = new XMLEventStore;
  23. }
  24. if(argv[1] == "csv")
  25. {
  26. EventStoreInterface Event = new CSVEventStore;
  27. }
  28. /* Now we will pass the "Event" to our gui(MainWindow) and will call the methods of it, which will hide whether the method of XMLEventStore is called or of CSVEventStore.
  29. */
  30. }
  31.  
  32. // This type of implementation will hide the data storage from the rest of the application. The business layer / UI also will not know which backend is used.
Add Comment
Please, Sign In to add comment