Panda3D
Loading...
Searching...
No Matches
factoryParams.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file factoryParams.h
10 * @author drose
11 * @date 2000-05-08
12 */
13
14#ifndef FACTORYPARAMS_H
15#define FACTORYPARAMS_H
16
17#include "pandabase.h"
18
19#include "typedObject.h"
20#include "typedReferenceCount.h"
21#include "pointerTo.h"
22#include "factoryParam.h"
23#include "dcast.h"
24
25#include "pvector.h"
26
27/**
28 * An instance of this class is passed to the Factory when requesting it to do
29 * its business and construct a new something. It can be filled with optional
30 * parameters to the CreateFunc for the particular subclass the Factory will
31 * be creating.
32 *
33 * This is just a vector of pointers to *something*; it will be up to the
34 * individual CreateFuncs to interpret this meaningfully.
35 */
36class EXPCL_PANDA_PUTIL FactoryParams {
37public:
38 FactoryParams() = default;
39 FactoryParams(const FactoryParams &copy) = default;
40 FactoryParams(FactoryParams &&from) noexcept = default;
41 ~FactoryParams() = default;
42
43 FactoryParams &operator = (FactoryParams &&from) noexcept = default;
44
45 void add_param(FactoryParam *param);
46 void clear();
47
48 int get_num_params() const;
49 FactoryParam *get_param(int n) const;
50
52
53 INLINE void *get_user_data() const;
54
55private:
56 typedef pvector< PT(TypedReferenceCount) > Params;
57
58 Params _params;
59 void *_user_data = nullptr;
60
61 friend class FactoryBase;
62};
63
64template<class ParamType>
65INLINE bool get_param_into(ParamType *&pointer, const FactoryParams &params);
66
67#include "factoryParams.I"
68
69#endif
The base class of any number of specific pieces of parameter information that might be passed to a Fa...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
int get_num_params() const
Returns the number of parameters that have been added to the set.
FactoryParam * get_param(int n) const
Returns the nth parameter that has been added to the set.
void clear()
Removes all parameters from the set.
void * get_user_data() const
Returns the custom pointer that was associated with the factory function.
FactoryParam * get_param_of_type(TypeHandle type) const
Returns the first parameter that matches exactly the indicated type, or if there are no exact matches...
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool get_param_into(ParamType *&pointer, const FactoryParams &params)
A handy convenience template function that extracts a parameter of the indicated type from the Factor...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.