473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Abstract Factory as a holder for different representation

Hi All

I am working on a Stock Exchange related program. Because I want, my
program be independent from specific market convention, I designed a
class hierarchy for market and a class hierarchy for Market Factory.
Market Factory is like Abstract Factory:
// Mrkt.h
struct Mrkt {
public:
class AbsIndividual {
public:
virtual ~AbsIndividual() =0 {}
};
virtual ~Mrkt() =0;
};

struct IranMrkt : Mrkt {
std::string Name;
struct IndividualBaseInfo : Mrkt::AbsIndividual {
std::string Nmae;
std::string FamilyName;
};

struct InvestmentCompBaseInfo : Mrkt::AbsIndividual {
std::string Name;
std::string ExecutiveMngr;
};
};

// MrktFactory.h

struct MrktFactory {
public:
virtual Mrkt::AbsIndividual* MakeIndividual() const =0;
virtual Mrkt::AbsIndividual* MakeInvestmentComp() const =0;

virtual ~MrktFactory() { }
};

struct IranMrktFactory : MrktFactory {
Mrkt::AbsIndividual* MakeIndividual() const {
return new IranMrkt::IndividualBaseInfo();
}
Mrkt::AbsIndividual* MakeInvestmentComp() const {
return new IranMrkt::InvestmentCompBaseInfo();
}
};

int main()
{
auto_ptr<MrktFactoryg_MrktFactory(new IranMrktFactory());
}

Up to here, my program is OK and everything is fine. But there is a
lot ot thing that I want to represent in specific market as a nested
class or object. For example, in IRAN, the market is opened at 9:00 am
and is closed at 12:30 pm. In IRAN, we use Solar system for
representing date and Thursday and Friday are holiday, so I should
have something like this:
struct IranMrkt : Mrkt {
struct Calendar {
// Calendar stuff
class IranianDate {
// ...
};
}
// ...
};
My problem is: after creating Factory in main and after it is clear
that program bound to IranMrkt, I want to write the following code:
int main()
{
auto_ptr<MrktFactoryg_MrktFactory(new IranMrktFactory());
IranMrkt::Calendar Cal;
// Stock Exchange Bell
pair<IranMrkt::Calendar::IranianTime,
IranMrkt::Calendar::IranianTimetheBell;
}
I want, it to be plug and play not ad-hoc. I want to retrieve the
class from created factory.
Would you please help me and offer your solution?

Regards,
S. Amrollahi
Nov 20 '07 #1
0 1015

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products....
4
by: max | last post by:
Hello, I analyze this design pattern for a long time but I do not understand how this pattern work and what the purpose is? (I looked a this site...
33
by: Chris Capel | last post by:
What is the rationale behind the decision not to allow abstract static class members? It doesn't seem like it's a logically contradictory concept, or that the implementation would be difficult or...
6
by: Tamir Khason | last post by:
I have some classes that basicly do the same things but different way. There are no default constructors in those classes each constructor should recieve same value So Fooclass:MyBasicClass...
2
by: Julia | last post by:
Hi, I have an application composed from layers like the following A --B ---C A is the top layer C uses an Abstract Factory to Create Concrete classes
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
0
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never...
6
by: Nindi | last post by:
5 Files Singleton.h The Singleton Factory.h The factory creating new objects. The Base class of the hierachy stores a typelist identifying the signature of the constructors to be called...
4
by: C# | last post by:
http://www.questpond.com/FreeDesign1.htm I was going through the above videos. Can i conclude Abstract factory patterns are extensions of factory patterns. I have made the conclusion after...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.