VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
connectionSettings.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2013 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <makSettingsManager/settingsObject.h>
13 
14 #include <connectionFileRecord.h>
15 
16 #include <boost/archive/xml_iarchive.hpp>
17 #include <boost/archive/xml_oarchive.hpp>
18 #include <boost/serialization/nvp.hpp>
19 #include <boost/unordered_map.hpp>
20 
21 #include <QtCore/QStringList>
22 
23 #include <vlutil/vlString.h>
24 #include <vlutil/vlPrint.h>
25 #include <vlutil/vlRtiCompilerCheck.h>
26 
27 #include <string>
28 #include <vector>
29 #include <map>
30 
31 
32 // Stores two strings - first is the command-line flag, second is a descriptive (?) string
33 typedef std::pair<const char*,const char*> ArgFlagDescriptorPair;
34 typedef boost::unordered_map<unsigned int,ArgFlagDescriptorPair> ArgIndexDescriptionMap;
35 typedef ArgIndexDescriptionMap::iterator ArgIndexDescriptionEntry;
36 
37 //Mapping between argument int and command-line value DtString
38 typedef std::map< unsigned int, QString > ConnectionArgValues;
39 typedef ConnectionArgValues::iterator ConnectionArgValuesEntry;
40 
41 typedef std::map<std::string,std::string> DriverRecordArgValues;
42 typedef DriverRecordArgValues::iterator DriverRecordArgValuesEntry;
43 
46 {
51 };
52 
56 {
57 public:
58 
59  // Default constructor, required for deserialization
61 
62  // Constructor
63  DtConnectionSettings( std::string name );
64 
65  // Constructor
66  DtConnectionSettings( std::string name, DtProtocolTypes protocol );
67 
68  // Copy constructor
70 
71  virtual ~DtConnectionSettings();
72 
73  // Equality operator
74  virtual bool operator == ( const DtConnectionSettings & orig ) const;
75 
76  // Inequality operator
77  virtual bool operator != ( const DtConnectionSettings& orig ) const;
78 
79  // Reset this object based on another, used by DtSettingsManager::setSetting
80  virtual bool setFrom( const DtConnectionSettings* other );
81  virtual bool setFrom( const DtConnectionFileRecord& rec );
82 
83  // Returns true if the connection will be valid
84  virtual bool connectionWillBeValid() const;
85 
86 #ifdef _WIN32
87  // Call to VR-Link routine to check to make sure RTI version is compatible. If not give an error and return false
88  virtual bool checkRtiVersion(DtHLALib, bool showError = true) const;
89 #endif
90 
91  virtual bool setToFileRecord( DtConnectionFileRecord * rec );
92 
93  virtual void setName( std::string name );
94  virtual std::string name();
95 
96  // What protocol is this connection
97  virtual DtProtocolTypes protocolType() const;
98  virtual void setProtocolType( DtProtocolTypes type );
99 
100  //Is this settings object the connect we should automatically connect with
101  virtual bool autoConnection() const ;
102  virtual void setAutoConnection( bool conn );
103 
104  // accessor to myArgsMap
105  virtual ConnectionArgValues* argValues();
106 
107  //overload this class so as to take whatever data type comes out of the dialog
108  virtual void updateStringArgValue( unsigned int type, QString qstringValue );
109  virtual void updateBoolArgValue( unsigned int type, bool boolValue );
110  virtual void updateIntArgValue( unsigned int type, int intValue );
111 
112  //returns "false" if the entry does not exist
113  virtual bool getArgValue( unsigned int argType, QString & argValue ) const;
114 
116  virtual void removeArgValueEntry( unsigned int type );
117  virtual bool findArgDescriptor( unsigned int type, ArgFlagDescriptorPair& mappingStorage );
118 
119  virtual QStringList frontEndFlags();
120  virtual QStringList backEndFlags();
121 
122  static DtConnectionSettings* createFromDriverRecord( DtConnectionFileRecord & driverRecord, QString connName = "");
123  static DtConnectionSettings* createFromProtocol( DtProtocolTypes protocol, QString connName = "" );
124 
125 protected:
126 
127  // Stores the available command line args for this connection. Override to add new args
128  virtual void initialize();
129 
130 private:
131 
133 
134  // Serialization support. Derived classes must call
135  // BOOST_SERIALIZATION_BASE_OBJECT_NVP(DtSettingsObject) in their
136  // implementation of serialize.
137  template<class Archive>
138  void serialize(Archive & ar, const unsigned int version)
139  {
140  // Serialize the base class
141  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(DtSettingsObject);
142 
143  // Serialize our values
144  ar & BOOST_SERIALIZATION_NVP(myAmAutoConnection);
145  ar & BOOST_SERIALIZATION_NVP(myProtocolType);
146  //ar & BOOST_SERIALIZATION_NVP(myArgsListSetting);
147  }
148 
149 protected:
150 
151 
153 
156  std::string mySettingsType;
157 
158  // Holds all the cmd args that have been set for this connection
160 
161 };
162 
163 // Setup this class as abstract in boost
164 BOOST_SERIALIZATION_ASSUME_ABSTRACT( DtConnectionSettings )

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)