hotspot/src/share/vm/runtime/commandLineFlagWriteableList.hpp
changeset 38273 2634194d7555
equal deleted inserted replaced
38267:29feb145a316 38273:2634194d7555
       
     1 /*
       
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 #ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP
       
    26 #define SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP
       
    27 
       
    28 #include "runtime/globals.hpp"
       
    29 #include "utilities/growableArray.hpp"
       
    30 
       
    31 class CommandLineFlagWriteable : public CHeapObj<mtArguments> {
       
    32 public:
       
    33   enum WriteableType {
       
    34     // can be set without any limits
       
    35     Always           = 0,
       
    36     // can only be set once, either via command lines or during runtime
       
    37     Once             = 1,
       
    38     // can only be set on command line (multiple times allowed)
       
    39     CommandLineOnly  = 2
       
    40   };
       
    41 private:
       
    42   const char* _name;
       
    43   WriteableType _type;
       
    44   bool _writeable;
       
    45   bool _startup_done;
       
    46 public:
       
    47   // the "name" argument must be a string literal
       
    48   CommandLineFlagWriteable(const char* name, WriteableType type) { _name=name; _type=type; _writeable=true; _startup_done=false; }
       
    49   ~CommandLineFlagWriteable() {}
       
    50   const char* name() { return _name; }
       
    51   const WriteableType type() { return _type; }
       
    52   bool is_writeable(void);
       
    53   void mark_once(void);
       
    54   void mark_startup(void);
       
    55 };
       
    56 
       
    57 class CommandLineFlagWriteableList : public AllStatic {
       
    58   static GrowableArray<CommandLineFlagWriteable*>* _controls;
       
    59 public:
       
    60   static void init();
       
    61   static int length() { return (_controls != NULL) ? _controls->length() : 0; }
       
    62   static CommandLineFlagWriteable* at(int i) { return (_controls != NULL) ? _controls->at(i) : NULL; }
       
    63   static CommandLineFlagWriteable* find(const char* name);
       
    64   static void add(CommandLineFlagWriteable* range) { _controls->append(range); }
       
    65   static void mark_startup(void);
       
    66 };
       
    67 
       
    68 #endif // SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP