<commit_before>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2015.  All rights reserved
 */
#ifndef _Stroika_Framework_SystemPerformance_Support_WMICollector_h_
#define _Stroika_Framework_SystemPerformance_Support_WMICollector_h_ 1

#include    "../../StroikaPreComp.h"

#include    <memory>
#if     qPlatform_Windows
#include    <Pdh.h>
#else
#error "WINDOWS REQUIRED FOR THIS MODULE"
#endif

#include    "../../../Foundation/Containers/Mapping.h"
#include    "../../../Foundation/Containers/Set.h"
#include    "../../../Foundation/Debug/AssertExternallySynchronizedLock.h"
#include    "../../../Foundation/Memory/Optional.h"
#include    "../../../Foundation/Time/Realtime.h"




/**
 *  \file
 *
 *  \version    <a href="code_status.html#Late-Alpha">Late-Alpha</a>
 *
 *  TODO:
 *
 *      @todo   Cleanup use of  AssertExternallySynchronizedLock once we have RECURSIVE
 *              flag.
 *
 *      @todo   Support remove of counters and instances.
 *
 *      @todo   See if its possible to support other 'value' return types. Sterl thinks
 *              and there is some evidence to suppor tthis - that there should be w way to get back
 *              strings (for stuff like disk name, or process name). And the API seems to ahve some
 *              support for this, but getformattedvalue doesnt seem to support it?
 *
 *      @todo   Support 'wildcards/array' somehow. Not sure what this means, but maybe just a more compact
 *              way to do some queries.
 *
 *      @todo   Consider if we should support multiple objects at a time.
 *
 *      @todo   Consider use of Atom manager for tokens - as would be more efficeint than strings.
 *              Would be a good place to expierment with private 'scoped' context for atom values.
 *
 *      @todo   Consider implementation based on COM calls, since Sterl believes those maybe
 *              more efficient
 *
 */



namespace   Stroika {
    namespace   Frameworks {
        namespace   SystemPerformance {
            namespace   Support {

                using   Foundation::Characters::String;
                using   Foundation::Containers::Mapping;
                using   Foundation::Containers::Set;
                using   Foundation::Memory::Optional;
                using   Foundation::Time::DurationSecondsType;
                using   Foundation::Traversal::Iterable;


                /**
                 * Known good WMI object names:
                 *      "Processor"
                 *      "PhysicalDisk"
                 *      "Memory"
                 *      "System"
                 *      "Network Interface"
                 *      "LogicalDisk"
                 *
                 *  Example:
                 *      WMICollector  tmp { L"Processor", {L"_Total"}, {L"% Processor Time"} };
                 *      double x = tmp.GetCurrentValue ( L"_Total", L"% Processor Time");
                 *
                 *  Example:
                 *      WMICollector  tmp { L"LogicalDisk", {L"E:"},  {L"% Free Space"} };
                 *      double x = tmp.GetCurrentValue (L"E:", L"% Free Space");
                 *
                 * Use the Windows Performance Monitor tool and click PerformanceMonitor and "Add Counters" to see more/list
                */
                class  WMICollector : private Foundation::Debug::AssertExternallySynchronizedLock {
                public:
                    /**
                     * Instance index is not numeric.. Often value is _Total.
                     *<commit_msg>comments<commit_after>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2015.  All rights reserved
 */
#ifndef _Stroika_Framework_SystemPerformance_Support_WMICollector_h_
#define _Stroika_Framework_SystemPerformance_Support_WMICollector_h_ 1

#include    "../../StroikaPreComp.h"

#include    <memory>
#if     qPlatform_Windows
#include    <Pdh.h>
#else
#error "WINDOWS REQUIRED FOR THIS MODULE"
#endif

#include    "../../../Foundation/Containers/Mapping.h"
#include    "../../../Foundation/Containers/Set.h"
#include    "../../../Foundation/Debug/AssertExternallySynchronizedLock.h"
#include    "../../../Foundation/Memory/Optional.h"
#include    "../../../Foundation/Time/Realtime.h"




/**
 *  \file
 *
 *  \version    <a href="code_status.html#Late-Alpha">Late-Alpha</a>
 *
 *  TODO:
 *
 *      @todo   Cleanup use of  AssertExternallySynchronizedLock once we have RECURSIVE
 *              flag.
 *
 *      @todo   Support remove of counters and instances.
 *
 *      @todo   See if its possible to support other 'value' return types. Sterl thinks
 *              and there is some evidence to suppor tthis - that there should be w way to get back
 *              strings (for stuff like disk name, or process name). And the API seems to ahve some
 *              support for this, but getformattedvalue doesnt seem to support it?
 *
 *      @todo   Support 'wildcards/array' somehow. Not sure what this means, but maybe just a more compact
 *              way to do some queries.
 *
 *      @todo   Consider if we should support multiple objects at a time.
 *
 *      @todo   Consider use of Atom manager for tokens - as would be more efficeint than strings.
 *              Would be a good place to expierment with private 'scoped' context for atom values.
 *
 *      @todo   Consider implementation based on COM calls, since Sterl believes those maybe
 *              more efficient
 *
 */



namespace   Stroika {
    namespace   Frameworks {
        namespace   SystemPerformance {
            namespace   Support {

                using   Foundation::Characters::String;
                using   Foundation::Containers::Mapping;
                using   Foundation::Containers::Set;
                using   Foundation::Memory::Optional;
                using   Foundation::Time::DurationSecondsType;
                using   Foundation::Traversal::Iterable;


                /**
                 * Known good WMI object names:
                 *      "Processor"
                 *      "PhysicalDisk"
                 *      "Memory"
                 *      "System"
                 *      "Network Interface"
                 *      "LogicalDisk"
                 *
                 *  Example:
                 *      WMICollector  tmp { L"Processor", {L"_Total"}, {L"% Processor Time"} };
                 *      double x = tmp.GetCurrentValue ( L"_Total", L"% Processor Time");
                 *
                 *  Example:
                 *      WMICollector  tmp { L"LogicalDisk", {L"E:"},  {L"% Free Space"} };
                 *      double x = tmp.GetCurrentValue (L"E:", L"% Free Space");
                 *
                 * Use the Windows 'Performance Monitor' tool and click PerformanceMonitor and "Add Counters" to see more/list
                */
                class  WMICollector : private Foundation::Debug::AssertExternallySynchronizedLock {
                public:
                    /**
                     * Instance index is not numeric.. Often value is _Total.
                     *
{'fraction_non_alphanumeric': 0.09604759881002975, 'fraction_numerical': 0.0025499362515937103, 'mean_word_length': 1.7524366471734893, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3635736', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1824, 'n_words': 566}