< prev index next >

src/hotspot/share/services/diagnosticArgument.hpp

Print this page
rev 50556 : [mq]: jcmd-cleanups

@@ -60,57 +60,58 @@
 };
 
 class GenDCmdArgument : public ResourceObj {
 protected:
   GenDCmdArgument* _next;
-  const char*      _name;
-  const char*      _description;
-  const char*      _type;
-  const char*      _default_string;
+  const char* const _name;
+  const char* const _description;
+  const char* const _type;
+  const char* const _default_string;
   bool             _is_set;
-  bool             _is_mandatory;
+  const bool        _is_mandatory;
   bool             _allow_multiple;
   GenDCmdArgument(const char* name, const char* description, const char* type,
-                  const char* default_string, bool mandatory) {
-    _name = name;
-    _description = description;
-    _type = type;
-    _default_string = default_string;
-    _is_mandatory = mandatory;
-    _is_set = false;
-    _allow_multiple = false;
-  };
+                  const char* default_string, bool mandatory)
+    : _next(NULL)
+    , _name(name)
+    , _description(description)
+    , _type(type)
+    , _default_string(default_string)
+    , _is_set(false)
+    , _is_mandatory(mandatory)
+    ,  _allow_multiple(false) {}
+
 public:
-  const char* name() { return _name; }
-  const char* description() { return _description; }
-  const char* type() { return _type; }
-  const char* default_string() { return _default_string; }
-  bool is_set() { return _is_set; }
+  const char* name() const        { return _name; }
+  const char* description() const { return _description; }
+  const char* type() const        { return _type; }
+  const char* default_string() const { return _default_string; }
+  bool is_set() const             { return _is_set; }
   void set_is_set(bool b) { _is_set = b; }
-  bool allow_multiple() { return _allow_multiple; }
-  bool is_mandatory() { return _is_mandatory; }
-  bool has_value() { return _is_set || _default_string != NULL; }
-  bool has_default() { return _default_string != NULL; }
+  bool allow_multiple() const     { return _allow_multiple; }
+  bool is_mandatory() const       { return _is_mandatory; }
+  bool has_value() const          { return _is_set || _default_string != NULL; }
+  bool has_default() const        { return _default_string != NULL; }
   void read_value(const char* str, size_t len, TRAPS);
   virtual void parse_value(const char* str, size_t len, TRAPS) = 0;
   virtual void init_value(TRAPS) = 0;
   virtual void reset(TRAPS) = 0;
   virtual void cleanup() = 0;
-  virtual void value_as_str(char* buf, size_t len) = 0;
+  virtual void value_as_str(char* buf, size_t len) const = 0;
   void set_next(GenDCmdArgument* arg) {
     _next = arg;
   }
   GenDCmdArgument* next() {
     return _next;
   }
 
-  void to_string(jlong l, char* buf, size_t len);
-  void to_string(bool b, char* buf, size_t len);
-  void to_string(char* c, char* buf, size_t len);
-  void to_string(NanoTimeArgument n, char* buf, size_t len);
-  void to_string(MemorySizeArgument f, char* buf, size_t len);
-  void to_string(StringArrayArgument* s, char* buf, size_t len);
+  void to_string(jlong l, char* buf, size_t len) const;
+  void to_string(bool b, char* buf, size_t len) const;
+  void to_string(char* c, char* buf, size_t len) const;
+  void to_string(NanoTimeArgument n, char* buf, size_t len) const;
+  void to_string(MemorySizeArgument f, char* buf, size_t len) const;
+  void to_string(StringArrayArgument* s, char* buf, size_t len) const;
 };
 
 template <class ArgType> class DCmdArgument: public GenDCmdArgument {
 private:
   ArgType _value;

@@ -121,11 +122,11 @@
   DCmdArgument(const char* name, const char* description, const char* type,
                bool mandatory, const char* defaultvalue) :
                GenDCmdArgument(name, description, type, defaultvalue, mandatory)
                { }
   ~DCmdArgument() { destroy_value(); }
-  ArgType value() { return _value;}
+  ArgType value() const { return _value;}
   void set_value(ArgType v) { _value = v; }
   void reset(TRAPS) {
     destroy_value();
     init_value(CHECK);
     _is_set = false;

@@ -134,9 +135,9 @@
     destroy_value();
   }
   void parse_value(const char* str, size_t len, TRAPS);
   void init_value(TRAPS);
   void destroy_value();
-  void value_as_str(char *buf, size_t len) { return to_string(_value, buf, len);}
+  void value_as_str(char *buf, size_t len) const { to_string(_value, buf, len);}
 };
 
 #endif  /* SHARE_VM_SERVICES_DIAGNOSTICARGUMENT_HPP */
< prev index next >