<commit_before>#include <string>
#include <vector>
#include <iostream>
#include <ostream>
#include <typeinfo>
#include <exception>
#include <fstream>

#include <tinfra/Symbol.h>
using namespace std;

#include <tinfra/tinfra.h>
#include <tinfra/tinfra_lex.h>
#include <tinfra/xml.h>
#include <tinfra/xml/XMLStream.h>

using tinfra::Symbol;
using tinfra::ManagedType;

//
// classes
//

///
// Address
///

enum yesno {
    no, yes
};

namespace tinfra {
template<>
struct LexicalInterpreter<yesno> {
    static void to_string(const yesno& v, std::ostream& dest) {
        dest << ( (v == no) ? "no" : "yes");
    }
    static void to_string(const yesno& v, std::string& dest) {
        dest = ( (v == no) ? "no" : "yes");
    }
    static void from_string(const char* v, yesno& dest) {
        dest = (v[0] == 'y') ? yes : no;
    }
};
}
namespace S {
    // symbols
    extern Symbol active;
    extern Symbol closed;
    extern Symbol created;
    extern Symbol deadline;
    extern Symbol description;
    extern Symbol end;
    extern Symbol fileversion;
    extern Symbol fullname;
    extern Symbol group;
    extern Symbol hide;
    extern Symbol id;
    extern Symbol master_task;
    extern Symbol master_tasks;
    extern Symbol measure_id;
    extern Symbol members;
    extern Symbol members_data;
    extern Symbol name;
    extern Symbol persistent;
    extern Symbol process_measures;
    extern Symbol progress;
    extern Symbol project;
    extern Symbol project_phases;
    extern Symbol projects;
    extern Symbol projectphase_id;
    extern Symbol shortname;
    extern Symbol start;
    extern Symbol started;
    extern Symbol state;
    extern Symbol time_load;
    extern Symbol tasks;
    extern Symbol version;
}

// Member definition
struct Member {
    yesno   active;
    string  fullname;
    Symbol  id;
    string  shortname;

    template <typename F>
    void apply(F& f) const
    {
        f(S::active,    active);
        f(S::fullname,   fullname);
        f(S::id,  id);
        f(S::shortname,   shortname);
    }
};

// Group definition

struct Group {
    string fullname;
    vector<Member> members;

    template <typename F>
    void apply(F& f) const
    {
        f(S::fullname,  fullname);
        f(S::members,   members);
    }
};

struct Project {
    yesno    active;
    string   fullname;
    Symbol   id;

    template <typename F>
    void apply(F& f) const
    {
        f(S::active,  active);
        f(S::fullname,   fullname);
        f(S::id,  id);
    }
};

struct ProcessMeasure {
    Symbol   id;
    string   name;

    template <typename F>
    void apply(F& f) const
    {
        f(S::id,  id);
        f(S::name,  name);
    }
};

struct ProjectPhase {
    Symbol   id;
    string   name;

    template <typename F>
    void apply(F& f) const
    {
        f(S::id,  id);
        f(S::name,  name);
    }
};

struct MasterTask {
    Symbol id;
    Symbol project;
    string state;
    yesno  active;
    yesno  persistent;
    string description;

    template <typename F>
    void apply(F& f) const
    {
        f(S::id,  id);
        f(S::project,  project);
        f(S::state,  state);
        f(S::active,  active);
        f(S::persistent,  persistent);
        f(S::description, description);
    }
};

struct timestamp {
    long timestamp;
};

struct TimeLoadEntry {
    timestamp start;
    timestamp end;

    template <typename F>
    void apply(F& f) const
    {
        f(S::start,  start);
        f(S::end,    end);
    }
};

enum taskstate {
    prepared, active, closed
};

struct Task {
    string      name;
    Symbol      project;
    Symbol      master_task;
    timestamp   created;
    timestamp   started;
    int    progress;
    taskstate   state;
    timestamp   closed;
    timestamp   deadline;
    yesno       hide;
    Symbol      measure_id;
    Symbol      projectphase_id;
    string      description;
    vector<TimeLoadEntry> time_load;

    template <typename F>
    void apply(F& f) const
    {
        f(S::name,  name);
        f(S::project,  project);
        f(S::master_task,  master_task);
        f(S::created,  created);
        f(S::started,  started);
        f(S::progress,  progress);
        f(S::state,  state);
        f(S::closed,  closed);
        f(S::deadline, deadline);
        f(S::hide, hide);
        f(S::measure_id, measure_id);
        f(S::projectphase_id, projectphase_id);
        f(S::description, description);
        f(S::time_load, time_load);
    }
};

struct MemberData {
    yesno    active;
    Symbol   id;
    vector<Task>        tasks;

    template <typename F>
    void apply(F& f) const
    {
        f(S::active,  active);
        f(S::id,  id);
        f(S::tasks,  tasks);
    }
};
struct FileVersion {
    int version;

    template <typename F>
    void apply(F& f) const
    {
        f(S::version, version);
    }
};

struct TaskMonitor {
    FileVersion     fileversion;

    Group           group;

    vector<Project> projects;
    vector<ProcessMeasure> process_measures;

    vector<ProjectPhase>   project_phases;

    vector<MasterTask>     master_tasks;
    vector<MemberData>     members_data;

    template <typename F>
    void apply(F& f) const
    {
        f(S::group, group);
        f(S::fileversion,  fileversion);
        f(S::projects,  projects);
        f(S::process_measures,  process_measures);
        f(S::project_phases,  project_phases);
        f(S::master_tasks,  master_tasks);
        f(S::members_data,  members_data);
    }
};

namespace tinfra {
	template<> struct TypeTraits<TaskMonitor>: public ManagedStruct<TaskMonitor> {};
	template<> struct TypeTraits<Group>: public ManagedStruct<Group> {};
        template<> struct TypeTraits<Member>: public ManagedStruct<Member> {};
        template<> struct TypeTraits<MemberData>: public ManagedStruct<MemberData> {};
        template<> struct TypeTraits<Project>: public ManagedStruct<Project> {};
        template<> struct TypeTraits<ProjectPhase>: public ManagedStruct<ProjectPhase> {};
        template<> struct TypeTraits<ProcessMeasure>: public ManagedStruct<ProcessMeasure> {};
        template<> struct TypeTraits<MasterTask>: public ManagedStruct<MasterTask> {};
        template<> struct TypeTraits<FileVersion>: public ManagedStruct<FileVersion> {};
        template<> struct TypeTraits<Task>: public ManagedStruct<Task> {};
        template<> struct TypeTraits<TimeLoadEntry>: public ManagedStruct<TimeLoadEntry> {};
        template<> struct TypeTraits<timestamp>: public Fundamental<timestamp> {};
        template<> struct TypeTraits<taskstate>: public Fundamental<taskstate> {};

	template<typename T> struct TypeTraits<vector<T> >: public STLContainer<vector<T> > {};
}

ostream& operator << (ostream& o, const Symbol& s)  { return o << s.getName().c_str(); }
ostream& operator << (ostream& o, const timestamp& s)  { return o << s.timestamp; }
ostream& operator << (ostream& o, const taskstate& s)  {
    return o << ( s == prepared ? "prepared" :
                  s == active   ? "active":
                  s == closed   ? "closed" : "<error>");
}
namespace S {
    // symbols
    Symbol active = "active";
    Symbol closed = "closed";;
    Symbol created = "created";;
    Symbol deadline = "deadline";;
    Symbol description = "description";;
    Symbol end = "end";;
    Symbol fileversion = "fileversion";
    Symbol fullname = "fullname";;
    Symbol group = "group";
    Symbol hide = "hide";
    Symbol id = "id";
    Symbol master_task = "master_task";
    Symbol master_tasks = "master_tasks";
    Symbol measure_id = "measure_id";
    Symbol members = "members";
    Symbol members_data = "members_data";
    Symbol name = "name";
    Symbol persistent = "persistent";
    Symbol process_measures = "process_measures";
    Symbol progress = "progress";
    Symbol project = "project";
    Symbol project_phases = "project_phases";
    Symbol projects = "projects";
    Symbol projectphase_id = "projectphase_id";
    Symbol shortname = "shortname";
    Symbol start = "start";
    Symbol started = "started";
    Symbol state = "state";
    Symbol time_load = "time_load";
    Symbol tasks = "tasks";
    Symbol version = "version";
}

void initialize_xml_mapping(tinfra::xml::XMLSymbolMapping& xml_mapping)
{
    xml_mapping.map_class_by_traits<TaskMonitor>(Symbol("taskmonitor"));
    xml_mapping.map_class_by_traits<ProcessMeasure>(Symbol("process-measure"));
    xml_mapping.map_class_by_traits<ProjectPhase>(Symbol("project-phase"));
    xml_mapping.map_class_by_traits<Task>(Symbol("task"));
    xml_mapping.map_class_by_traits<MasterTask>(Symbol("master-task"));
    xml_mapping.map_class_by_traits<TimeLoadEntry>(Symbol("time-load-entry"));
    xml_mapping.map_class_by_traits<MemberData>(Symbol("member-data"));
    xml_mapping.map_class_by_traits<Project>(Symbol("project"));
    xml_mapping.map_class_by_traits<Member>(Symbol("member"));

    xml_mapping.map_field(S::process_measures,Symbol("process-measures"));
    xml_mapping.map_field(S::project_phases,Symbol("project-phases"));
    xml_mapping.map_field(S::master_tasks,Symbol("master-tasks"));
    xml_mapping.map_field(S::master_task,Symbol("master-task"));
    xml_mapping.map_field(S::projectphase_id,Symbol("projectphase-id"));
    xml_mapping.map_field(S::measure_id,Symbol("measure-id"));
    xml_mapping.map_field(S::members_data,Symbol("members-data"));
    xml_mapping.map_field(S::time_load,Symbol("time-load"));
}

void test1()
{
    TaskMonitor tm;
    tm.fileversion.version = 9;
    tm.group.fullname = "Group1";

    tinfra::xml::XMLSymbolMapping xml_symbol_mapping;
    initialize_xml_mapping(xml_symbol_mapping);

    tm.process_measures.push_back(tinfra::construct<ProcessMeasure>()
                                                           (S::id, Symbol("req-1"))
                                                           (S::name, string("XXX")));
    tm.project_phases.push_back(tinfra::construct<ProjectPhase>()
                                                           (S::id, Symbol("m1"))
                                                           (S::name, string("Test")));
    tinfra::xml::FileXMLOutputStream xml_out(* cout.rdbuf());
    tinfra::xml::dump(xml_out, Symbol("taskmonitor"), tm, xml_symbol_mapping);
}

void test2()
{
    TaskMonitor tm;

    tinfra::xml::XMLSymbolMapping xml_symbol_mapping;
    initialize_xml_mapping(xml_symbol_mapping);
    {

        tinfra::xml::XMLEventBuffer b;
        tinfra::xml::XMLBufferOutputStream b1(b);
        tinfra::xml::read_xml("taskmonitor2.xml",b1);
        tinfra::xml::XMLBufferInputStream b2(b);
        tinfra::xml::load<TaskMonitor>(b2, Symbol("taskmonitor"), tm, xml_symbol_mapping);
        cout << "readed!" << endl;
    }
    {
        tinfra::xml::FileXMLOutputStream xml_out(* cout.rdbuf());
        xml_out.start_document();
        xml_out.set_human_readable(true);
        tinfra::xml::dump(xml_out, Symbol("taskmonitor"), tm, xml_symbol_mapping);
        cout << "written!" << endl;
    }
    cout << "bye!" << endl;
}

int main2()
{
    //test1();
    test2();
    return 0;
}

int main()
{
    try {
        main2();
    } catch( std::exception& e) {
        cerr << "fatal error: " << e.what() << endl;
    }
}
<commit_msg>* follow Symbol refactor<commit_after>#include <string>
#include <vector>
#include <iostream>
#include <ostream>
#include <typeinfo>
#include <exception>
#include <fstream>

#include <tinfra/symbol.h>
using namespace std;

#include <tinfra/tinfra.h>
#include <tinfra/tinfra_lex.h>
#include <tinfra/xml.h>
#include <tinfra/xml/XMLStream.h>

using tinfra::symbol;
using tinfra::ManagedType;

//
// classes
//

///
// Address
///

enum yesno {
    no, yes
};

namespace tinfra {
template<>
struct LexicalInterpreter<yesno> {
    static void to_string(const yesno& v, std::ostream& dest) {
        dest << ( (v == no) ? "no" : "yes");
    }
    static void to_string(const yesno& v, std::string& dest) {
        dest = ( (v == no) ? "no" : "yes");
    }
    static void from_string(const char* v, yesno& dest) {
        dest = (v[0] == 'y') ? yes : no;
    }
};
}
namespace S {
    // symbols
    extern symbol active;
    extern symbol closed;
    extern symbol created;
    extern symbol deadline;
    extern symbol description;
    extern symbol end;
    extern symbol fileversion;
    extern symbol fullname;
    extern symbol group;
    extern symbol hide;
    extern symbol id;
    extern symbol master_task;
    extern symbol master_tasks;
    extern symbol measure_id;
    extern symbol members;
    extern symbol members_data;
    extern symbol name;
    extern symbol persistent;
    extern symbol process_measures;
    extern symbol progress;
    extern symbol project;
    extern symbol project_phases;
    extern symbol projects;
    extern symbol projectphase_id;
    extern symbol shortname;
    extern symbol start;
    extern symbol started;
    extern symbol state;
    extern symbol time_load;
    extern symbol tasks;
    extern symbol version;
}

// Member definition
struct Member {
    yesno   active;
    string  fullname;
    symbol  id;
    string  shortname;

    template <typename F>
    void apply(F& f) const
    {
        f(S::active,    active);
        f(S::fullname,   fullname);
        f(S::id,  id);
        f(S::shortname,   shortname);
    }
};

// Group definition

struct Group {
    string fullname;
    vector<Member> members;

    template <typename F>
    void apply(F& f) const
    {
        f(S::fullname,  fullname);
        f(S::members,   members);
    }
};

struct Project {
    yesno    active;
    string   fullname;
    symbol   id;

    template <typename F>
    void apply(F& f) const
    {
        f(S::active,  active);
        f(S::fullname,   fullname);
        f(S::id,  id);
    }
};

struct ProcessMeasure {
    symbol   id;
    string   name;

    template <typename F>
    void apply(F& f) const
    {
        f(S::id,  id);
        f(S::name,  name);
    }
};

struct ProjectPhase {
    symbol   id;
    string   name;

    template <typename F>
    void apply(F& f) const
    {
        f(S::id,  id);
        f(S::name,  name);
    }
};

struct MasterTask {
    symbol id;
    symbol project;
    string state;
    yesno  active;
    yesno  persistent;
    string description;

    template <typename F>
    void apply(F& f) const
    {
        f(S::id,  id);
        f(S::project,  project);
        f(S::state,  state);
        f(S::active,  active);
        f(S::persistent,  persistent);
        f(S::description, description);
    }
};

struct timestamp {
    long stamp;
};

struct TimeLoadEntry {
    timestamp start;
    timestamp end;

    template <typename F>
    void apply(F& f) const
    {
        f(S::start,  start);
        f(S::end,    end);
    }
};

enum taskstate {
    prepared, active, closed
};

struct Task {
    string      name;
    symbol      project;
    symbol      master_task;
    timestamp   created;
    timestamp   started;
    int    progress;
    taskstate   state;
    timestamp   closed;
    timestamp   deadline;
    yesno       hide;
    symbol      measure_id;
    symbol      projectphase_id;
    string      description;
    vector<TimeLoadEntry> time_load;

    template <typename F>
    void apply(F& f) const
    {
        f(S::name,  name);
        f(S::project,  project);
        f(S::master_task,  master_task);
        f(S::created,  created);
        f(S::started,  started);
        f(S::progress,  progress);
        f(S::state,  state);
        f(S::closed,  closed);
        f(S::deadline, deadline);
        f(S::hide, hide);
        f(S::measure_id, measure_id);
        f(S::projectphase_id, projectphase_id);
        f(S::description, description);
        f(S::time_load, time_load);
    }
};

struct MemberData {
    yesno    active;
    symbol   id;
    vector<Task>        tasks;

    template <typename F>
    void apply(F& f) const
    {
        f(S::active,  active);
        f(S::id,  id);
        f(S::tasks,  tasks);
    }
};
struct FileVersion {
    int version;

    template <typename F>
    void apply(F& f) const
    {
        f(S::version, version);
    }
};

struct TaskMonitor {
    FileVersion     fileversion;

    Group           group;

    vector<Project> projects;
    vector<ProcessMeasure> process_measures;

    vector<ProjectPhase>   project_phases;

    vector<MasterTask>     master_tasks;
    vector<MemberData>     members_data;

    template <typename F>
    void apply(F& f) const
    {
        f(S::group, group);
        f(S::fileversion,  fileversion);
        f(S::projects,  projects);
        f(S::process_measures,  process_measures);
        f(S::project_phases,  project_phases);
        f(S::master_tasks,  master_tasks);
        f(S::members_data,  members_data);
    }
};

namespace tinfra {
	template<> struct TypeTraits<TaskMonitor>: public ManagedStruct<TaskMonitor> {};
	template<> struct TypeTraits<Group>: public ManagedStruct<Group> {};
        template<> struct TypeTraits<Member>: public ManagedStruct<Member> {};
        template<> struct TypeTraits<MemberData>: public ManagedStruct<MemberData> {};
        template<> struct TypeTraits<Project>: public ManagedStruct<Project> {};
        template<> struct TypeTraits<ProjectPhase>: public ManagedStruct<ProjectPhase> {};
        template<> struct TypeTraits<ProcessMeasure>: public ManagedStruct<ProcessMeasure> {};
        template<> struct TypeTraits<MasterTask>: public ManagedStruct<MasterTask> {};
        template<> struct TypeTraits<FileVersion>: public ManagedStruct<FileVersion> {};
        template<> struct TypeTraits<Task>: public ManagedStruct<Task> {};
        template<> struct TypeTraits<TimeLoadEntry>: public ManagedStruct<TimeLoadEntry> {};
        template<> struct TypeTraits<timestamp>: public Fundamental<timestamp> {};
        template<> struct TypeTraits<taskstate>: public Fundamental<taskstate> {};

	template<typename T> struct TypeTraits<vector<T> >: public STLContainer<vector<T> > {};
}

ostream& operator << (ostream& o, const timestamp& s)  { return o << s.stamp; }
ostream& operator << (ostream& o, const taskstate& s)  {
    return o << ( s == prepared ? "prepared" :
                  s == active   ? "active":
                  s == closed   ? "closed" : "<error>");
}
namespace S {
    // symbols
    symbol active = "active";
    symbol closed = "closed";;
    symbol created = "created";;
    symbol deadline = "deadline";;
    symbol description = "description";;
    symbol end = "end";;
    symbol fileversion = "fileversion";
    symbol fullname = "fullname";;
    symbol group = "group";
    symbol hide = "hide";
    symbol id = "id";
    symbol master_task = "master_task";
    symbol master_tasks = "master_tasks";
    symbol measure_id = "measure_id";
    symbol members = "members";
    symbol members_data = "members_data";
    symbol name = "name";
    symbol persistent = "persistent";
    symbol process_measures = "process_measures";
    symbol progress = "progress";
    symbol project = "project";
    symbol project_phases = "project_phases";
    symbol projects = "projects";
    symbol projectphase_id = "projectphase_id";
    symbol shortname = "shortname";
    symbol start = "start";
    symbol started = "started";
    symbol state = "state";
    symbol time_load = "time_load";
    symbol tasks = "tasks";
    symbol version = "version";
}

void initialize_xml_mapping(tinfra::xml::XMLSymbolMapping& xml_mapping)
{
    xml_mapping.map_class_by_traits<TaskMonitor>(symbol("taskmonitor"));
    xml_mapping.map_class_by_traits<ProcessMeasure>(symbol("process-measure"));
    xml_mapping.map_class_by_traits<ProjectPhase>(symbol("project-phase"));
    xml_mapping.map_class_by_traits<Task>(symbol("task"));
    xml_mapping.map_class_by_traits<MasterTask>(symbol("master-task"));
    xml_mapping.map_class_by_traits<TimeLoadEntry>(symbol("time-load-entry"));
    xml_mapping.map_class_by_traits<MemberData>(symbol("member-data"));
    xml_mapping.map_class_by_traits<Project>(symbol("project"));
    xml_mapping.map_class_by_traits<Member>(symbol("member"));

    xml_mapping.map_field(S::process_measures,symbol("process-measures"));
    xml_mapping.map_field(S::project_phases,symbol("project-phases"));
    xml_mapping.map_field(S::master_tasks,symbol("master-tasks"));
    xml_mapping.map_field(S::master_task,symbol("master-task"));
    xml_mapping.map_field(S::projectphase_id,symbol("projectphase-id"));
    xml_mapping.map_field(S::measure_id,symbol("measure-id"));
    xml_mapping.map_field(S::members_data,symbol("members-data"));
    xml_mapping.map_field(S::time_load,symbol("time-load"));
}

void test1()
{
    TaskMonitor tm;
    tm.fileversion.version = 9;
    tm.group.fullname = "Group1";

    tinfra::xml::XMLSymbolMapping xml_symbol_mapping;
    initialize_xml_mapping(xml_symbol_mapping);

    tm.process_measures.push_back(tinfra::construct<ProcessMeasure>()
                                                           (S::id, symbol("req-1"))
                                                           (S::name, string("XXX")));
    tm.project_phases.push_back(tinfra::construct<ProjectPhase>()
                                                           (S::id, symbol("m1"))
                                                           (S::name, string("Test")));
    tinfra::xml::FileXMLOutputStream xml_out(* cout.rdbuf());
    tinfra::xml::dump(xml_out, symbol("taskmonitor"), tm, xml_symbol_mapping);
}

void test2()
{
    TaskMonitor tm;

    tinfra::xml::XMLSymbolMapping xml_symbol_mapping;
    initialize_xml_mapping(xml_symbol_mapping);
    {

        tinfra::xml::XMLEventBuffer b;
        tinfra::xml::XMLBufferOutputStream b1(b);
        tinfra::xml::read_xml("taskmonitor2.xml",b1);
        tinfra::xml::XMLBufferInputStream b2(b);
        tinfra::xml::load<TaskMonitor>(b2, symbol("taskmonitor"), tm, xml_symbol_mapping);
        cout << "readed!" << endl;
    }
    {
        tinfra::xml::FileXMLOutputStream xml_out(* cout.rdbuf());
        xml_out.start_document();
        xml_out.set_human_readable(true);
        tinfra::xml::dump(xml_out, symbol("taskmonitor"), tm, xml_symbol_mapping);
        cout << "written!" << endl;
    }
    cout << "bye!" << endl;
}

int main2()
{
    //test1();
    test2();
    return 0;
}

int main()
{
    try {
        main2();
    } catch( std::exception& e) {
        cerr << "fatal error: " << e.what() << endl;
    }
}
<|endoftext|>


<commit_before><commit_msg>DevTools: Only enable dev tools for dev tools if process-per-tab flag is set. At the same time, allow it in release mode as well. BUG=27252<commit_after><|endoftext|>


<commit_before><commit_msg>Add in UMA logging for context menu playback controls.<commit_after><|endoftext|>


<commit_before>//! [simple state machine]
QPushButton button;

QStateMachine machine;
QState *s1 = new QState();
s1->assignProperty(&button, "text", "Click me");

QFinalState *s2 = new QFinalState();
s1->addTransition(&button, SIGNAL(clicked()), s2);

machine.addState(s1);
machine.addState(s2);
machine.setInitialState(s1);
machine.start();
//! [simple state machine]
<commit_msg>Add license header.<commit_after>/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

//! [simple state machine]
QPushButton button;

QStateMachine machine;
QState *s1 = new QState();
s1->assignProperty(&button, "text", "Click me");

QFinalState *s2 = new QFinalState();
s1->addTransition(&button, SIGNAL(clicked()), s2);

machine.addState(s1);
machine.addState(s2);
machine.setInitialState(s1);
machine.start();
//! [simple state machine]
<|endoftext|>


<commit_before>// bdlma_concurrentmultipoolallocator.cpp                             -*-C++-*-

// ----------------------------------------------------------------------------
//                                   NOTICE
//
// This component is not up to date with current BDE coding standards, and
// should not be used as an example for new development.
// ----------------------------------------------------------------------------

#include <bdlma_concurrentmultipoolallocator.h>

#include <bsls_ident.h>
BSLS_IDENT_RCSID(bdlma_concurrentmultipoolallocator_cpp,"$Id$ $CSID$")

#include <bsls_performancehint.h>

namespace BloombergLP {
namespace bdlma {

                    // ----------------------------------
                    // class ConcurrentMultipoolAllocator
                    // ----------------------------------

// CREATORS
ConcurrentMultipoolAllocator::~ConcurrentMultipoolAllocator()
{
}

// MANIPULATORS
void *ConcurrentMultipoolAllocator::allocate(bsls::Types::size_type size)
{
    if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(0 == size)) {
        BSLS_PERFORMANCEHINT_UNLIKELY_HINT;
        return 0;                                                     // RETURN
    }

    return d_multipool.allocate(size);
}

void ConcurrentMultipoolAllocator::deallocate(void *address)
{
    if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(address != 0)) {
        d_multipool.deallocate(address);
    }
    BSLS_PERFORMANCEHINT_UNLIKELY_HINT;
}

void ConcurrentMultipoolAllocator::release()
{
    d_multipool.release();
}

}  // close package namespace

}  // close enterprise namespace

// ----------------------------------------------------------------------------
// Copyright 2016 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------- END-OF-FILE ----------------------------------
<commit_msg>Re-apply fix to bdlma_concurrentmultipoolallocator<commit_after>// bdlma_concurrentmultipoolallocator.cpp                             -*-C++-*-

// ----------------------------------------------------------------------------
//                                   NOTICE
//
// This component is not up to date with current BDE coding standards, and
// should not be used as an example for new development.
// ----------------------------------------------------------------------------

#include <bdlma_concurrentmultipoolallocator.h>

#include <bsls_ident.h>
BSLS_IDENT_RCSID(bdlma_concurrentmultipoolallocator_cpp,"$Id$ $CSID$")

#include <bsls_performancehint.h>

namespace BloombergLP {
namespace bdlma {

                    // ----------------------------------
                    // class ConcurrentMultipoolAllocator
                    // ----------------------------------

// CREATORS
ConcurrentMultipoolAllocator::~ConcurrentMultipoolAllocator()
{
}

// MANIPULATORS
void *ConcurrentMultipoolAllocator::allocate(bsls::Types::size_type size)
{
    if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(0 == size)) {
        BSLS_PERFORMANCEHINT_UNLIKELY_HINT;
        return 0;                                                     // RETURN
    }

    return d_multipool.allocate(size);
}

void ConcurrentMultipoolAllocator::deallocate(void *address)
{
    if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(address != 0)) {
        d_multipool.deallocate(address);
    }
    else {
        BSLS_PERFORMANCEHINT_UNLIKELY_HINT;
    }
}

void ConcurrentMultipoolAllocator::release()
{
    d_multipool.release();
}

}  // close package namespace

}  // close enterprise namespace

// ----------------------------------------------------------------------------
// Copyright 2016 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------- END-OF-FILE ----------------------------------
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: newppdlg.cxx,v $
 *
 *  $Revision: 1.9 $
 *
 *  last change: $Author: rt $ $Date: 2004-01-07 15:43:14 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#include <stdio.h>
#include <unistd.h>

#ifndef _PSPRINT_PPDPARSER_HXX_
#include <psprint/ppdparser.hxx>
#endif
#ifndef _PSPRINT_HELPER_HXX_
#include <psprint/helper.hxx>
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#ifndef _SV_MNEMONIC_HXX
#include <vcl/mnemonic.hxx>
#endif
#ifndef _URLOBJ_HXX
#include <tools/urlobj.hxx>
#endif
#ifndef __SGI_STL_LIST
#include <list>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif

#ifndef _PAD_HELPER_HXX_
#include <helper.hxx>
#endif
#ifndef _PAD_PADIALOG_HRC_
#include <padialog.hrc>
#endif
#ifndef _PAD_NEWPPDLG_HXX_
#include <newppdlg.hxx>
#endif
#ifndef _PAD_PADIALOG_HXX_
#include <padialog.hxx>
#endif
#ifndef _PAD_PROGRESS_HXX_
#include <progress.hxx>
#endif

#define PPDIMPORT_GROUP "PPDImport"

using namespace padmin;
using namespace psp;
using namespace osl;
using namespace rtl;

PPDImportDialog::PPDImportDialog( Window* pParent ) :
        ModalDialog( pParent, PaResId( RID_PPDIMPORT_DLG ) ),
        m_aOKBtn( this, PaResId( RID_PPDIMP_BTN_OK ) ),
        m_aCancelBtn( this, PaResId( RID_PPDIMP_BTN_CANCEL ) ),
        m_aSearchBtn( this, PaResId( RID_PPDIMP_BTN_SEARCH ) ),
        m_aPathBox( this, PaResId( RID_PPDIMP_LB_PATH ) ),
        m_aDriverTxt( this, PaResId( RID_PPDIMP_TXT_DRIVER ) ),
        m_aDriverLB( this, PaResId( RID_PPDIMP_LB_DRIVER ) ),
        m_aPathGroup( this, PaResId( RID_PPDIMP_GROUP_PATH ) ),
        m_aDriverGroup( this, PaResId( RID_PPDIMP_GROUP_DRIVER ) ),
        m_aPathTxt( this, PaResId( RID_PPDIMP_TXT_PATH ) ),
        m_aLoadingPPD( PaResId( RID_PPDIMP_STR_LOADINGPPD ) )
{
    FreeResource();

    String aText( m_aDriverTxt.GetText() );
    aText.SearchAndReplaceAscii( "%s", Button::GetStandardText( BUTTON_OK ) );
    m_aDriverTxt.SetText( MnemonicGenerator::EraseAllMnemonicChars( aText ) );

    Config& rConfig = getPadminRC();
    rConfig.SetGroup( PPDIMPORT_GROUP );
    m_aPathBox.SetText( String( rConfig.ReadKey( "LastDir" ), RTL_TEXTENCODING_UTF8 ) );
    for( int i = 0; i < 11; i++ )
    {
        ByteString aEntry( rConfig.ReadKey( ByteString::CreateFromInt32( i ) ) );
        if( aEntry.Len() )
            m_aPathBox.InsertEntry( String( aEntry, RTL_TEXTENCODING_UTF8 ) );
    }

    m_aOKBtn.SetClickHdl( LINK( this, PPDImportDialog, ClickBtnHdl ) );
    m_aCancelBtn.SetClickHdl( LINK( this, PPDImportDialog, ClickBtnHdl ) );
    m_aSearchBtn.SetClickHdl( LINK( this, PPDImportDialog, ClickBtnHdl ) );
    m_aPathBox.SetSelectHdl( LINK( this, PPDImportDialog, SelectHdl ) );
    m_aPathBox.SetModifyHdl( LINK( this, PPDImportDialog, ModifyHdl ) );

    if( m_aPathBox.GetText().Len() )
        Import();
}

PPDImportDialog::~PPDImportDialog()
{
    while( m_aDriverLB.GetEntryCount() )
    {
        delete (String*)m_aDriverLB.GetEntryData( 0 );
        m_aDriverLB.RemoveEntry( 0 );
    }
}

