< prev index next >

src/hotspot/share/services/diagnosticArgument.hpp

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


  45   }
  46 };
  47 
  48 class NanoTimeArgument {
  49 public:
  50   jlong _nanotime;
  51   jlong _time;
  52   char _unit[3];
  53 };
  54 
  55 class MemorySizeArgument {
  56 public:
  57   u8 _size;
  58   u8 _val;
  59   char _multiplier;
  60 };
  61 
  62 class GenDCmdArgument : public ResourceObj {
  63 protected:
  64   GenDCmdArgument* _next;
  65   const char*      _name;
  66   const char*      _description;
  67   const char*      _type;
  68   const char*      _default_string;
  69   bool             _is_set;
  70   bool             _is_mandatory;
  71   bool             _allow_multiple;
  72   GenDCmdArgument(const char* name, const char* description, const char* type,
  73                   const char* default_string, bool mandatory) {
  74     _name = name;
  75     _description = description;
  76     _type = type;
  77     _default_string = default_string;
  78     _is_mandatory = mandatory;
  79     _is_set = false;
  80     _allow_multiple = false;
  81   };
  82 public:
  83   const char* name() { return _name; }
  84   const char* description() { return _description; }
  85   const char* type() { return _type; }
  86   const char* default_string() { return _default_string; }
  87   bool is_set() { return _is_set; }
  88   void set_is_set(bool b) { _is_set = b; }
  89   bool allow_multiple() { return _allow_multiple; }
  90   bool is_mandatory() { return _is_mandatory; }
  91   bool has_value() { return _is_set || _default_string != NULL; }
  92   bool has_default() { return _default_string != NULL; }
  93   void read_value(const char* str, size_t len, TRAPS);
  94   virtual void parse_value(const char* str, size_t len, TRAPS) = 0;
  95   virtual void init_value(TRAPS) = 0;
  96   virtual void reset(TRAPS) = 0;
  97   virtual void cleanup() = 0;
  98   virtual void value_as_str(char* buf, size_t len) = 0;
  99   void set_next(GenDCmdArgument* arg) {
 100     _next = arg;
 101   }
 102   GenDCmdArgument* next() {
 103     return _next;
 104   }
 105 
 106   void to_string(jlong l, char* buf, size_t len);
 107   void to_string(bool b, char* buf, size_t len);
 108   void to_string(char* c, char* buf, size_t len);
 109   void to_string(NanoTimeArgument n, char* buf, size_t len);
 110   void to_string(MemorySizeArgument f, char* buf, size_t len);
 111   void to_string(StringArrayArgument* s, char* buf, size_t len);
 112 };
 113 
 114 template <class ArgType> class DCmdArgument: public GenDCmdArgument {
 115 private:
 116   ArgType _value;
 117 public:
 118   DCmdArgument(const char* name, const char* description, const char* type,
 119                bool mandatory) :
 120                GenDCmdArgument(name, description, type, NULL, mandatory) { }
 121   DCmdArgument(const char* name, const char* description, const char* type,
 122                bool mandatory, const char* defaultvalue) :
 123                GenDCmdArgument(name, description, type, defaultvalue, mandatory)
 124                { }
 125   ~DCmdArgument() { destroy_value(); }
 126   ArgType value() { return _value;}
 127   void set_value(ArgType v) { _value = v; }
 128   void reset(TRAPS) {
 129     destroy_value();
 130     init_value(CHECK);
 131     _is_set = false;
 132   }
 133   void cleanup() {
 134     destroy_value();
 135   }
 136   void parse_value(const char* str, size_t len, TRAPS);
 137   void init_value(TRAPS);
 138   void destroy_value();
 139   void value_as_str(char *buf, size_t len) { return to_string(_value, buf, len);}
 140 };
 141 
 142 #endif  /* SHARE_VM_SERVICES_DIAGNOSTICARGUMENT_HPP */


  45   }
  46 };
  47 
  48 class NanoTimeArgument {
  49 public:
  50   jlong _nanotime;
  51   jlong _time;
  52   char _unit[3];
  53 };
  54 
  55 class MemorySizeArgument {
  56 public:
  57   u8 _size;
  58   u8 _val;
  59   char _multiplier;
  60 };
  61 
  62 class GenDCmdArgument : public ResourceObj {
  63 protected:
  64   GenDCmdArgument* _next;
  65   const char* const _name;
  66   const char* const _description;
  67   const char* const _type;
  68   const char* const _default_string;
  69   bool              _is_set;
  70   const bool        _is_mandatory;
  71   bool             _allow_multiple;
  72   GenDCmdArgument(const char* name, const char* description, const char* type,
  73                   const char* default_string, bool mandatory)
  74     : _next(NULL)
  75     , _name(name), _description(description), _type(type)
  76     , _default_string(default_string), _is_mandatory(mandatory)
  77     , _is_set(false), _allow_multiple(false) {}
  78 



  79 public:
  80   const char* name() const { return _name; }
  81   const char* description() const { return _description; }
  82   const char* type() const { return _type; }
  83   const char* default_string() const { return _default_string; }
  84   bool is_set() const { return _is_set; }
  85   void set_is_set(bool b) { _is_set = b; }
  86   bool allow_multiple() const { return _allow_multiple; }
  87   bool is_mandatory() const { return _is_mandatory; }
  88   bool has_value() const { return _is_set || _default_string != NULL; }
  89   bool has_default() const { return _default_string != NULL; }
  90   void read_value(const char* str, size_t len, TRAPS);
  91   virtual void parse_value(const char* str, size_t len, TRAPS) = 0;
  92   virtual void init_value(TRAPS) = 0;
  93   virtual void reset(TRAPS) = 0;
  94   virtual void cleanup() = 0;
  95   virtual void value_as_str(char* buf, size_t len) const = 0;
  96   void set_next(GenDCmdArgument* arg) {
  97     _next = arg;
  98   }
  99   GenDCmdArgument* next() {
 100     return _next;
 101   }
 102 
 103   void to_string(jlong l, char* buf, size_t len) const;
 104   void to_string(bool b, char* buf, size_t len) const;
 105   void to_string(char* c, char* buf, size_t len) const;
 106   void to_string(NanoTimeArgument n, char* buf, size_t len) const;
 107   void to_string(MemorySizeArgument f, char* buf, size_t len) const;
 108   void to_string(StringArrayArgument* s, char* buf, size_t len) const;
 109 };
 110 
 111 template <class ArgType> class DCmdArgument: public GenDCmdArgument {
 112 private:
 113   ArgType _value;
 114 public:
 115   DCmdArgument(const char* name, const char* description, const char* type,
 116                bool mandatory) :
 117                GenDCmdArgument(name, description, type, NULL, mandatory) { }
 118   DCmdArgument(const char* name, const char* description, const char* type,
 119                bool mandatory, const char* defaultvalue) :
 120                GenDCmdArgument(name, description, type, defaultvalue, mandatory)
 121                { }
 122   ~DCmdArgument() { destroy_value(); }
 123   ArgType value() const { return _value;}
 124   void set_value(ArgType v) { _value = v; }
 125   void reset(TRAPS) {
 126     destroy_value();
 127     init_value(CHECK);
 128     _is_set = false;
 129   }
 130   void cleanup() {
 131     destroy_value();
 132   }
 133   void parse_value(const char* str, size_t len, TRAPS);
 134   void init_value(TRAPS);
 135   void destroy_value();
 136   void value_as_str(char *buf, size_t len) const { to_string(_value, buf, len);}
 137 };
 138 
 139 #endif  /* SHARE_VM_SERVICES_DIAGNOSTICARGUMENT_HPP */
< prev index next >