473,886 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

templatized state model

Does anyone know of any c++ templates that can be used for state
representation (i.e. state models)?

My question is vague since I am looking for references (websites or books)
where templates can be used to model states.

Jul 19 '05 #1
1 1428
On Mon, 08 Sep 2003 13:05:30 -0500, skscpp wrote:
Does anyone know of any c++ templates that can be used for state
representation (i.e. state models)? It can be done. (See below)
My question is vague since I am looking for references (websites or books)
where templates can be used to model states.

Unfortunatly i don't know any books or websites.

Depending on what you exactly want the solutions differ extremely. But
here is one example (although there would be other and probably better
solutions to do only the things i do in the example, but you probably
have some better use for templates representing states):

template <class State> class MyClass{
State myState;

template <class NewState> MyClass<NewStat e> copyAndChangeSt ate(ns)
MyClass<NewStat e> objectWithChang edState;
// copy all needed data from this to objectWithChang edState;
// initialise the state with information from ns.

template <class OldState, class NewState> changeState(Old State o, NewState n)
// the default behaviour is that the transition is illegal.
// Specializations of this template method are needed to define
// possible transitions.
throw EInvallidStateT ransition();

template <> changeState(Sta te1 s1, State2 s2)
// A specialization enabling transitions from Sate1 to State2

template <class NewState> MyClass<NewStat e> transition(NewS tate ns)
changeState(myS tate, ns);
// unfortiunatly we have to create an new object an return that.
// But you might be able to use some pointers to avoid this.
return copyAndChangeSt ate(ns);

Good luck. If you have more questions or i understood you completely wrong
let me know (could you please email me a copy also?)

Jul 19 '05 #2

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

Similar topics

by: aurgathor | last post by:
Howdy, I got the templatized class Matrix working in the way it's written in the faq , and it works fine as: Matrix<sqr_T> display(80,25); However, I'd like to have this variable in the private section of another class, and I'd like to instantiate in the class's constructor, with the option of having a size determined at run-time.
by: Someonekicked | last post by:
I know this might not be the right group to post this question, though I am looking for any help or redirection to the right group. Its a small program, and I have to model it using state diagrams. Two of the main funtions in the program are recursive. I searched online for any examples of how to model recursive funtions with state diagrams, I could not find any real examples. Does anybody know where I can get any examples of how to...
by: James Hunter Ross | last post by:
We love the ASP.NET "Session" concept and make good use of it. But, getting close to deployment we find we lose sessions far too often, probably due to application restarts, etc. We hope to eliminate these restarts, but we're not sure that can be achieved. (We are exploring who/what might be touching web.config or assemblies or other files in our application, but have found nothing so far.) We have some serious rewriting to do if all...
by: stephen.nil | last post by:
http://code.google.com/p/spxml/ spxml is a xml parser, supports PULL-model and DOM-model xml parsing. Using state pattern make it simple to implement the xml parser. State pattern has three participants: * Context ( SP_XmlPullParser ) o defines the interface of interest to clients o maintains an instance of a ConcreteState subclass that defines the current state.
by: Andrew Teece | last post by:
Hope someone can help. We are trying to deploy an ASP.Net 2.0 application to a 3-node webfarm. The application uses the ReportViewer control in local mode, hence we need session state. Because we dont wan't a single point of failure we use SQL Session State. I have setup a persistant sql session state database on a SQL 2000 server (this is a cluster in production, so no SPOF) I have setup our web.config files to include; " <sessionState...
by: Smokey Grindle | last post by:
What are the advantages of using ASP.NET's session state server service over using InProc state sessions? Also if you have a state server service running, is there any way to find out when a session ended? with the inproc ones you can use the global.asax's session_ended method...
by: gary.bernstein | last post by:
I want to call a singleton getInstance function to retrieve a templatized object without knowing what types were used to create the singleton object in the first call to getInstance. How can I do this non-intrusively -- I.e., without, for example, typedef'ing the types in every compilation unit? Background: Our code base has assert macros that need to reboot the system after notifying components via a single templatized Component...
by: johnthawk | last post by:
In the below code setting cell to inconsistent sets entire column inconsistent (renderer).However, I need a third state off | on | inconsistent . How can I change one path->cell? Any help appreciated. Thanks john # get current value fixed = model.get_value(iter, MARK_FOR_COLUMN) icont = model.get_value(iter,MARK_FOR_INCONSISTENT) # clear for action
by: galathaea | last post by:
it surprises me how often engineers confuse states with actions i think this is the fundamental reification behind procedural statemess and this mistake infects a lot of great projects with entropising debate this error is the type of complexity growing belief that changes a simple state transition o -------o to clever decompositions into state sequences
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.