This is probably extremely simple, but I am not comfortable with templates.
The Boost++ libraries define two templates which I wish to extend ...
template< class MostDerived,
class InitialState,
class Allocator = std::allocator< void >,
class ExceptionTranslator = null_exception_translator >
class state_machine : noncopyable
{};
template< class MostDerived,
class Context,
class InnerInitial = mpl::list<>,
history_mode historyMode = has_no_history >
class simple_state : public detail::simple_state_base_type< MostDerived,
typename Context::inner_context_type, InnerInitial >::type
{};
I would like to add a few more parameters, let's keep it simple and just start with a string which is state name or FSM name to use for debug tracing.
How do I extend these? And how do I declare an object of each of my new classes?
Thanks in advance for any help.
4 3157
These templates are empty classes. And they are concrete (you can have objects of these classes).
You do not derive from concrete classes.
Do the Boost folks say what the purpose of the templates is?
Well, the docs are on http://www.boost.org/doc/libs/1_36_0/libs/statechart/doc/index.html It all looks very good, but I'd like to add a few things. Just for starters, I'd like to pass a string giving the name of the state machine or state, which I can then use in debug tracing. When I get that working I can add more stuff.
I'd prefer to pass it in the constructor, rather than add a new method to set it, but I appear to be too dumb to do that :-(
Well, I figure the extension ought to be
template< class fsmName, // Hint: pass a std::string
class MostDerived,
class InitialState,
class Allocator = std::allocator< void >,
class ExceptionTranslator = null_exception_translator >
class myFsm : public sc::state_machine <MostDerived, InitialState, Allocator, ExceptionTranslator>
{
};
template< class fsmStateName, // Hint: pass a std::string
class MostDerived,
class Context,
class InnerInitial = mpl::list<>,
history_mode historyMode = has_no_history >
class myFsmState : public sc::simple_state <MostDerived, Context>
{
};
Butt I can't figure out how to declare an object for a state machine and one for a state :-(
If you have a template, say line this: -
template<class T, class U>
-
class MyClass
-
{
-
T data;
-
U data1;
-
-
};
-
You create objects by specializing the template. That is, you specify at compile time what the template will be converted into. -
MyClass<string, int> obj;
-
MyClass<int, double> obj1;
-
There's no "passing to the contructor".
You do understand that the compiler makes a copy of the template and replaces the placeholders (like T and U) with the actual types and it is this copy that is compiled and used in your program?
If fsmStateName or fsmName are strings, then call out a string as the first parameter of your template. -
myFsm<string, etc...> mystatemachine;
-
myFsmState<string, etc.....> mystate;
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Qun Cao |
last post by:
Hi Everyone,
I am a beginner on cross language development. My problem at hand is to
build a python interface for a C++ application built on top of a 3D
game engine. The purpose of this python...
|
by: Michal Nazarewicz |
last post by:
Let say I have a class template Pair representing an ordered pair, ie:
#v+
template<class T1, class T2>
class Pair {
T1 a;
T2 b;
public:
Pair() : a(), b() { }
Pair(const Pair<T1, T2&p) :...
|
by: Bit Byte |
last post by:
Can't seem to get my head around the point of a trait class - no matter
how many times I read up on it - why not simply use functors or function
pointers ?
Anyone care to explain this in a...
|
by: David Sanders |
last post by:
Hi,
As part of a simulation program, I have several different model
classes, ModelAA, ModelBB, etc., which are all derived from the class
BasicModel by inheritance.
model to use, for example...
|
by: Simon G Best |
last post by:
Hello!
I'm trying to specialize a member function template of a class template,
like this:-
template<typename Tclass thingy {
public:
template<typename UT f (const U &) const;
};
|
by: jamesrjones |
last post by:
I'm writing a template library that models the IEEE754(r) decimal
arithmetic standard, and I'd like to provide numeric_limits<for my
templates. The problem is that I'm not sure how to do this.
...
|
by: Kevin |
last post by:
I'm creating a template to support state machines. In doing so, I
need to pass an enumeration for the number of transitions and a non
type parameter for the range of the enum (to allow me to...
|
by: alan |
last post by:
I'm creating a sort-of "wrapper" class which (partly) acts like a
variable. Something like:
template<class t>
class cell{
t curval;
public:
/*public for debugging only - will be private in...
|
by: Chris M. Thomasson |
last post by:
FWIW, here is a quick example (in the form of a fully compliable program
with error checking omitted) of how I use POSIX threads within a C++
environment:...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |