Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Tools/Xabsl2/GT/GTXabsl2Profiler/GTXabsl2ProfilerNameTable.h

Go to the documentation of this file.

    00001 /**
    00002 * @file GTXabsl2ProfilerNameTable.h
    00003 *
    00004 * Definition and Implementation of classes GTXabsl2Profiler, GTXabsl2ProfilerNameTable
    00005 *
    00006 * @author Michael Spranger
    00007 */
    00008 #ifndef __GTXabsl2ProfilerNameTable_h_
    00009 #define __GTXabsl2ProfilerNameTable_h_
    00010
    00011 #ifdef _WIN32
    00012 #pragma warning(disable:4786)
    00013 // the constructor with all it's long parameter type names results in a too
    00014 // long debug identifier
    00015 #endif
    00016
    00017 #include <string>
    00018 #include <vector>
    00019 #include <deque>
    00020
    00021 #include "Platform/GTAssert.h"
    00022
    00023 #include "Tools/Streams/OutStreams.h"
    00024 #include "Platform/SystemCall.h"
    00025
    00026 #include "Tools/Xabsl2/Xabsl2Engine/Xabsl2Array.h"
    00027 #include "Tools/Xabsl2/Xabsl2Engine/Xabsl2Engine.h"
    00028 #include "Tools/Debugging/Debugging.h"
    00029
    00030 #include "Tools/Streams/InStreams.h"
    00031 #include "Tools/Module/SolutionRequest.h"
    00032
    00033 /*
    00034 * @class GTXabsl2ProfilerNameTableEntry
    00035 * Class that encapsulates string representations for options, state in options and optionparameters
    00036 * @author Michael Spranger
    00037 */
    00038 class GTXabsl2ProfilerNameTableEntry{
    00039   public:
    00040     /** The name of the Option represented by this entry */
    00041     std::string optionName;
    00042     /**The vector of state names */
    00043     std::vector<std::string> states;
    00044     /** A vector of parameter names */
    00045     std::vector<std::string> parameters;
    00046     /** The maximal depth of this option in the option-tree (XABSL)*/
    00047     int maxDepth;
    00048
    00049     /**
    00050     * Constructor
    00051     * Initializes the strings as zero length strings.
    00052     */
    00053     GTXabsl2ProfilerNameTableEntry(){};
    00054
    00055
    00056     /**
    00057     * Constructor
    00058     * @param option The option name
    00059     * @param state The names of all state within the corresponding option
    00060     * @param params The names of all parameters for this Option
    00061     * @param depth The maximal depth of this option in the option tree.
    00062     */
    00063     GTXabsl2ProfilerNameTableEntry(const std::string option,std::vector<std::string> state, std::vector<std::string> params, const int depth)
    00064       : optionName(option), states(state), parameters(params), maxDepth(depth){}
    00065
    00066 };
    00067
    00068 /*
    00069 * @class GTXabsl2ProfilerNameTable
    00070 * Dynamic Array for keeping a correlation of Xabsl2Options and States to Numbers for profiling purposes (remembering activation paths).
    00071 * @author Michael Spranger
    00072 */
    00073 class GTXabsl2ProfilerNameTable: public std::vector<GTXabsl2ProfilerNameTableEntry>
    00074 {
    00075   /** The number of elements in the array */
    00076   public:
    00077      int maxDepth;
    00078
    00079     /** Constructor
    00080     * Initializes all members with 0.
    00081     */
    00082     GTXabsl2ProfilerNameTable(): maxDepth(0)
    00083     {}
    00084
    00085     /**
    00086     * Initializes the Array
    00087     */
    00088     void init(Xabsl2Engine& pEngine);
    00089
    00090     /**
    00091     * Returns the Position for a given optionname
    00092     * Note that the function crashes if the element does not exist.
    00093     */
    00094     int getOptionPosition(const std::string optionName) const
    00095     {
    00096       return findOption(optionName);
    00097     }
    00098
    00099     /**
    00100     * Returns the Position for a given state within the option
    00101     * Note that the function crashes if the element does not exist.
    00102     * @param optionName Name of the option the state is in
    00103     * @param state Name of the state the position is returned for
    00104     * @return The Position of the state within NameTableEntry
    00105     */
    00106     int getStatePosition(const std::string optionName, const std::string state){
    00107       return findState(optionName, state);
    00108     }
    00109
    00110     /** Returns whether an element for the given name exists
    00111     * @param optionName Name of the option searched for
    00112     * @param stateName Name of the state that in conjunction with optionName makes the request unique
    00113     */
    00114     bool exists(const std::string optionName, const std::string stateName) const
    00115     {
    00116       return find(optionName, stateName) >= 0;
    00117     }
    00118
    00119     /** Returns whether an element for the given namey exists
    00120     * @param option Name of the option searched for
    00121     */
    00122     bool existsOption(const std::string option){
    00123       return findOption(option) >=0;
    00124     }
    00125
    00126
    00127    protected:
    00128    /**
    00129    * Returns the index of an element with the given names.
    00130    * @return The index of the element of -1 if the name does not exist.
    00131    */
    00132      int find(const std::string optionName, const std::string state) const;
    00133
    00134      /**
    00135      * Returns the index of an element with the given names.
    00136      * @return The index of the element of -1 if the name does not exist.
    00137      */
    00138      int findState(const std::string optionName, const std::string state) const;
    00139
    00140      /**
    00141      * Returns the index of an element with the given names.
    00142      * @return The index of the element of -1 if the name does not exist.
    00143      */
    00144      int findOption(const std::string optionName) const;
    00145
    00146     /*
    00147      * Registers Option, calls itself recursively for subsequent options, registering all subsequent options as well
    00148      * @param  option Option to be registered
    00149      * @param depth depth of the option to be registered
    00150      */
    00151     void registerOption(const Xabsl2Option* option, int depth);
    00152
    00153     /*
    00154      *  Does a depth count for the option, where depth is initial depth
    00155      */
    00156     void countDepth(const Xabsl2Option* option, int depth);
    00157
    00158 };
    00159 /**
    00160 * Streaming operator that reads KickCase from a stream.
    00161 * @param in The stream from which is read.
    00162 * @param nameTable The name table object.
    00163 * @return The stream.
    00164 */
    00165 In& operator>>(In& in, GTXabsl2ProfilerNameTable& nameTable);
    00166
    00167 /**
    00168 * Streaming operator that writes KickCase to a stream.
    00169 * @param out The stream to write on.
    00170 * @param nameTable The name table object.
    00171 * @return The stream.
    00172 */
    00173 Out& operator<<(Out& out, const GTXabsl2ProfilerNameTable& nameTable);
    00174
    00175
    00176 #endif// __GTXabsl2Profiler_h_