VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <readerWriter/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() override;
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  DtReaderWriterRegistry* parentRegistry = NULL) const override;
81 
82  //Type of extension object to create. Existing type(s) are defined in
83  //derivedSRUserExtTypes.h. Our new class returns the string
84  //"my-state-repository-user-extension". This is the string that must be
85  //registered with the factory that creates these objects, and specified in
86  //in the parameter database file when we want one of these classes instantiated.
87  virtual DtString type() const override;
88 
89  //Called after object has been created by the DtVrfObjectStateRepository class.
90  virtual void init() override;
91 
92  //Specific user data extensions. In this case, its a readable writeable string
93  //with the DtReaderWriter name 'my-tag'.
94  virtual void setTag(const DtString& tag);
95  virtual const DtString& tag() const;
96 
97  //Returns newly created instance of this class.
99  DtVrfObjectStateRepository* stateRepository,
100  const DtString& rwName = DtString::nullString(),
101  DtReaderWriterRegistry* parentRegistry = 0);
102 
103 protected:
104 
106 };
107 
108 #endif
DtRwString myTag
Definition: derivedSRUserExt.h:105
virtual void init() override
Called after object has been created by the DtVrfObjectStateRepository class.
static DtVrfStateRepositoryUserExtension * create(DtVrfObjectStateRepository *stateRepository, const DtString &rwName=DtString::nullString(), DtReaderWriterRegistry *parentRegistry=0)
virtual DtVrfObjectStateRepository * stateRepository() const
State repository this object belongs to.
Description: Readable, Writable DtString Variable substitutions are done on this object when it is re...
Definition: rwString.h:20
Definition: readerWriterRegistry.h:39
Description: This repository is an internal repository accessible only by local objects. It holds all information that is common to all the forms of all entity/aggregate/control objects within VR-Forces.
Definition: vrfObjectStateRepository.h:91
DerivedSRUserExtension(DtVrfObjectStateRepository *stateRepository, const DtString &rwName=DtString::nullString(), DtReaderWriterRegistry *parentRegistry=0)
Instances of DtVrfStateRepositoryUserExtension can be used by customers to extend the base DtVrfObjec...
Definition: vrfStateRepositoryUserExtension.h:20
virtual const DtString & tag() const
virtual void setTag(const DtString &tag)
Definition: derivedSRUserExt.h:55
virtual ~DerivedSRUserExtension() override
virtual DtString type() const override
Type of extension object to create. Returns DtDefaultSRUserExtensionType, defined in vrfSRUserExtType...
virtual DtVrfStateRepositoryUserExtension * clone(DtVrfObjectStateRepository *stateRepository, const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL) const override
Note you must implement the clone function in derived classes to ensure that this data is initialized...
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.
const DerivedSRUserExtension & operator=(const DerivedSRUserExtension &orig)

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)