void PPDImportDialog::Import()
{
    String aImportPath( m_aPathBox.GetText() );

    Config& rConfig = getPadminRC();
    rConfig.SetGroup( PPDIMPORT_GROUP );
    rConfig.WriteKey( "LastDir", ByteString( aImportPath, RTL_TEXTENCODING_UTF8 ) );

    int nEntries = m_aPathBox.GetEntryCount();
    while( nEntries-- )
        if( aImportPath == m_aPathBox.GetEntry( nEntries ) )
            break;
    if( nEntries < 0 )
    {
        int nNextEntry = rConfig.ReadKey( "NextEntry" ).ToInt32();
        rConfig.WriteKey( ByteString::CreateFromInt32( nNextEntry ), ByteString( aImportPath, RTL_TEXTENCODING_UTF8 ) );
        nNextEntry = nNextEntry < 10 ? nNextEntry+1 : 0;
        rConfig.WriteKey( "NextEntry", ByteString::CreateFromInt32( nNextEntry ) );
        m_aPathBox.InsertEntry( aImportPath );
    }
    while( m_aDriverLB.GetEntryCount() )
    {
        delete (String*)m_aDriverLB.GetEntryData( 0 );
        m_aDriverLB.RemoveEntry( 0 );
    }

    ProgressDialog aProgress( Application::GetFocusWindow() );
    aProgress.startOperation( m_aLoadingPPD );

    ::std::list< String > aFiles;
    FindFiles( aImportPath, aFiles, String::CreateFromAscii( "PS;PPD" ) );

    int i = 0;
    aProgress.setRange( 0, aFiles.size() );
    while( aFiles.size() )
    {
        aProgress.setValue( ++i );
        aProgress.setFilename( aFiles.front() );
        INetURLObject aPath( aImportPath, INET_PROT_FILE, INetURLObject::ENCODE_ALL );
        aPath.Append( aFiles.front() );
        String aPrinterName = PPDParser::getPPDPrinterName( aPath.PathToFileName() );
        aFiles.pop_front();

        if( ! aPrinterName.Len() )
        {
#if OSL_DEBUG_LEVEL > 1
            fprintf( stderr, "Warning: File %s has empty printer name.\n",
                     ByteString( aPath.PathToFileName(), osl_getThreadTextEncoding() ).GetBuffer() );
#endif
            continue;
        }

        USHORT nPos = m_aDriverLB.InsertEntry( aPrinterName );
        m_aDriverLB.SetEntryData( nPos, new String( aPath.PathToFileName() ) );
    }
}

IMPL_LINK( PPDImportDialog, ClickBtnHdl, PushButton*, pButton )
{
    rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();

    if( pButton == &m_aCancelBtn )
    {
        EndDialog( 0 );
    }
    else if( pButton == &m_aOKBtn )
    {
        // copy the files
        ::std::list< String > aToDirs;
        String aPathList( ::psp::getPrinterPath() );
        int nTokens = aPathList.GetTokenCount( ':' );
        for( int n = 0; n < nTokens; n++ )
        {
            String aPath = aPathList.GetToken( n, ':' );
            aPath.AppendAscii( "/"PSPRINT_PPDDIR );
            aToDirs.push_back( aPath );
        }
        ::std::list< String >::iterator writeDir = aToDirs.begin();

        for( int i = 0; i < m_aDriverLB.GetSelectEntryCount(); i++ )
        {
            INetURLObject aFile( *(String*)m_aDriverLB.GetEntryData(
                m_aDriverLB.GetSelectEntryPos( i )
                ), INET_PROT_FILE, INetURLObject::ENCODE_ALL );
            OUString aFromUni( aFile.GetMainURL(INetURLObject::DECODE_TO_IURI) );

            do
            {
                INetURLObject aToFile( *writeDir, INET_PROT_FILE, INetURLObject::ENCODE_ALL );
                aToFile.Append( aFile.GetName() );
                aToFile.setExtension( String::CreateFromAscii( "PPD" ) );
                OUString aToUni( aToFile.GetMainURL(INetURLObject::DECODE_TO_IURI) );
                if( ! File::copy( aFromUni, aToUni ) )
                    break;
                ++writeDir;
            } while( writeDir != aToDirs.end() );
        }
        EndDialog( 1 );
    }
    else if( pButton == &m_aSearchBtn )
    {
        String aPath( m_aPathBox.GetText() );
        if( chooseDirectory( this, aPath ) )
        {
            m_aPathBox.SetText( aPath );
            Import();
        }
    }
    return 0;
}

IMPL_LINK( PPDImportDialog, SelectHdl, ComboBox*, pListBox )
{
    if( pListBox == &m_aPathBox )
    {
        Import();
    }
    return 0;
}

IMPL_LINK( PPDImportDialog, ModifyHdl, ComboBox*, pListBox )
{
    if( pListBox == &m_aPathBox )
    {
        ByteString aDir( m_aPathBox.GetText(), osl_getThreadTextEncoding() );
        if( ! access( aDir.GetBuffer(), F_OK ) )
            Import();
    }
    return 0;
}
<commit_msg>INTEGRATION: CWS cups01 (1.8.26); FILE MERGED 2004/02/13 15:32:27 pl 1.8.26.2: RESYNC: (1.8-1.9); FILE MERGED 2003/08/15 13:21:14 pl 1.8.26.1: removed a bunch of warnings<commit_after>/*************************************************************************
 *
 *  $RCSfile: newppdlg.cxx,v $
 *
 *  $Revision: 1.10 $
 *
 *  last change: $Author: obo $ $Date: 2004-03-17 10:44:51 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#include <stdio.h>
#include <unistd.h>

#ifndef _PSPRINT_PPDPARSER_HXX_
#include <psprint/ppdparser.hxx>
#endif
#ifndef _PSPRINT_HELPER_HXX_
#include <psprint/helper.hxx>
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#ifndef _SV_MNEMONIC_HXX
#include <vcl/mnemonic.hxx>
#endif
#ifndef _URLOBJ_HXX
#include <tools/urlobj.hxx>
#endif
#ifndef __SGI_STL_LIST
#include <list>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif

#ifndef _PAD_HELPER_HXX_
#include <helper.hxx>
#endif
#ifndef _PAD_PADIALOG_HRC_
#include <padialog.hrc>
#endif
#ifndef _PAD_NEWPPDLG_HXX_
#include <newppdlg.hxx>
#endif
#ifndef _PAD_PADIALOG_HXX_
#include <padialog.hxx>
#endif
#ifndef _PAD_PROGRESS_HXX_
#include <progress.hxx>
#endif

#define PPDIMPORT_GROUP "PPDImport"

using namespace padmin;
using namespace psp;
using namespace osl;
using namespace rtl;

PPDImportDialog::PPDImportDialog( Window* pParent ) :
        ModalDialog( pParent, PaResId( RID_PPDIMPORT_DLG ) ),
        m_aOKBtn( this, PaResId( RID_PPDIMP_BTN_OK ) ),
        m_aCancelBtn( this, PaResId( RID_PPDIMP_BTN_CANCEL ) ),
        m_aPathTxt( this, PaResId( RID_PPDIMP_TXT_PATH ) ),
        m_aPathBox( this, PaResId( RID_PPDIMP_LB_PATH ) ),
        m_aSearchBtn( this, PaResId( RID_PPDIMP_BTN_SEARCH ) ),
        m_aDriverTxt( this, PaResId( RID_PPDIMP_TXT_DRIVER ) ),
        m_aDriverLB( this, PaResId( RID_PPDIMP_LB_DRIVER ) ),
        m_aPathGroup( this, PaResId( RID_PPDIMP_GROUP_PATH ) ),
        m_aDriverGroup( this, PaResId( RID_PPDIMP_GROUP_DRIVER ) ),
        m_aLoadingPPD( PaResId( RID_PPDIMP_STR_LOADINGPPD ) )
{
    FreeResource();

    String aText( m_aDriverTxt.GetText() );
    aText.SearchAndReplaceAscii( "%s", Button::GetStandardText( BUTTON_OK ) );
    m_aDriverTxt.SetText( MnemonicGenerator::EraseAllMnemonicChars( aText ) );

    Config& rConfig = getPadminRC();
    rConfig.SetGroup( PPDIMPORT_GROUP );
    m_aPathBox.SetText( String( rConfig.ReadKey( "LastDir" ), RTL_TEXTENCODING_UTF8 ) );
    for( int i = 0; i < 11; i++ )
    {
        ByteString aEntry( rConfig.ReadKey( ByteString::CreateFromInt32( i ) ) );
        if( aEntry.Len() )
            m_aPathBox.InsertEntry( String( aEntry, RTL_TEXTENCODING_UTF8 ) );
    }

    m_aOKBtn.SetClickHdl( LINK( this, PPDImportDialog, ClickBtnHdl ) );
    m_aCancelBtn.SetClickHdl( LINK( this, PPDImportDialog, ClickBtnHdl ) );
    m_aSearchBtn.SetClickHdl( LINK( this, PPDImportDialog, ClickBtnHdl ) );
    m_aPathBox.SetSelectHdl( LINK( this, PPDImportDialog, SelectHdl ) );
    m_aPathBox.SetModifyHdl( LINK( this, PPDImportDialog, ModifyHdl ) );

    if( m_aPathBox.GetText().Len() )
        Import();
}

PPDImportDialog::~PPDImportDialog()
{
    while( m_aDriverLB.GetEntryCount() )
    {
        delete (String*)m_aDriverLB.GetEntryData( 0 );
        m_aDriverLB.RemoveEntry( 0 );
    }
}

void PPDImportDialog::Import()
{
    String aImportPath( m_aPathBox.GetText() );

    Config& rConfig = getPadminRC();
    rConfig.SetGroup( PPDIMPORT_GROUP );
    rConfig.WriteKey( "LastDir", ByteString( aImportPath, RTL_TEXTENCODING_UTF8 ) );

    int nEntries = m_aPathBox.GetEntryCount();
    while( nEntries-- )
        if( aImportPath == m_aPathBox.GetEntry( nEntries ) )
            break;
    if( nEntries < 0 )
    {
        int nNextEntry = rConfig.ReadKey( "NextEntry" ).ToInt32();
        rConfig.WriteKey( ByteString::CreateFromInt32( nNextEntry ), ByteString( aImportPath, RTL_TEXTENCODING_UTF8 ) );
        nNextEntry = nNextEntry < 10 ? nNextEntry+1 : 0;
        rConfig.WriteKey( "NextEntry", ByteString::CreateFromInt32( nNextEntry ) );
        m_aPathBox.InsertEntry( aImportPath );
    }
    while( m_aDriverLB.GetEntryCount() )
    {
        delete (String*)m_aDriverLB.GetEntryData( 0 );
        m_aDriverLB.RemoveEntry( 0 );
    }

    ProgressDialog aProgress( Application::GetFocusWindow() );
    aProgress.startOperation( m_aLoadingPPD );

    ::std::list< String > aFiles;
    FindFiles( aImportPath, aFiles, String::CreateFromAscii( "PS;PPD" ) );

    int i = 0;
    aProgress.setRange( 0, aFiles.size() );
    while( aFiles.size() )
    {
        aProgress.setValue( ++i );
        aProgress.setFilename( aFiles.front() );
        INetURLObject aPath( aImportPath, INET_PROT_FILE, INetURLObject::ENCODE_ALL );
        aPath.Append( aFiles.front() );
        String aPrinterName = PPDParser::getPPDPrinterName( aPath.PathToFileName() );
        aFiles.pop_front();

        if( ! aPrinterName.Len() )
        {
#if OSL_DEBUG_LEVEL > 1
            fprintf( stderr, "Warning: File %s has empty printer name.\n",
                     ByteString( aPath.PathToFileName(), osl_getThreadTextEncoding() ).GetBuffer() );
#endif
            continue;
        }

        USHORT nPos = m_aDriverLB.InsertEntry( aPrinterName );
        m_aDriverLB.SetEntryData( nPos, new String( aPath.PathToFileName() ) );
    }
}

IMPL_LINK( PPDImportDialog, ClickBtnHdl, PushButton*, pButton )
{
    if( pButton == &m_aCancelBtn )
    {
        EndDialog( 0 );
    }
    else if( pButton == &m_aOKBtn )
    {
        // copy the files
        ::std::list< String > aToDirs;
        String aPathList( ::psp::getPrinterPath() );
        int nTokens = aPathList.GetTokenCount( ':' );
        for( int n = 0; n < nTokens; n++ )
        {
            String aPath = aPathList.GetToken( n, ':' );
            aPath.AppendAscii( "/"PSPRINT_PPDDIR );
            aToDirs.push_back( aPath );
        }
        ::std::list< String >::iterator writeDir = aToDirs.begin();

        for( int i = 0; i < m_aDriverLB.GetSelectEntryCount(); i++ )
        {
            INetURLObject aFile( *(String*)m_aDriverLB.GetEntryData(
                m_aDriverLB.GetSelectEntryPos( i )
                ), INET_PROT_FILE, INetURLObject::ENCODE_ALL );
            OUString aFromUni( aFile.GetMainURL(INetURLObject::DECODE_TO_IURI) );

            do
            {
                INetURLObject aToFile( *writeDir, INET_PROT_FILE, INetURLObject::ENCODE_ALL );
                aToFile.Append( aFile.GetName() );
                aToFile.setExtension( String::CreateFromAscii( "PPD" ) );
                OUString aToUni( aToFile.GetMainURL(INetURLObject::DECODE_TO_IURI) );
                if( ! File::copy( aFromUni, aToUni ) )
                    break;
                ++writeDir;
            } while( writeDir != aToDirs.end() );
        }
        EndDialog( 1 );
    }
    else if( pButton == &m_aSearchBtn )
    {
        String aPath( m_aPathBox.GetText() );
        if( chooseDirectory( this, aPath ) )
        {
            m_aPathBox.SetText( aPath );
            Import();
        }
    }
    return 0;
}

IMPL_LINK( PPDImportDialog, SelectHdl, ComboBox*, pListBox )
{
    if( pListBox == &m_aPathBox )
    {
        Import();
    }
    return 0;
}

IMPL_LINK( PPDImportDialog, ModifyHdl, ComboBox*, pListBox )
{
    if( pListBox == &m_aPathBox )
    {
        ByteString aDir( m_aPathBox.GetText(), osl_getThreadTextEncoding() );
        if( ! access( aDir.GetBuffer(), F_OK ) )
            Import();
    }
    return 0;
}
<|endoftext|>


<commit_before><commit_msg>This is the Chromium side of my WebKit change that fixes some Find issues with text marked as user-select-none.<commit_after><|endoftext|>


<commit_before><commit_msg>Fix failing unittest ExtensionResourceTest.CreateWithMissingResourceOnDisk in unit_tests.<commit_after><|endoftext|>


<commit_before>/*=========================================================================

 Program:   ORFEO Toolbox
 Language:  C++
 Date:      $Date$
 Version:   $Revision$

 Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
 See OTBCopyright.txt for details.

 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notices for more information.

 =========================================================================*/
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"

