VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vrfNameGenerator.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
12 #include "vrfobjcore/simObject.h"
13 #include <tbb/recursive_mutex.h>
14 #include <tbb/atomic.h>
15 #include <vlutil/vlString.h>
16 
17 class DtObjectType;
18 
21 {
22 public:
25 
27  virtual ~DtVrfNameGenerator();
28 
29  virtual bool init(DtSimulationServices*);
30 
31  virtual void clear();
32 
34  virtual DtString nextName(const DtObjectType&);
35  virtual DtString nextNameWithPrefix(const DtObjectType & objectType,
36  const DtString& potentialPrefix);
37 
41  virtual unsigned int maxNameLengthForType(const DtObjectType& objectType) const;
42 
47  virtual DtString generateUniqueName(int maxLength, const DtString&
48  root = "Object");
49 
52  virtual DtString nextNameWithPrefix(int maxLength,
53  const DtString& potentialPrefix);
54 
55  virtual DtString nextUnorganizedName();
56 
59  virtual bool parseName(const DtString& name, DtString& shortName, int& number) const;
60 
61 protected:
62  virtual void processSimObjectDeleted(DtSimObjectReference);
63  virtual void processSimObjectAdded(DtSimObjectReference);
64  virtual void processSimObjectRenamed(const DtSimObject*, const DtString& oldText, const DtString& newText);
65 
67  virtual DtString createPullFrom(const DtString& current, int low, int high) const;
68 
70  virtual void giveBack(const DtString& shortName, int number);
71 
73  virtual void take(const DtString& shortName, int number, bool affectDuplicateCount = false);
74 
76  virtual int getNextNumber(const DtString&);
77 
78  typedef std::pair<int, int> Range;
79  typedef std::vector<Range> Ranges;
80 
82  virtual void takeFromRange(Ranges&, int number) const;
83 
84 protected:
86  tbb::recursive_mutex myMutex;
87  tbb::atomic<int> myNextUnorganizedName;
88 
90  {
91  NameGenerationInfo() : nextNumber(1) {};
92  NameGenerationInfo(const NameGenerationInfo& orig) : nextNumber(orig.nextNumber), pullFromRanges(orig.pullFromRanges), countsOfNumbers(orig.countsOfNumbers) {};
93 
94  int nextNumber;
95  std::map<int, int> countsOfNumbers;
97  };
98 
99  typedef std::map<DtString, NameGenerationInfo> NameGenerationMap;
101 
102  boost::signals2::scoped_connection mySimObjectAddedConnection;
103  boost::signals2::scoped_connection mySimObjectDeletedConnection;
104  boost::signals2::scoped_connection mySimObjectRenamedConnection;
105 };
boost::signals2::scoped_connection mySimObjectRenamedConnection
Definition: vrfNameGenerator.h:104
Definition: vrfNameGenerator.h:89
Ranges pullFromRanges
Definition: vrfNameGenerator.h:96
tbb::atomic< int > myNextUnorganizedName
Definition: vrfNameGenerator.h:87
The DtSimObjectReference is a shared pointer that can be used amongst many object for access to the u...
Definition: simObjectReference.h:26
std::map< DtString, NameGenerationInfo > NameGenerationMap
Definition: vrfNameGenerator.h:99
NameGenerationMap myNameGenerationMap
Definition: vrfNameGenerator.h:100
#define DT_DLL_vrfobjcore
This file is used to determine how to build.
Definition: vrfobjcoreDefines.h:24
DtSimulationServices * mySimulationServices
Definition: vrfNameGenerator.h:85
boost::signals2::scoped_connection mySimObjectDeletedConnection
Definition: vrfNameGenerator.h:103
std::pair< int, int > Range
Definition: vrfNameGenerator.h:78
boost::signals2::scoped_connection mySimObjectAddedConnection
Definition: vrfNameGenerator.h:102
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:95
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: simObject.h:88
std::map< int, int > countsOfNumbers
Definition: vrfNameGenerator.h:95
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
NameGenerationInfo()
Definition: vrfNameGenerator.h:91
std::vector< Range > Ranges
Definition: vrfNameGenerator.h:79
The DtVrfNameGenerator class will generate a unique name by object type.
Definition: vrfNameGenerator.h:20
tbb::recursive_mutex myMutex
Definition: vrfNameGenerator.h:86

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)