File: ObjectInfo.h

package info (click to toggle)
metview 5.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 44,932 kB
  • sloc: cpp: 211,811; ansic: 33,467; xml: 3,942; sh: 2,942; yacc: 1,183; fortran: 762; lex: 761; perl: 700; python: 340; f90: 236; makefile: 92
file content (169 lines) | stat: -rw-r--r-- 4,476 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/***************************** LICENSE START ***********************************

 Copyright 2012 ECMWF and INPE. This software is distributed under the terms
 of the Apache License version 2.0. In applying this license, ECMWF does not
 waive the privileges and immunities granted to it by virtue of its status as
 an Intergovernmental Organization or submit itself to any jurisdiction.

 ***************************** LICENSE END *************************************/

//
// .NAME:	
//  ObjectInfo
//
// .AUTHOR:
//  Gilberto Camara, Baudoin Raoult and Fernando Ii
//
// .SUMMARY:
//  A class for handling description of PlotMod objects
//
//
// .CLIENTS:
//  Presentable 
//
//
// .RESPONSABILITIES:
//  - Convert a request from the METVIEW request to the
//    macro syntax
//  - Write the contents of a PLOT_SUPERPAGE into a 
//    macro file
//
// .COLLABORATORS:
//  MvRequest 
// 
// .BASE CLASS:
//  (none)
//
// .DERIVED CLASSES:
//  (none)	
//
// .REFERENCES:
//
//
#ifndef ObjectInfo_H
#define ObjectInfo_H

#include "inc_stl.h"
using std::string;

#include <Cached.h>
#include <Types.hpp>

class MvIcon;
class MvRequest;

typedef  list<Cached> CachedList;
typedef  map<Cached,int >  NamesMap;

class ObjectInfo {

public:

	// Constructors
	ObjectInfo():
    		hasAction_ ( false ),
    		isPrint_ ( false ) { namesMap_.erase(namesMap_.begin(), namesMap_.end() ); } 

	// Class Methods
	void IsPrint ( bool yesno )
		{ isPrint_ = yesno; }

	void SetPlotAction ()
		{ hasAction_ = true; }

	bool HasAction()
		{ return hasAction_; } 

	void LinePrefix(const string& xx ) { linePrefix_ = xx; }

	// Puts a new line in the description
	void PutNewLine ( const	 Cached& newLine );

	// Format a line and a Value
	void FormatLine(const Cached &, const Cached&, const Cached &, int width = 25 );
	Cached FormatValue(const char *, const char *, const Cached &);

	// Calculate maximum size of the parameters name
	int MaximumParameterNameLength( MvRequest& );

	// Writes a description into a file
	void WriteDescription ( FILE* filePtr );

	// Convert a request to the macro syntax
	void ConvertRequestToMacro( MvRequest& inRequest,
			      	    MacroConversion lastComma,
			      	    Cached varName, Cached macroName,
			      	    set<Cached> skip = set<Cached>(),
			      	    bool onlySub = false);

	 // Converts a data unit to macro syntax
	Cached ConvertDataUnitToMacro ( MvIcon& dataUnit );

	// Converts a visdef to macro syntax
	Cached ConvertIconToMacro ( MvRequest& req, Cached defVal, int id = 1 );

	// Utility function, will call the correct converter
	Cached Convert(MvRequest &);

	// Static Methods
	// Find the object path associated to a request
	// which describes the object
   static Cached ObjectPath ( const MvRequest& );
   static string ObjectFullPath ( const MvRequest& );

	// Find the object name associated to a request
	// which describes the object
   static Cached ObjectName ( const MvRequest&, const char* = "",
                              int id = 0, bool updateId = false,
                              bool basename = true );

	// Generate a number to tell variable names apart
	static int GenerateId(const char *name );

	// indicates if the value has characters
	static bool IsAName ( const char* value );

	// indicates if the request has been called from a macro
	static bool CalledFromMacro ( const MvRequest& request );

	static Cached IconClass ( const MvRequest&);

	// Obtain the name of the object, without the extension
	static Cached StripExtension ( const char* value );

	// Converts a name with spaces to a name with underscores
	static Cached SpaceToUnderscore ( const char* nameWithSpaces );

	// Obtain the default Visdef name
	static Cached DefaultVisDefName ( int treeNode );

	// Check if visdefs are from the same Class
	// EXCEPTION:  PCONT(NORMAL) and PCONT(ISOTACHS) are assumed to
	// belong from different Classes
	// Return : 
	//          TRUE  : same class
	//          FALSE : different class
	static bool CheckVisDefClass (const MvRequest&, const MvRequest&);

	static Cached GenerateName(MvRequest req);

   // Find full file name, including the path
   static string FileName(const MvRequest&);

	// Destructor
	virtual ~ObjectInfo() {}

private:

	CachedList description_;
	static NamesMap namesMap_;
	bool       hasAction_;
	bool       isPrint_;
	string linePrefix_;

	// No copy allowed
	ObjectInfo(const ObjectInfo&);
	ObjectInfo& operator=(const ObjectInfo&){return *this;}
};

#endif