#include "otbMeanShiftVectorImageFilter.h"

namespace otb
{
namespace Wrapper
{

class MeanShiftSegmentation : public Application
{
public:
  /** Standard class typedefs. */
  typedef MeanShiftSegmentation         Self;
  typedef Application                   Superclass;
  typedef itk::SmartPointer<Self>       Pointer;
  typedef itk::SmartPointer<const Self> ConstPointer;

  /** Standard macro */
  itkNewMacro(Self);

  itkTypeMacro(MeanShiftSegmentation, otb::Application);

private:
  void DoInit()
  {
    SetName("MeanShiftSegmentation");
    SetDescription("Perform mean shift clustering");

    // Documentation
    SetDocName("Mean Shift segmentation application");
    SetDocLongDescription("This application performs mean shift clustering.");
    SetDocLimitations("None");
    SetDocAuthors("OTB-Team");
    SetDocSeeAlso(" ");

    AddDocTag(Tags::Segmentation);

    AddParameter(ParameterType_InputImage,   "in",     "Input Image");
    AddParameter(ParameterType_OutputImage,  "fout",    "Filtered output");
    AddParameter(ParameterType_OutputImage,  "cout",    "Clustered output");
    AddParameter(ParameterType_OutputImage,  "lout",    "Label output");
    AddParameter(ParameterType_OutputImage,  "cbout",   "Cluster Boundaries output");
    MandatoryOff("fout");
    MandatoryOff("cout");
    MandatoryOff("lout");
    MandatoryOff("cbout");

    AddParameter(ParameterType_RAM, "ram", "Available RAM");
    SetDefaultParameterInt("ram", 256);
    MandatoryOff("ram");

    AddParameter(ParameterType_Int,          "spatialr",   "Spatial radius");
    AddParameter(ParameterType_Float,        "ranger",   "Range radius");
    AddParameter(ParameterType_Int,          "minsize",   "Min region size");
    AddParameter(ParameterType_Float,        "scale",   "Scale");
    SetDefaultParameterInt("spatialr",   5);
    SetDefaultParameterFloat("ranger",   15.0);
    SetDefaultParameterInt("minsize",    100);
    SetDefaultParameterFloat("scale",    100000.);

    // Doc example parameter settings
    SetDocExampleParameterValue("in", "qb_RoadExtract2sub200x200.tif");
    SetDocExampleParameterValue("cout", "MeanShift_ClusteredOutput.tif");
    SetDocExampleParameterValue("fout", "MeanShift_FilterOutput.tif");
    SetDocExampleParameterValue("lout", "MeanShift_LabeledClusteredOutput.tif uint32");
    SetDocExampleParameterValue("cbout", "MeanShift_ClusterBoundariesOutput.tif uint8");
    SetDocExampleParameterValue("spatialr", "16");
    SetDocExampleParameterValue("ranger", "16");
    SetDocExampleParameterValue("minsize", "10");
    SetDocExampleParameterValue("scale", "1.0");

  }

  void DoUpdateParameters()
  {
    // Nothing to do here : all parameters are independent
  }

  void DoExecute()
  {
    FloatVectorImageType* input = GetParameterImage("in");

    typedef otb::MeanShiftVectorImageFilter<FloatVectorImageType, FloatVectorImageType> MSFilterType;
    MSFilterType::Pointer filter = MSFilterType::New();

    filter->SetInput(input);
    filter->SetSpatialRadius( GetParameterInt("spatialr") );
    filter->SetRangeRadius( GetParameterFloat("ranger") );
    filter->SetMinimumRegionSize( GetParameterInt("minsize") );
    filter->SetScale( GetParameterFloat("scale") );

    m_Ref = filter;

    if (IsParameterEnabled("fout") && HasValue("fout"))
      SetParameterOutputImage("fout", filter->GetOutput());
    if (IsParameterEnabled("cout") && HasValue("cout"))
      SetParameterOutputImage("cout", filter->GetClusteredOutput());
    if (IsParameterEnabled("lout") && HasValue("lout"))
      SetParameterOutputImage("lout", filter->GetLabeledClusteredOutput());
    if (IsParameterEnabled("cbout") && HasValue("cbout"))
      SetParameterOutputImage("cbout", filter->GetClusterBoundariesOutput());
  }

  itk::LightObject::Pointer m_Ref;

};

}
}

OTB_APPLICATION_EXPORT(otb::Wrapper::MeanShiftSegmentation)
<commit_msg>ENH: explicit cast of labeled and clusterboundaries output of meanshift segmentation application.<commit_after>/*=========================================================================

 Program:   ORFEO Toolbox
 Language:  C++
 Date:      $Date$
 Version:   $Revision$

 Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
 See OTBCopyright.txt for details.

 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notices for more information.

 =========================================================================*/
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"

#include "otbMeanShiftVectorImageFilter.h"

namespace otb
{
namespace Wrapper
{

class MeanShiftSegmentation : public Application
{
public:
  /** Standard class typedefs. */
  typedef MeanShiftSegmentation         Self;
  typedef Application                   Superclass;
  typedef itk::SmartPointer<Self>       Pointer;
  typedef itk::SmartPointer<const Self> ConstPointer;

  typedef otb::MeanShiftVectorImageFilter<FloatVectorImageType, FloatVectorImageType> MSFilterType;

  /** Standard macro */
  itkNewMacro(Self);

  itkTypeMacro(MeanShiftSegmentation, otb::Application);

private:
  void DoInit()
  {
    SetName("MeanShiftSegmentation");
    SetDescription("Perform mean shift clustering");

    // Documentation
    SetDocName("Mean Shift segmentation application");
    SetDocLongDescription("This application performs mean shift clustering.");
    SetDocLimitations("None");
    SetDocAuthors("OTB-Team");
    SetDocSeeAlso(" ");

    AddDocTag(Tags::Segmentation);

    AddParameter(ParameterType_InputImage,   "in",     "Input Image");
    AddParameter(ParameterType_OutputImage,  "fout",    "Filtered output");
    AddParameter(ParameterType_OutputImage,  "cout",    "Clustered output");
    AddParameter(ParameterType_OutputImage,  "lout",    "Label output");
    AddParameter(ParameterType_OutputImage,  "cbout",   "Cluster Boundaries output");
    MandatoryOff("fout");
    MandatoryOff("cout");
    MandatoryOff("lout");
    MandatoryOff("cbout");

    AddParameter(ParameterType_RAM, "ram", "Available RAM");
    SetDefaultParameterInt("ram", 256);
    MandatoryOff("ram");

    AddParameter(ParameterType_Int,          "spatialr",   "Spatial radius");
    AddParameter(ParameterType_Float,        "ranger",   "Range radius");
    AddParameter(ParameterType_Int,          "minsize",   "Min region size");
    AddParameter(ParameterType_Float,        "scale",   "Scale");
    SetDefaultParameterInt("spatialr",   5);
    SetDefaultParameterFloat("ranger",   15.0);
    SetDefaultParameterInt("minsize",    100);
    SetDefaultParameterFloat("scale",    100000.);

    // Doc example parameter settings
    SetDocExampleParameterValue("in", "qb_RoadExtract2sub200x200.tif");
    SetDocExampleParameterValue("cout", "MeanShift_ClusteredOutput.tif");
    SetDocExampleParameterValue("fout", "MeanShift_FilterOutput.tif");
    SetDocExampleParameterValue("lout", "MeanShift_LabeledClusteredOutput.tif uint32");
    SetDocExampleParameterValue("cbout", "MeanShift_ClusterBoundariesOutput.tif uint8");
    SetDocExampleParameterValue("spatialr", "16");
    SetDocExampleParameterValue("ranger", "16");
    SetDocExampleParameterValue("minsize", "10");
    SetDocExampleParameterValue("scale", "1.0");

  }

  void DoUpdateParameters()
  {
    // Nothing to do here : all parameters are independent
  }

