One thing than needs to be said right off the bat is that runtime polymorphism works in C++ via pointers to the base class not by value. So your
std::map<std::string, Action>needs to bestd::map<std::string, Action*>or your derived Actions (i.e.DisplayHelpAction) will be slicedsliced when copied into themap. StoringAction*also mean that you'll need to explicitly take care of freeing themapvalues when you're done. Note: you can use a boost::ptr_map (boost::ptr_map<std::string,Action>) (as @Fred Nurk pointed out) or a boost::shared_ptr (std::map<std::string,boost::shared_ptr<Action> >) to not worry about explicitly freeing theAction*allocated.
The same thing about 'Action getAction(std::string ActionString);' it needs to becomeAction* getAction(std::string ActionString);.The linker error is (most likely) caused by not providing an implementation for
virtual unsigned int ExecuteAction();. Also I'd say it makes sense to make it pure virtual (virtual unsigned int ExecuteAction() = 0;) - in which case you don't need to provide an implementation for it. It will also provide the closes semantics to a Java interface for theActionclass.Unless you have a very good reason for the
Actionderived objects to not know the entireboost:program_optionsI'd pass it down and let each of them access it directly instead of constructingstd::map<std::string, boost::any>.I'd rename
DetermineActionto something likeActionManagerorActionHandler.
One thing than needs to be said right off the bat is that runtime polymorphism works in C++ via pointers to the base class not by value. So your
std::map<std::string, Action>needs to bestd::map<std::string, Action*>or your derived Actions (i.e.DisplayHelpAction) will be sliced when copied into themap. StoringAction*also mean that you'll need to explicitly take care of freeing themapvalues when you're done. Note: you can use a boost::ptr_map (boost::ptr_map<std::string,Action>) (as @Fred Nurk pointed out) or a boost::shared_ptr (std::map<std::string,boost::shared_ptr<Action> >) to not worry about explicitly freeing theAction*allocated.
The same thing about 'Action getAction(std::string ActionString);' it needs to becomeAction* getAction(std::string ActionString);.The linker error is (most likely) caused by not providing an implementation for
virtual unsigned int ExecuteAction();. Also I'd say it makes sense to make it pure virtual (virtual unsigned int ExecuteAction() = 0;) - in which case you don't need to provide an implementation for it. It will also provide the closes semantics to a Java interface for theActionclass.Unless you have a very good reason for the
Actionderived objects to not know the entireboost:program_optionsI'd pass it down and let each of them access it directly instead of constructingstd::map<std::string, boost::any>.I'd rename
DetermineActionto something likeActionManagerorActionHandler.
One thing than needs to be said right off the bat is that runtime polymorphism works in C++ via pointers to the base class not by value. So your
std::map<std::string, Action>needs to bestd::map<std::string, Action*>or your derived Actions (i.e.DisplayHelpAction) will be sliced when copied into themap. StoringAction*also mean that you'll need to explicitly take care of freeing themapvalues when you're done. Note: you can use a boost::ptr_map (boost::ptr_map<std::string,Action>) (as @Fred Nurk pointed out) or a boost::shared_ptr (std::map<std::string,boost::shared_ptr<Action> >) to not worry about explicitly freeing theAction*allocated.
The same thing about 'Action getAction(std::string ActionString);' it needs to becomeAction* getAction(std::string ActionString);.The linker error is (most likely) caused by not providing an implementation for
virtual unsigned int ExecuteAction();. Also I'd say it makes sense to make it pure virtual (virtual unsigned int ExecuteAction() = 0;) - in which case you don't need to provide an implementation for it. It will also provide the closes semantics to a Java interface for theActionclass.Unless you have a very good reason for the
Actionderived objects to not know the entireboost:program_optionsI'd pass it down and let each of them access it directly instead of constructingstd::map<std::string, boost::any>.I'd rename
DetermineActionto something likeActionManagerorActionHandler.
One thing than needs to be said right off the bat is that runtime polymorphism works in C++ via pointers to the base class not by value. So your
std::map<std::string, Action>needs to bestd::map<std::string, Action*>or your derived Actions (i.e.DisplayHelpAction) will be sliced when copied into themap. StoringAction*also mean that you'll need to explicitly take care of freeing themapvalues when you're done. Note: you can use a boost::ptr_map (boost::ptr_map<std::string,Action>) (as @Fred Nurk pointed out) or a boost::shared_ptr (std::map<std::string,boost::shared_ptr<Action> >) to not worry about explicitly freeing theAction*allocated.
The same thing about 'Action getAction(std::string ActionString);' it needs to becomeAction* getAction(std::string ActionString);.The linker error is (most likely) caused by not providing an implementation for
virtual unsigned int ExecuteAction();. Also I'd say it makes sense to make it pure virtual (virtual unsigned int ExecuteAction() = 0;) - in which case you don't need to provide an implementation for it. It will also provide the closes semantics to a Java interface for theActionclass.Unless you have a very good reason for the
Actionderived objects to not know the entireboost:program_optionsI'd pass it down and let each of them access it directly instead of constructingstd::map<std::string, boost::any>.I'd rename
DetermineActionto something likeActionManagerorActionHandler.
One thing than needs to be said right off the bat is that runtime polymorphism works in C++ via pointers to the base class not by value. So your
std::map<std::string, Action>needs to bestd::map<std::string, Action*>or your derived Actions (i.e.DisplayHelpAction) will be sliced when copied into themap. StoringAction*also mean that you'll need to explicitly take care of freeing themapvalues when you're done.
The same thing about 'Action getAction(std::string ActionString);' it needs to becomeAction* getAction(std::string ActionString);.The linker error is (most likely) caused by not providing an implementation for
virtual unsigned int ExecuteAction();. Also I'd say it makes sense to make it pure virtual (virtual unsigned int ExecuteAction() = 0;) - in which case you don't need to provide an implementation for it. It will also provide the closes semantics to a Java interface for theActionclass.Unless you have a very good reason for the
Actionderived objects to not know the entireboost:program_optionsI'd pass it down and let each of them access it directly instead of constructingstd::map<std::string, boost::any>.I'd rename
DetermineActionto something likeActionManagerorActionHandler.
One thing than needs to be said right off the bat is that runtime polymorphism works in C++ via pointers to the base class not by value. So your
std::map<std::string, Action>needs to bestd::map<std::string, Action*>or your derived Actions (i.e.DisplayHelpAction) will be sliced when copied into themap. StoringAction*also mean that you'll need to explicitly take care of freeing themapvalues when you're done. Note: you can use a boost::ptr_map (boost::ptr_map<std::string,Action>) (as @Fred Nurk pointed out) or a boost::shared_ptr (std::map<std::string,boost::shared_ptr<Action> >) to not worry about explicitly freeing theAction*allocated.
The same thing about 'Action getAction(std::string ActionString);' it needs to becomeAction* getAction(std::string ActionString);.The linker error is (most likely) caused by not providing an implementation for
virtual unsigned int ExecuteAction();. Also I'd say it makes sense to make it pure virtual (virtual unsigned int ExecuteAction() = 0;) - in which case you don't need to provide an implementation for it. It will also provide the closes semantics to a Java interface for theActionclass.Unless you have a very good reason for the
Actionderived objects to not know the entireboost:program_optionsI'd pass it down and let each of them access it directly instead of constructingstd::map<std::string, boost::any>.I'd rename
DetermineActionto something likeActionManagerorActionHandler.
One thing than needs to be said right off the bat is that runtime polymorphism works in C++ via pointers to the base class not by value. So your
std::map<std::string, Action>needs to bestd::map<std::string, Action*>or your derived Actions (i.e.DisplayHelpAction) will be sliced when copied into themap. StoringAction*also mean that you'll need to explicitly take care of freeing themapvalues when you're done.
The same thing about 'Action getAction(std::string ActionString);' it needs to becomeAction* getAction(std::string ActionString);.The linker error is (most likely) caused by not providing an implementation for
virtual unsigned int ExecuteAction();. Also I'd say it makes sense to make it pure virtual (virtual unsigned int ExecuteAction() = 0;) - in which case you don't need to provide an implementation for it. It will also provide the closes semantics to a Java interface for theActionclass.Unless you have a very good reason for the
Actionderived objects to not know the entireboost:program_optionsI'd pass it down and let each of them access it directly instead of constructingstd::map<std::string, boost::any>.I'd rename
DetermineActionto something likeActionManagerorActionHandler.
One thing than needs to be said right off the bat is that runtime polymorphism works in C++ via pointers to the base class not by value. So your
std::map<std::string, Action>needs to bestd::map<std::string, Action*>or your derived Actions (i.e.DisplayHelpAction) will be sliced when copied into themap. StoringAction*also mean that you'll need to explicitly take care of freeing themapvalues when you're done.
The same thing about 'Action getAction(std::string ActionString);' it needs to becomeAction* getAction(std::string ActionString);.The linker error is (most likely) caused by not providing an implementation for
virtual unsigned int ExecuteAction();. Also I'd say it makes sense to make it pure virtual (virtual unsigned int ExecuteAction() = 0;) - in which case you don't need to provide an implementation for it. It will also provide the closes semantics to a Java interface for theActionclass.
One thing than needs to be said right off the bat is that runtime polymorphism works in C++ via pointers to the base class not by value. So your
std::map<std::string, Action>needs to bestd::map<std::string, Action*>or your derived Actions (i.e.DisplayHelpAction) will be sliced when copied into themap. StoringAction*also mean that you'll need to explicitly take care of freeing themapvalues when you're done.
The same thing about 'Action getAction(std::string ActionString);' it needs to becomeAction* getAction(std::string ActionString);.The linker error is (most likely) caused by not providing an implementation for
virtual unsigned int ExecuteAction();. Also I'd say it makes sense to make it pure virtual (virtual unsigned int ExecuteAction() = 0;) - in which case you don't need to provide an implementation for it. It will also provide the closes semantics to a Java interface for theActionclass.Unless you have a very good reason for the
Actionderived objects to not know the entireboost:program_optionsI'd pass it down and let each of them access it directly instead of constructingstd::map<std::string, boost::any>.I'd rename
DetermineActionto something likeActionManagerorActionHandler.