VR-Forces 4.1.1 Class Documentation
derivedSRUserExt.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2005 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: derivedSRUserExt.h,v $ $Revision: 1.4 $ $State: Exp $
7 *******************************************************************************/
8 
9 #ifndef DerivedSRUserExtension_H_
10 #define DerivedSRUserExtension_H_
11 
13 #include "vrfutil/rwString.h"
14 
15 //class DerivedSRUserExtension:
16 //
17 //Instances of DerivedSRUserExtension are an example of an extension to
18 //a base state repository class. It provides a way to extend an entity's state
19 //information independent at a lower level in the state repository hierarchy.
20 //All entities in VR-Forces have at a minimum a DtVrfObjectStateRepsitory, which
21 //can be extended in this way. By extending a state repository through the
22 //DtVrfStateRepostioryUserExtension class, you don't have to extend multiple
23 //leaf-level state repository classes to add the same kind of extension
24 //to different kinds of entities (e.g. ground vehicles and air entities, both
25 //of which have different derived state repository classes).
26 //
27 //A state repository extension object (DtVrfStateRepositoryUserExtension) can be
28 //initialized from a parameter database, and then saved/restored as part of an
29 //entity's state in an order of battle file.
30 //
31 //This example of a user-defined state repository extensions class contains a
32 //single new data member, myTag (a new kind of identifier). The myTag member
33 //variable is a readable, writeable string (DtRwString). myTag is registered
34 //with the name "my-tag" in this class' constructor.
35 //
36 //The class returns a new type string "my-state-repository-user-extension".
37 //This is the key that gets registered with the factory so VR-Forces will
38 //know how to create an instance of this class when it encounters it in
39 //a parameter database file. The configuration of an instance of this type of
40 //state repository extension in a parameter database file (an .ope file) would
41 //look something like this:
42 //
43 //(state-repository-extension-type "my-state-repository-user-extension")
44 //(user-extension
45 // (my-tag "some-useful-info")
46 //)
47 //
48 //At runtime, you can access the state repository extension through the
49 //entity's state repository member, e.g.
50 //
51 //DtVrfObject* entity;
52 //DerivedSRUserExtension* userSRExtension =
53 //dynamic_cast<DerivedSRUserExtension*>(entity->vrfState()->userExtension());
54 
56 {
57 public:
58 
59  //constructor
61  const DtString& rwName = DtString::nullString(),
62  DtReaderWriterRegistry* parentRegistry = 0);
63 
64  //copy constructor
66  const DerivedSRUserExtension& orig,
67  const DtString& rwName = DtString::nullString(),
68  DtReaderWriterRegistry* parentRegistry = 0);
69 
70  //assignment
72  const DerivedSRUserExtension& orig);
73 
74  //destructor
75  virtual ~DerivedSRUserExtension();
76 
77  //Note you must implement the clone function in derived classes to ensure
78  //that this data is initialized from the parameter database correctly.
80  DtVrfObjectStateRepository* stateRepository,
81  const DtString& name,
82  DtReaderWriterRegistry* parentRegistry = NULL) const;
83 
84  //Type of extension object to create. Existing type(s) are defined in
85  //derivedSRUserExtTypes.h. Our new class returns the string
86  //"my-state-repository-user-extension". This is the string that must be
87  //registered with the factory that creates these objects, and specified in
88  //in the parameter database file when we want one of these classes instantiated.
89  virtual DtString type() const;
90 
91  //Called after object has been created by the DtVrfObjectStateRepository class.
92  virtual void init();
93 
94  //Specific user data extensions. In this case, its a readable writeable string
95  //with the DtReaderWriter name 'my-tag'.
96  virtual void setTag(const DtString& tag);
97  virtual const DtString& tag() const;
98 
99  //Returns newly created instance of this class.
101  DtVrfObjectStateRepository* stateRepository,
102  const DtString& rwName = DtString::nullString(),
103  DtReaderWriterRegistry* parentRegistry = 0);
104 
105 protected:
106 
108 };
109 
110 #endif

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)