VR-Engage  2.2
Loading...
Searching...
No Matches
projectileList.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file projectileList.h
7//! \ingroup vreVrfobjcore
8//! \brief Projectile list class for VREngage
9//!
10//! This file defines the DtProjectileList class, which provides a readable/writable list
11//! of DtProjectile objects in VREngage simulations. DtProjectileList items include the type of
12//! DtProjectile class, so it can read/write DtProjectile objects of any type registered
13//! in the DtProjectileFactory.
14
15#pragma once
16
17#include <readerWriter/rwList.h>
18
19class DtProjectile;
20
22
23namespace makVre
24{
25//! \brief Type identifier string for the projectile list class
26const char DtProjectileListType[] = "DtProjectileList";
27
28class DtProjectile;
29
30//! \brief Class representing a list of projectiles
31//!
32//! This class provides a readable/writable list of DtProjectile objects.
33//! It handles reading and writing projectile objects of various types to/from
34//! files or streams, and provides methods for adding and managing projectiles
35//! in the list. The list is used to track and manage multiple projectiles in
36//! the simulation.
37class VREVRFOBJCORE_DLL DtProjectileList : public DtRwList
38{
39protected:
40 //! \brief Default constructor (protected)
41 //!
42 //! Default constructor is protected to prevent creation of unnamed instances.
43 //! Use the public constructor with a name instead.
45
46public:
47 //! \brief Constructor with name
48 //! \param name The name of this projectile list
49 //! \param parentRegistry Parent registry for reader/writer functionality (optional)
50 //!
51 //! Creates a new projectile list with the specified name.
52 DtProjectileList(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
53
54 //! \brief Copy constructor
55 //! \param orig The source projectile list to copy from
56 //! \param parentRegistry Parent registry for reader/writer functionality (optional)
57 //!
58 //! Creates a new projectile list as a copy of the provided original.
59 DtProjectileList(const DtProjectileList& orig, DtReaderWriterRegistry* parentRegistry = 0);
60
61 //! \brief Assignment operator
62 //! \param orig The source projectile list to copy from
63 //! \return Reference to this projectile list after assignment
64 //!
65 //! Assigns the contents of the provided list to this one.
66 //! Removes and deletes all entries on the left hand side, then
67 //! clones all entries on the right side list and adds them to
68 //! the left side list.
70
71 //! \brief Virtual destructor
72 //!
73 //! Cleans up resources used by the projectile list, including all
74 //! contained projectile objects.
75 virtual ~DtProjectileList() override;
76
77 //! \brief Creates a clone of this projectile list
78 //! \param parentRegistry Parent registry for reader/writer functionality (optional)
79 //! \return Pointer to a new projectile list that is a clone of this one
80 //!
81 //! Creates a new projectile list as a deep copy of this one, including
82 //! all contained projectile objects.
83 virtual DtProjectileList* clone(DtReaderWriterRegistry* parentRegistry = 0);
84
85 //! \brief Removes and destroys all projectiles from the list
86 //!
87 //! Clears the list by removing and destroying all contained projectile objects.
88 virtual void emptyList();
89
90 //! \brief Copies all projectiles from another list
91 //! \param orig The source projectile list to copy from
92 //!
93 //! Copies all projectiles from the provided list to this one.
94 //! Any existing projectiles in this list are preserved.
95 virtual void copyList(const DtProjectileList& orig);
96
97 //! \brief Adds a projectile to the list by copying
98 //! \param projectile The projectile to add
99 //! \return Pointer to the newly added projectile
100 //!
101 //! Makes a clone of the provided projectile and adds it to the list.
102 //! The returned pointer is owned by this list and should not be deleted
103 //! by the caller.
104 virtual DtProjectile* addProjectile(const DtProjectile& projectile);
105
106 //! \brief Gets the reader/writer type identifier
107 //! \return String identifying this list type
108 //!
109 //! Returns a unique type identifier string for this list type.
110 //! Will return DtProjectileListType.
111 virtual const char* readerWriterType() const override;
112
113 //! \brief Equality operator
114 //! \param other The projectile list to compare with (unnamed parameter)
115 //! \return True if the projectile lists are equal, false otherwise
116 //!
117 //! Compares this projectile list with another to determine if they are equal.
118 //! Lists are equal if they contain the same number of items and each item
119 //! is equal to the corresponding item in the other list.
120 bool operator==(const DtProjectileList&) const;
121
122protected:
123 //! \brief Adds a pre-created projectile to the list
124 //! \param projectile Pointer to the projectile to add
125 //!
126 //! Adds the provided projectile to the list. The projectile will be owned
127 //! by this list and destroyed when the list is emptied or destroyed.
128 //! This protected method is used internally when loading projectiles from
129 //! a file or stream.
130 virtual void addProjectile(DtProjectile* projectile);
131
132 //! \brief Handles reading projectiles from an MTL stream
133 //! \param args Input stream from an MTL file
134 //! \param searchPaths Search paths for resolving references
135 //! \param variableBindings Variable bindings for resolving references
136 //! \return Processed MTL stream after reading
137 //!
138 //! Overrides the base class getData method to handle reading projectiles from
139 //! an MTL stream. Constructs a projectile object, retrieves it from the MTL stream,
140 //! and then adds it to the list.
141 virtual DtlObjPtr getData(DtlObjPtr args,
142 const DtReaderWriter::SearchPaths& searchPaths,
143 const DtVariableBindingsList& variableBindings) override;
144};
145} // namespace makVre
Class representing ballistic projectiles in simulations.
Definition projectile.h:42
virtual ~DtProjectileList() override
Virtual destructor.
virtual void emptyList()
Removes and destroys all projectiles from the list.
DtProjectileList(const DtProjectileList &orig, DtReaderWriterRegistry *parentRegistry=0)
Copy constructor.
virtual void copyList(const DtProjectileList &orig)
Copies all projectiles from another list.
bool operator==(const DtProjectileList &) const
Equality operator.
virtual void addProjectile(DtProjectile *projectile)
Adds a pre-created projectile to the list.
DtProjectileList & operator=(const DtProjectileList &orig)
Assignment operator.
DtProjectileList()
Default constructor (protected)
virtual DtProjectileList * clone(DtReaderWriterRegistry *parentRegistry=0)
Creates a clone of this projectile list.
virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings) override
Handles reading projectiles from an MTL stream.
virtual const char * readerWriterType() const override
Gets the reader/writer type identifier.
virtual DtProjectile * addProjectile(const DtProjectile &projectile)
Adds a projectile to the list by copying.
DtProjectileList(const DtString &name, DtReaderWriterRegistry *parentRegistry=0)
Constructor with name.
Export macros for the VREngage Object Core library.
#define VREVRFOBJCORE_DLL
Platform-specific DLL export/import declaration.
Definition export.h:27
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const char DtProjectileListType[]
Type identifier string for the projectile list class.
Definition projectileList.h:26