  void DoExecute()
  {
    FloatVectorImageType* input = GetParameterImage("in");

   m_filter = MSFilterType::New();

    m_filter->SetInput(input);
    m_filter->SetSpatialRadius( GetParameterInt("spatialr") );
    m_filter->SetRangeRadius( GetParameterFloat("ranger") );
    m_filter->SetMinimumRegionSize( GetParameterInt("minsize") );
    m_filter->SetScale( GetParameterFloat("scale") );

    if (IsParameterEnabled("fout") && HasValue("fout"))
      SetParameterOutputImage("fout", m_filter->GetOutput());
    if (IsParameterEnabled("cout") && HasValue("cout"))
      SetParameterOutputImage("cout", m_filter->GetClusteredOutput());
    if (IsParameterEnabled("lout") && HasValue("lout"))
      SetParameterOutputImage<UInt16ImageType>("lout", m_filter->GetLabeledClusteredOutput());
    if (IsParameterEnabled("cbout") && HasValue("cbout"))
      SetParameterOutputImage<UInt16ImageType>("cbout", m_filter->GetClusterBoundariesOutput());
  }

  MSFilterType::Pointer m_filter;

};

}
}

OTB_APPLICATION_EXPORT(otb::Wrapper::MeanShiftSegmentation)
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/initfiles/p9_cxa_scom.C $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#include "p9_cxa_scom.H"
#include <stdint.h>
#include <stddef.h>
#include <fapi2.H>

using namespace fapi2;

constexpr auto literal_0x80031F98D8717 = 0x80031F98D8717;
constexpr auto literal_0x0B1C000104060 = 0x0B1C000104060;
constexpr auto literal_0x2B9C0001240E0 = 0x2B9C0001240E0;
constexpr auto literal_0b0000 = 0b0000;
constexpr auto literal_0b111 = 0b111;
constexpr auto literal_0b0010 = 0b0010;
constexpr auto literal_0b0001 = 0b0001;

fapi2::ReturnCode p9_cxa_scom(const fapi2::Target<fapi2::TARGET_TYPE_CAPP>& TGT0,
                              const fapi2::Target<fapi2::TARGET_TYPE_SYSTEM>& TGT1)
{
    fapi2::ReturnCode l_rc = 0;

    do
    {
        fapi2::ATTR_PROC_FABRIC_ADDR_BAR_MODE_Type l_TGT1_ATTR_PROC_FABRIC_ADDR_BAR_MODE;
        l_rc = FAPI_ATTR_GET(fapi2::ATTR_PROC_FABRIC_ADDR_BAR_MODE, TGT1, l_TGT1_ATTR_PROC_FABRIC_ADDR_BAR_MODE);

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: FAPI_ATTR_GET (ATTR_PROC_FABRIC_ADDR_BAR_MODE)");
            break;
        }

        fapi2::ATTR_PROC_FABRIC_PUMP_MODE_Type l_TGT1_ATTR_PROC_FABRIC_PUMP_MODE;
        l_rc = FAPI_ATTR_GET(fapi2::ATTR_PROC_FABRIC_PUMP_MODE, TGT1, l_TGT1_ATTR_PROC_FABRIC_PUMP_MODE);

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: FAPI_ATTR_GET (ATTR_PROC_FABRIC_PUMP_MODE)");
            break;
        }

        fapi2::buffer<uint64_t> l_scom_buffer;
        {
            l_rc = fapi2::getScom( TGT0, 0x2010803ull, l_scom_buffer );

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: getScom (0x2010803ull)");
                break;
            }

            l_scom_buffer.insert<uint64_t> (literal_0x80031F98D8717, 0, 52, 0 );
            l_rc = fapi2::putScom(TGT0, 0x2010803ull, l_scom_buffer);

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: putScom (0x2010803ull)");
                break;
            }
        }
        {
            l_rc = fapi2::getScom( TGT0, 0x2010806ull, l_scom_buffer );

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: getScom (0x2010806ull)");
                break;
            }

            l_scom_buffer.insert<uint64_t> (literal_0x0B1C000104060, 0, 52, 12 );
            l_rc = fapi2::putScom(TGT0, 0x2010806ull, l_scom_buffer);

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: putScom (0x2010806ull)");
                break;
            }
        }
        {
            l_rc = fapi2::getScom( TGT0, 0x2010807ull, l_scom_buffer );

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: getScom (0x2010807ull)");
                break;
            }

            l_scom_buffer.insert<uint64_t> (literal_0x2B9C0001240E0, 0, 52, 12 );
            l_rc = fapi2::putScom(TGT0, 0x2010807ull, l_scom_buffer);

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: putScom (0x2010807ull)");
                break;
            }
        }
        {
            l_rc = fapi2::getScom( TGT0, 0x2010818ull, l_scom_buffer );

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: getScom (0x2010818ull)");
                break;
            }

            if ((l_TGT1_ATTR_PROC_FABRIC_ADDR_BAR_MODE == fapi2::ENUM_ATTR_PROC_FABRIC_ADDR_BAR_MODE_SMALL_SYSTEM))
            {
                constexpr auto l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_ADR_BAR_MODE_ON = 0x1;
                l_scom_buffer.insert<uint64_t> (l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_ADR_BAR_MODE_ON, 1, 1, 63 );
            }
            else if ((l_TGT1_ATTR_PROC_FABRIC_ADDR_BAR_MODE == fapi2::ENUM_ATTR_PROC_FABRIC_ADDR_BAR_MODE_LARGE_SYSTEM))
            {
                constexpr auto l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_ADR_BAR_MODE_OFF = 0x0;
                l_scom_buffer.insert<uint64_t> (l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_ADR_BAR_MODE_OFF, 1, 1, 63 );
            }

            if ((l_TGT1_ATTR_PROC_FABRIC_PUMP_MODE == fapi2::ENUM_ATTR_PROC_FABRIC_PUMP_MODE_CHIP_IS_GROUP))
            {
                constexpr auto l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_SKIP_G_ON = 0x1;
                l_scom_buffer.insert<uint64_t> (l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_SKIP_G_ON, 6, 1, 63 );
            }
            else if ((l_TGT1_ATTR_PROC_FABRIC_PUMP_MODE == fapi2::ENUM_ATTR_PROC_FABRIC_PUMP_MODE_CHIP_IS_NODE))
            {
                constexpr auto l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_SKIP_G_OFF = 0x0;
                l_scom_buffer.insert<uint64_t> (l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_SKIP_G_OFF, 6, 1, 63 );
            }

            l_rc = fapi2::putScom(TGT0, 0x2010818ull, l_scom_buffer);

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: putScom (0x2010818ull)");
                break;
            }
        }
        {
            l_rc = fapi2::getScom( TGT0, 0x2010819ull, l_scom_buffer );

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: getScom (0x2010819ull)");
                break;
            }

            l_scom_buffer.insert<uint64_t> (literal_0b0000, 4, 4, 60 );
            l_rc = fapi2::putScom(TGT0, 0x2010819ull, l_scom_buffer);

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: putScom (0x2010819ull)");
                break;
            }
        }
        {
            l_rc = fapi2::getScom( TGT0, 0x201081bull, l_scom_buffer );

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: getScom (0x201081bull)");
                break;
            }

            l_scom_buffer.insert<uint64_t> (literal_0b111, 45, 3, 61 );
            l_scom_buffer.insert<uint64_t> (literal_0b0010, 48, 4, 60 );
            l_rc = fapi2::putScom(TGT0, 0x201081bull, l_scom_buffer);

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: putScom (0x201081bull)");
                break;
            }
        }
        {
            l_rc = fapi2::getScom( TGT0, 0x201081cull, l_scom_buffer );

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: getScom (0x201081cull)");
                break;
            }

            l_scom_buffer.insert<uint64_t> (literal_0b0001, 18, 4, 60 );
            l_rc = fapi2::putScom(TGT0, 0x201081cull, l_scom_buffer);

            if (l_rc)
            {
                FAPI_ERR("ERROR executing: putScom (0x201081cull)");
                break;
            }
        }

    }
    while(0);

    return l_rc;
}
<commit_msg>Modify initCompiler to use FAPI_TRY in generated procedures<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/initfiles/p9_cxa_scom.C $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#include "p9_cxa_scom.H"
#include <stdint.h>
#include <stddef.h>
#include <fapi2.H>

using namespace fapi2;

constexpr auto literal_0x80031F98D8717 = 0x80031F98D8717;
constexpr auto literal_0x0B1C000104060 = 0x0B1C000104060;
constexpr auto literal_0x2B9C0001240E0 = 0x2B9C0001240E0;
constexpr auto literal_0b0000 = 0b0000;
constexpr auto literal_0b111 = 0b111;
constexpr auto literal_0b0010 = 0b0010;
constexpr auto literal_0b0001 = 0b0001;

