VR-Forces 4.5 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 
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 
54 {
57 };
58 
62 {
63 public:
64 
65  // Default constructor, required for deserialization
67 
68  // Constructor
69  DtConnectionSettings( std::string name );
70 
71  // Constructor
72  DtConnectionSettings( std::string name, DtProtocolTypes protocol );
73 
74  // Copy constructor
76 
77  virtual ~DtConnectionSettings();
78 
79  // Equality operator
80  virtual bool operator == ( const DtConnectionSettings & orig ) const;
81 
82  // Inequality operator
83  virtual bool operator != ( const DtConnectionSettings& orig ) const;
84 
85  // Reset this object based on another, used by DtSettingsManager::setSetting
86  virtual bool setFrom( const DtConnectionSettings* other );
87  virtual bool setFrom( const DtConnectionFileRecord& rec );
88 
89  // Returns true if the connection will be valid
90  virtual bool connectionWillBeValid() const;
91 
92 #ifdef _WIN32
93  // Call to VR-Link routine to check to make sure RTI version is compatible. If not give an error and return false
94  virtual bool checkRtiVersion(DtHLALib, bool showError = true) const;
95 #endif
96 
97  virtual bool setToFileRecord( DtConnectionFileRecord * rec );
98 
99  virtual void setName( std::string name );
100  virtual std::string name();
101 
102  // What protocol is this connection
103  virtual DtProtocolTypes protocolType() const;
104  virtual void setProtocolType( DtProtocolTypes type );
105 
106  //Is this settings object the connect we should automatically connect with
107  virtual bool autoConnection() const ;
108  virtual void setAutoConnection( bool conn );
109 
110  // accessor to myArgsMap
111  virtual ConnectionArgValues* argValues();
112 
113  //overload this class so as to take whatever data type comes out of the dialog
114  virtual void updateStringArgValue( unsigned int type, QString qstringValue );
115  virtual void updateBoolArgValue( unsigned int type, bool boolValue );
116  virtual void updateIntArgValue( unsigned int type, int intValue );
117 
118  //returns "false" if the entry does not exist
119  virtual bool getArgValue( unsigned int argType, QString & argValue ) const;
120 
122  virtual void removeArgValueEntry( unsigned int type );
123  virtual bool findArgDescriptor( unsigned int type, ArgFlagDescriptorPair& mappingStorage );
124 
125  virtual QStringList frontEndFlags();
126  virtual QStringList backEndFlags();
127 
128  static DtConnectionSettings* createFromDriverRecord( DtConnectionFileRecord & driverRecord, QString connName = "");
129  static DtConnectionSettings* createFromProtocol( DtProtocolTypes protocol, QString connName = "" );
130 
131 protected:
132 
133  // Stores the available command line args for this connection. Override to add new args
134  virtual void initialize();
135 
136 private:
137 
139 
140  // Serialization support. Derived classes must call
141  // BOOST_SERIALIZATION_BASE_OBJECT_NVP(DtSettingsObject) in their
142  // implementation of serialize.
143  template<class Archive>
144  void serialize(Archive & ar, const unsigned int version)
145  {
146  // Serialize the base class
147  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(DtSettingsObject);
148 
149  // Serialize our values
150  ar & BOOST_SERIALIZATION_NVP(myAmAutoConnection);
151  ar & BOOST_SERIALIZATION_NVP(myProtocolType);
152  //ar & BOOST_SERIALIZATION_NVP(myArgsListSetting);
153  }
154 
155 protected:
156 
157 
159 
162  std::string mySettingsType;
163 
164  // Holds all the cmd args that have been set for this connection
166 
167 };
168 
169 // Setup this class as abstract in boost
170 BOOST_SERIALIZATION_ASSUME_ABSTRACT( DtConnectionSettings )

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)