fapi2::ReturnCode p9_cxa_scom(const fapi2::Target<fapi2::TARGET_TYPE_CAPP>& TGT0,
                              const fapi2::Target<fapi2::TARGET_TYPE_SYSTEM>& TGT1)
{
    {
        fapi2::ATTR_PROC_FABRIC_ADDR_BAR_MODE_Type l_TGT1_ATTR_PROC_FABRIC_ADDR_BAR_MODE;
        FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_PROC_FABRIC_ADDR_BAR_MODE, TGT1, l_TGT1_ATTR_PROC_FABRIC_ADDR_BAR_MODE));
        fapi2::ATTR_PROC_FABRIC_PUMP_MODE_Type l_TGT1_ATTR_PROC_FABRIC_PUMP_MODE;
        FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_PROC_FABRIC_PUMP_MODE, TGT1, l_TGT1_ATTR_PROC_FABRIC_PUMP_MODE));
        fapi2::buffer<uint64_t> l_scom_buffer;
        {
            FAPI_TRY(fapi2::getScom( TGT0, 0x2010803ull, l_scom_buffer ));

            l_scom_buffer.insert<uint64_t> (literal_0x80031F98D8717, 0, 52, 0 );
            FAPI_TRY(fapi2::putScom(TGT0, 0x2010803ull, l_scom_buffer));
        }
        {
            FAPI_TRY(fapi2::getScom( TGT0, 0x2010806ull, l_scom_buffer ));

            l_scom_buffer.insert<uint64_t> (literal_0x0B1C000104060, 0, 52, 12 );
            FAPI_TRY(fapi2::putScom(TGT0, 0x2010806ull, l_scom_buffer));
        }
        {
            FAPI_TRY(fapi2::getScom( TGT0, 0x2010807ull, l_scom_buffer ));

            l_scom_buffer.insert<uint64_t> (literal_0x2B9C0001240E0, 0, 52, 12 );
            FAPI_TRY(fapi2::putScom(TGT0, 0x2010807ull, l_scom_buffer));
        }
        {
            FAPI_TRY(fapi2::getScom( TGT0, 0x2010818ull, l_scom_buffer ));

            if ((l_TGT1_ATTR_PROC_FABRIC_ADDR_BAR_MODE == fapi2::ENUM_ATTR_PROC_FABRIC_ADDR_BAR_MODE_SMALL_SYSTEM))
            {
                constexpr auto l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_ADR_BAR_MODE_ON = 0x1;
                l_scom_buffer.insert<uint64_t> (l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_ADR_BAR_MODE_ON, 1, 1, 63 );
            }
            else if ((l_TGT1_ATTR_PROC_FABRIC_ADDR_BAR_MODE == fapi2::ENUM_ATTR_PROC_FABRIC_ADDR_BAR_MODE_LARGE_SYSTEM))
            {
                constexpr auto l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_ADR_BAR_MODE_OFF = 0x0;
                l_scom_buffer.insert<uint64_t> (l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_ADR_BAR_MODE_OFF, 1, 1, 63 );
            }

            if ((l_TGT1_ATTR_PROC_FABRIC_PUMP_MODE == fapi2::ENUM_ATTR_PROC_FABRIC_PUMP_MODE_CHIP_IS_GROUP))
            {
                constexpr auto l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_SKIP_G_ON = 0x1;
                l_scom_buffer.insert<uint64_t> (l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_SKIP_G_ON, 6, 1, 63 );
            }
            else if ((l_TGT1_ATTR_PROC_FABRIC_PUMP_MODE == fapi2::ENUM_ATTR_PROC_FABRIC_PUMP_MODE_CHIP_IS_NODE))
            {
                constexpr auto l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_SKIP_G_OFF = 0x0;
                l_scom_buffer.insert<uint64_t> (l_CAPP0_CXA_TOP_CXA_APC0_APCCTL_SKIP_G_OFF, 6, 1, 63 );
            }

            FAPI_TRY(fapi2::putScom(TGT0, 0x2010818ull, l_scom_buffer));
        }
        {
            FAPI_TRY(fapi2::getScom( TGT0, 0x2010819ull, l_scom_buffer ));

            l_scom_buffer.insert<uint64_t> (literal_0b0000, 4, 4, 60 );
            FAPI_TRY(fapi2::putScom(TGT0, 0x2010819ull, l_scom_buffer));
        }
        {
            FAPI_TRY(fapi2::getScom( TGT0, 0x201081bull, l_scom_buffer ));

            l_scom_buffer.insert<uint64_t> (literal_0b111, 45, 3, 61 );
            l_scom_buffer.insert<uint64_t> (literal_0b0010, 48, 4, 60 );
            FAPI_TRY(fapi2::putScom(TGT0, 0x201081bull, l_scom_buffer));
        }
        {
            FAPI_TRY(fapi2::getScom( TGT0, 0x201081cull, l_scom_buffer ));

            l_scom_buffer.insert<uint64_t> (literal_0b0001, 18, 4, 60 );
            FAPI_TRY(fapi2::putScom(TGT0, 0x201081cull, l_scom_buffer));
        }

    };
fapi_try_exit:
    return fapi2::current_err;
}
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/io/p9_io_dmi_scominit.C $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
///
/// @file p9_io_dmi_scominit.C
/// @brief Invoke DMI processor side initfile
///
//----------------------------------------------------------------------------
// *HWP HWP Owner       : Chris Steffen <cwsteffen@us.ibm.com>
// *HWP HWP Backup Owner: Gary Peterson <garyp@us.ibm.com>
// *HWP FW Owner        : Sumit Kumar <sumit_kumar@in.ibm.com>
// *HWP Team            : IO
// *HWP Level           : 3
// *HWP Consumed by     : FSP:HB
//----------------------------------------------------------------------------
//
// @verbatim
// High-level procedure flow:
//
//   Invoke DMI scominit file.
//
// Procedure Prereq:
//   - System clocks are running.
// @endverbatim
//----------------------------------------------------------------------------

//------------------------------------------------------------------------------
//  Includes
//------------------------------------------------------------------------------
#include <p9_io_regs.H>
#include <p9_io_scom.H>
#include <p9_io_dmi_scominit.H>
#include <p9c_dmi_io_scom.H>

//------------------------------------------------------------------------------
// Constant definitions
//------------------------------------------------------------------------------
const uint64_t FIR_ACTION0 = 0x0000000000000000ULL;
const uint64_t FIR_ACTION1 = 0x2068686868000000ULL;
const uint64_t FIR_MASK    = 0xDF97979797FFC000ULL;

const uint64_t DMI_FIR_ACTION0_REG = 0x07011006;
const uint64_t DMI_FIR_ACTION1_REG = 0x07011007;
const uint64_t DMI_FIR_MASK_REG    = 0x07011003;

//------------------------------------------------------------------------------
// Function definitions
//------------------------------------------------------------------------------

/**
 * @brief Gets the value of the ATTR_CHIP_UNIT_NUM and passes back by reference
 * @param[in]  i_tgt         Fapi2 Target
 * @param[out] o_chipunitnum Chip Unit Number
 * @return FAPI2_RC_SUCCESS on success, otherwise error
 */
fapi2::ReturnCode p9_dmi_get_chipunit_num(const DMI_TGT& i_tgt, uint8_t& o_chipunitnum)
{
    FAPI_IMP("I/O DMI Scominit: Get Chipunit Number Start.");

    // Retrieve chipunitnum attribute
    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_tgt, o_chipunitnum ),
             "Error getting ATTR_CHIP_UNIT_POS, rc = 0x%.8X",
             (uint64_t)fapi2::current_err );

fapi_try_exit:
    FAPI_IMP("I/O DMI Scominit: Get Chipunit Number Exit.");
    return fapi2::current_err;
}

/**
 * @brief HWP that calls the DMI SCOM initfiles
 * Should be called for all valid/connected DMI endpoints
 *
 * @param[in] i_tgt  Reference to DMI chiplet target
 *
 * @return FAPI2_RC_SUCCESS on success, error otherwise
 */
fapi2::ReturnCode p9_io_dmi_scominit(const DMI_TGT& i_tgt)
{
    // mark HWP entry
    FAPI_INF("p9_io_dmi_scominit: Entering ...");
    const uint8_t GRP_03  = 3;
    const uint8_t LANE_00 = 0;
    fapi2::ReturnCode rc  = fapi2::FAPI2_RC_SUCCESS;

    // Get system target
    const fapi2::Target<fapi2::TARGET_TYPE_SYSTEM> sys_tgt;

    // assert IO reset to power-up bus endpoint logic
    // read-modify-write, set single reset bit (HW auto-clears)
    // on writeback
    FAPI_TRY(io::rmw(EDIP_RX_IORESET, i_tgt, GRP_03, LANE_00, 1));

    // Calculated HW Delay needed based on counter size and clock speed.
    // 50us -- Based on Counter Size, 40us minimum
    // 1 Million sim cycles -- Based on sim learning
    FAPI_TRY(fapi2::delay(50000, 1000000));

    FAPI_TRY(io::rmw(EDIP_TX_IORESET, i_tgt, GRP_03, LANE_00, 1));

    // Calculated HW Delay needed based on counter size and clock speed.
    // 50us -- Based on Counter Size, 40us minimum
    // 1 Million sim cycles -- Based on sim learning
    FAPI_TRY(fapi2::delay(50000, 1000000));

    FAPI_INF("Invoke FAPI2 p9c_dmi_scom Procedure");
    FAPI_EXEC_HWP(rc, p9c_dmi_io_scom, i_tgt, sys_tgt);

    if(rc)
    {
        FAPI_ERR("P9 I/O DMI Scominit Failed");
        fapi2::current_err = rc;
    }

    // configure FIR
    {
        fapi2::Target<fapi2::TARGET_TYPE_MC> l_mc_tgt =
            i_tgt.getParent<fapi2::TARGET_TYPE_MC>();

        FAPI_TRY(fapi2::putScom(l_mc_tgt,
                                DMI_FIR_ACTION0_REG,
                                FIR_ACTION0),
                 "Error from putScom (DMI_FIR_ACTION0_REG)");
        FAPI_TRY(fapi2::putScom(l_mc_tgt,
                                DMI_FIR_ACTION1_REG,
                                FIR_ACTION1),
                 "Error from putScom (DMI_FIR_ACTION1_REG)");
        FAPI_TRY(fapi2::putScom(l_mc_tgt,
                                DMI_FIR_MASK_REG,
                                FIR_MASK),
                 "Error from putScom (DMI_FIR_MASK_REG)");
    }

    // mark HWP exit
    FAPI_INF("p9_io_dmi_scominit: ... Exiting");

fapi_try_exit:
    return fapi2::current_err;
}
<commit_msg>Updating P9C DMI Proc Firs<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/io/p9_io_dmi_scominit.C $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
///
/// @file p9_io_dmi_scominit.C
/// @brief Invoke DMI processor side initfile
///
//----------------------------------------------------------------------------
// *HWP HWP Owner       : Chris Steffen <cwsteffen@us.ibm.com>
// *HWP HWP Backup Owner: Gary Peterson <garyp@us.ibm.com>
// *HWP FW Owner        : Sumit Kumar <sumit_kumar@in.ibm.com>
// *HWP Team            : IO
// *HWP Level           : 3
// *HWP Consumed by     : FSP:HB
//----------------------------------------------------------------------------
//
// @verbatim
// High-level procedure flow:
//
//   Invoke DMI scominit file.
//
// Procedure Prereq:
//   - System clocks are running.
// @endverbatim
//----------------------------------------------------------------------------

//------------------------------------------------------------------------------
//  Includes
//------------------------------------------------------------------------------
#include <p9_io_regs.H>
#include <p9_io_scom.H>
#include <p9_io_dmi_scominit.H>
#include <p9c_dmi_io_scom.H>

//------------------------------------------------------------------------------
// Constant definitions
//------------------------------------------------------------------------------
const uint64_t DMI_FIR_ACTION0_REG = 0x07011006;
const uint64_t DMI_FIR_ACTION1_REG = 0x07011007;
const uint64_t DMI_FIR_MASK_REG    = 0x07011003;

//------------------------------------------------------------------------------
// Function definitions
//------------------------------------------------------------------------------

/**
 * @brief Gets the value of the ATTR_CHIP_UNIT_NUM and passes back by reference
 * @param[in]  i_tgt         Fapi2 Target
 * @param[out] o_chipunitnum Chip Unit Number
 * @return FAPI2_RC_SUCCESS on success, otherwise error
 */
fapi2::ReturnCode p9_dmi_get_chipunit_num(const DMI_TGT& i_tgt, uint8_t& o_chipunitnum)
{
    FAPI_IMP("I/O DMI Scominit: Get Chipunit Number Start.");

    // Retrieve chipunitnum attribute
    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_tgt, o_chipunitnum ),
             "Error getting ATTR_CHIP_UNIT_POS, rc = 0x%.8X",
             (uint64_t)fapi2::current_err );

fapi_try_exit:
    FAPI_IMP("I/O DMI Scominit: Get Chipunit Number Exit.");
    return fapi2::current_err;
}

/**
 * @brief HWP that calls the DMI SCOM initfiles
 * Should be called for all valid/connected DMI endpoints
 *
 * @param[in] i_tgt  Reference to DMI chiplet target
 *
 * @return FAPI2_RC_SUCCESS on success, error otherwise
 */
fapi2::ReturnCode p9_io_dmi_scominit(const DMI_TGT& i_tgt)
{
    // mark HWP entry
    FAPI_INF("p9_io_dmi_scominit: Entering ...");
    const uint8_t GRP_03  = 3;
    const uint8_t LANE_00 = 0;
    fapi2::ReturnCode rc  = fapi2::FAPI2_RC_SUCCESS;

    // Get system target
    const fapi2::Target<fapi2::TARGET_TYPE_SYSTEM> sys_tgt;

    // assert IO reset to power-up bus endpoint logic
    // read-modify-write, set single reset bit (HW auto-clears)
    // on writeback
    FAPI_TRY(io::rmw(EDIP_RX_IORESET, i_tgt, GRP_03, LANE_00, 1));

    // Calculated HW Delay needed based on counter size and clock speed.
    // 50us -- Based on Counter Size, 40us minimum
    // 1 Million sim cycles -- Based on sim learning
    FAPI_TRY(fapi2::delay(50000, 1000000));

    FAPI_TRY(io::rmw(EDIP_TX_IORESET, i_tgt, GRP_03, LANE_00, 1));

    // Calculated HW Delay needed based on counter size and clock speed.
    // 50us -- Based on Counter Size, 40us minimum
    // 1 Million sim cycles -- Based on sim learning
    FAPI_TRY(fapi2::delay(50000, 1000000));

    FAPI_INF("Invoke FAPI2 p9c_dmi_scom Procedure");
    FAPI_EXEC_HWP(rc, p9c_dmi_io_scom, i_tgt, sys_tgt);

    if(rc)
    {
        FAPI_ERR("P9 I/O DMI Scominit Failed");
        fapi2::current_err = rc;
    }

    // configure FIR
    {
        fapi2::Target<fapi2::TARGET_TYPE_MC> l_mc_tgt =
            i_tgt.getParent<fapi2::TARGET_TYPE_MC>();

        // mask(1) action0(X) action1(X) : Masked
        // mask(0) action0(0) action1(0) : System Checkstop
        // mask(0) action0(0) action1(1) : Recoverable
        // mask(0) action0(1) action1(0) : Host Attention
        // mask(0) action0(1) action1(1) : Unit Checkstop
        fapi2::buffer<uint64_t> l_fir_mask;
        fapi2::buffer<uint64_t> l_fir_action0;
        fapi2::buffer<uint64_t> l_fir_action1;
        l_fir_mask.flush<1>();
        l_fir_action0.flush<0>();
        l_fir_action1.flush<0>();

        // 0    Rx Invalid State or Parity Error         recoverable
        l_fir_mask.clearBit<0>();
        l_fir_action1.setBit<0>();
        // 1    Tx Invalid State or Parity Error         recoverable
        l_fir_mask.clearBit<1>();
        l_fir_action1.setBit<1>();
        // 2    GCR Hange Error                          recoverable
        l_fir_mask.clearBit<2>();
        l_fir_action1.setBit<2>();
        // 3:7  Reserved                                 mask
        // 8    Rx Bus 0 Training Error                  mask
        // 9    Rx Bus 0 Spare Lane Deployed             recoverable
        l_fir_mask.clearBit<9>();
        l_fir_action1.setBit<9>();
        // 10   Rx Bus 0 Max Spares Exceeded             recoverable
        l_fir_mask.clearBit<10>();
        l_fir_action1.setBit<10>();
        // 11   Rx Bus 0 Recal or Dynamic Repair Error   recoverable
        l_fir_mask.clearBit<11>();
        l_fir_action1.setBit<11>();
        // 12   Rx Bus 0 Too Many Bus Errors             unit_cs
        l_fir_mask.clearBit<12>();
        l_fir_action0.setBit<12>();
        l_fir_action1.setBit<12>();
        // 13:15 Reserved                                mask
        // 16   Rx Bus 1 Training Error                  mask
        // 17   Rx Bus 1 Spare Lane Deployed             recoverable
        l_fir_mask.clearBit<17>();
        l_fir_action1.setBit<17>();
        // 18   Rx Bus 1 Max Spares Exceeded             recoverable
        l_fir_mask.clearBit<18>();
        l_fir_action1.setBit<18>();
        // 19   Rx Bus 1 Recal or Dynamic Repair Error   recoverable
        l_fir_mask.clearBit<19>();
        l_fir_action1.setBit<19>();
        // 20   Rx Bus 1 Too Many Bus Errors             unit_cs
        l_fir_mask.clearBit<20>();
        l_fir_action0.setBit<20>();
        l_fir_action1.setBit<20>();
        // 21:23 Reserved                                mask
        // 24   Rx Bus 2 Training Error                  mask
        // 25   Rx Bus 2 Spare Lane Deployed             recoverable
        l_fir_mask.clearBit<25>();
        l_fir_action1.setBit<25>();
        // 26   Rx Bus 2 Max Spares Exceeded             recoverable
        l_fir_mask.clearBit<26>();
        l_fir_action1.setBit<26>();
        // 27   Rx Bus 2 Recal or Dynamic Repair Error   recoverable
        l_fir_mask.clearBit<27>();
        l_fir_action1.setBit<27>();
        // 28   Rx Bus 2 Too Many Bus Errors             unit_cs
        l_fir_mask.clearBit<28>();
        l_fir_action0.setBit<28>();
        l_fir_action1.setBit<28>();
        // 29:31 Reserved                                mask
        // 32   Rx Bus 3 Training Error                  mask
        // 33   Rx Bus 3 Spare Lane Deployed             recoverable
        l_fir_mask.clearBit<33>();
        l_fir_action1.setBit<33>();
        // 34   Rx Bus 3 Max Spares Exceeded             recoverable
        l_fir_mask.clearBit<34>();
        l_fir_action1.setBit<34>();
        // 35   Rx Bus 3 Recal or Dynamic Repair Error   recoverable
        l_fir_mask.clearBit<35>();
        l_fir_action1.setBit<35>();
        // 36   Rx Bus 3 Too Many Bus Errors             unit_cs
        l_fir_mask.clearBit<36>();
        l_fir_action0.setBit<36>();
        l_fir_action1.setBit<36>();
        // 37:39 Reserved                                mask
        // 40:47 Bus 4 - Unused                          mask
        // 48    Scom Error                              mask
        // 49    Scom Error                              mask
        // 50:63 Unused                                  mask

        FAPI_TRY(fapi2::putScom(l_mc_tgt, DMI_FIR_ACTION0_REG, l_fir_action0));
        FAPI_TRY(fapi2::putScom(l_mc_tgt, DMI_FIR_ACTION1_REG, l_fir_action1));
        FAPI_TRY(fapi2::putScom(l_mc_tgt, DMI_FIR_MASK_REG, l_fir_mask));
    }

    // mark HWP exit
    FAPI_INF("p9_io_dmi_scominit: ... Exiting");

fapi_try_exit:
    return fapi2::current_err;
}
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/pm/p9_pm_occ_gpe_init.H $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
///
/// @file p9_pm_occ_gpe_init.H
/// @brief Initialize or reset the targeted GPE0 and/or GPE1
///
/// *HWP HWP Owner: Greg Still  <stillgs@us.ibm.com>
/// *HWP FW  Owner: Sangeetha T S <sangeet2@in.ibm.com>
/// *HWP Team: PM
/// *HWP Level: 2
/// *HWP Consumed by: HS
///

#ifndef _P9_PM_OCC_GPE_INIT_H
#define _P9_PM_OCC_GPE_INIT_H

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <fapi2.H>
#include <p9_pm.H>
#include <p9_misc_scom_addresses.H>

//------------------------------------------------------------------------------
// Constant definitions
//------------------------------------------------------------------------------
namespace p9occgpe
{
enum GPE_ENGINES
{
    GPE0        = 0x0,
    GPE1        = 0x1,
    GPEALL      = 0XF
};
}

//------------------------------------------------------------------------------
// Parameter structure definitions
//------------------------------------------------------------------------------

// function pointer typedef definition for HWP call support
typedef fapi2::ReturnCode (*p9_pm_occ_gpe_init_FP_t) (
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>&,
    const p9pm::PM_FLOW_MODE,
    const p9occgpe::GPE_ENGINES);

extern "C"
{

//------------------------------------------------------------------------------
// Function prototypes
//------------------------------------------------------------------------------

/// @brief Configure or reset the targeted GPE0 and/or GPE1
///
/// param[in] i_target   Chip target
/// param[in] i_mode     Control mode for the procedure (PM_INIT, PM_RESET)
/// param[in] i_engine   Targeted engine:  GPE0, GPE1, GPEALL

/// @return FAPI2_RC_SUCCESS in case of success
///         error code otherwise

    fapi2::ReturnCode
    p9_pm_occ_gpe_init(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
                       const p9pm::PM_FLOW_MODE i_mode,
                       const p9occgpe::GPE_ENGINES i_engine);
} //extern "C"
#endif // P9_PM_OCC_GPE_INIT_H
<commit_msg>Level 3: For various PM HWP<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/pm/p9_pm_occ_gpe_init.H $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
///
/// @file p9_pm_occ_gpe_init.H
/// @brief Initialize or reset the targeted GPE0 and/or GPE1
///
// *HWP HWP Owner       :   Greg Still <stillgs@us.ibm.com>
// *HWP Backup Owner    :   Prasad BG Ranganath <prasadbgr@in.ibm.com>
// *HWP FW  Owner       :   Prem S Jha <premjha2@in.ibm.com>
// *HWP Team            :   PM
// *HWP Level           :   3
// *HWP Consumed by     :   HS
//

#ifndef _P9_PM_OCC_GPE_INIT_H
#define _P9_PM_OCC_GPE_INIT_H

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <fapi2.H>
#include <p9_pm.H>
#include <p9_misc_scom_addresses.H>
#include <p9_hcd_common.H>

//------------------------------------------------------------------------------
// Constant definitions
//------------------------------------------------------------------------------
namespace p9occgpe
{
enum GPE_ENGINES
{
    GPE0        = 0x0,
    GPE1        = 0x1,
    GPEALL      = 0XF
};
}

// function pointer typedef definition for HWP call support
typedef fapi2::ReturnCode (*p9_pm_occ_gpe_init_FP_t) (
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>&,
    const p9pm::PM_FLOW_MODE,
    const p9occgpe::GPE_ENGINES);

extern "C"
{

//------------------------------------------------------------------------------
// Function prototypes
//------------------------------------------------------------------------------

/// @brief Configure or reset the targeted GPE0 and/or GPE1
///
/// param[in] i_target   Chip target
/// param[in] i_mode     Control mode for the procedure (PM_INIT, PM_RESET)
/// param[in] i_engine   Targeted engine:  GPE0, GPE1, GPEALL

/// @return FAPI2_RC_SUCCESS in case of success
///         error code otherwise

    fapi2::ReturnCode
    p9_pm_occ_gpe_init(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
                       const p9pm::PM_FLOW_MODE i_mode,
                       const p9occgpe::GPE_ENGINES i_engine);
} //extern "C"
#endif // P9_PM_OCC_GPE_INIT_H
<|endoftext|>