📄 component.h
字号:
/*
* TOPPERS/JSP Kernel
* Toyohashi Open Platform for Embedded Real-Time Systems/
* Just Standard Profile Kernel
*
* Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
* Toyohashi Univ. of Technology, JAPAN
*
* 忋婰挊嶌尃幰偼丆埲壓偺 (1)乣(4) 偺忦審偐丆Free Software Foundation
* 偵傛偭偰岞昞偝傟偰偄傞 GNU General Public License 偺 Version 2 偵婰
* 弎偝傟偰偄傞忦審傪枮偨偡応崌偵尷傝丆杮僜僼僩僂僃傾乮杮僜僼僩僂僃傾
* 傪夵曄偟偨傕偺傪娷傓丏埲壓摨偠乯傪巊梡丒暋惢丒夵曄丒嵞攝晍乮埲壓丆
* 棙梡偲屇傇乯偡傞偙偲傪柍彏偱嫋戻偡傞丏
* (1) 杮僜僼僩僂僃傾傪僜乕僗僐乕僪偺宍偱棙梡偡傞応崌偵偼丆忋婰偺挊嶌
* 尃昞帵丆偙偺棙梡忦審偍傛傃壓婰偺柍曐徹婯掕偑丆偦偺傑傑偺宍偱僜乕
* 僗僐乕僪拞偵娷傑傟偰偄傞偙偲丏
* (2) 杮僜僼僩僂僃傾傪丆儔僀僽儔儕宍幃側偳丆懠偺僜僼僩僂僃傾奐敪偵巊
* 梡偱偒傞宍偱嵞攝晍偡傞応崌偵偼丆嵞攝晍偵敽偆僪僉儏儊儞僩乮棙梡
* 幰儅僯儏傾儖側偳乯偵丆忋婰偺挊嶌尃昞帵丆偙偺棙梡忦審偍傛傃壓婰
* 偺柍曐徹婯掕傪宖嵹偡傞偙偲丏
* (3) 杮僜僼僩僂僃傾傪丆婡婍偵慻傒崬傓側偳丆懠偺僜僼僩僂僃傾奐敪偵巊
* 梡偱偒側偄宍偱嵞攝晍偡傞応崌偵偼丆師偺偄偢傟偐偺忦審傪枮偨偡偙
* 偲丏
* (a) 嵞攝晍偵敽偆僪僉儏儊儞僩乮棙梡幰儅僯儏傾儖側偳乯偵丆忋婰偺挊
* 嶌尃昞帵丆偙偺棙梡忦審偍傛傃壓婰偺柍曐徹婯掕傪宖嵹偡傞偙偲丏
* (b) 嵞攝晍偺宍懺傪丆暿偵掕傔傞曽朄偵傛偭偰丆TOPPERS僾儘僕僃僋僩偵
* 曬崘偡傞偙偲丏
* (4) 杮僜僼僩僂僃傾偺棙梡偵傛傝捈愙揑傑偨偼娫愙揑偵惗偠傞偄偐側傞懝
* 奞偐傜傕丆忋婰挊嶌尃幰偍傛傃TOPPERS僾儘僕僃僋僩傪柶愑偡傞偙偲丏
*
* 杮僜僼僩僂僃傾偼丆柍曐徹偱採嫙偝傟偰偄傞傕偺偱偁傞丏忋婰挊嶌尃幰偍
* 傛傃TOPPERS僾儘僕僃僋僩偼丆杮僜僼僩僂僃傾偵娭偟偰丆偦偺揔梡壜擻惈傕
* 娷傔偰丆偄偐側傞曐徹傕峴傢側偄丏傑偨丆杮僜僼僩僂僃傾偺棙梡偵傛傝捈
* 愙揑傑偨偼娫愙揑偵惗偠偨偄偐側傞懝奞偵娭偟偰傕丆偦偺愑擟傪晧傢側偄丏
*
* @(#) $Id: component.h,v 1.5 2003/06/30 12:50:32 takayuki Exp $
*/
// $Header: /home/CVS/configurator/base/component.h,v 1.5 2003/06/30 12:50:32 takayuki Exp $
#ifndef COMPONENT_H
#define COMPONENT_H
#ifdef _MSC_VER
#pragma warning(disable:4786)
#endif
#include <list>
#include <map>
#include <string>
#include <typeinfo>
#include "base/defs.h"
#include "base/message.h"
#include "base/directorymap.h"
#define DEFAULT_PARAMETER " "
#define FILENAME_PERSISTENTCONTAINER "settings.dat"
//------
class Component
{
public:
enum tagBarrier { EXTENSION, IGNORE_UNKNOWN_API, NO_SUPPORT };
//張棟偺幚峴弴彉
enum tagProcessStage
{
INITIALIZE, //偲偵偐偔恀偭愭偵摦偒偨偄張棟
BEFORE_PARSE, //僷乕僗慜
PARSER, //僷乕僒
AFTER_PARSE, //僷乕僗屻
PREDECESSOR, //斈梡偺慜
GENERAL_PURPOSE, //斈梡
SUCCESSOR, //斈梡偺屻
BEFORE_CODEGENERATION, //僐乕僪惗惉慜
CODEGENERATOR, //僐乕僪惗惉
AFTER_CODEGENERATION, //僐乕僪惗惉屻
FINALIZE
};
private:
static std::multimap<int,Component *> & componentList(void);
static std::list<Component *> & activatedComponentList(void);
static Directory persistentContainer;
static void loadPersistentContainer(Directory &);
static void storePersistentContainer(Directory &);
protected:
static int barrierFlag;
static std::string & bootBanner(void);
static Component * findComponent(const char *);
static bool findOption (Directory &, const char *, const char * = 0, std::string * = 0);
static bool checkOption(Directory &, const char *, const char * = 0);
static Directory * getOption (Directory &, const char *, const char * = 0, bool = true);
static Directory * mergeOption(Directory &, const char *, const char *);
static void enable(enum tagBarrier);
static void disable(enum tagBarrier);
static Directory & getPersisitentContainer(void);
static std::string getPersistentString (const std::string & key, std::string _default = "");
static int getPersistentValue (const std::string & key, int _default = 0);
static std::string setPersistentString (const std::string & key, std::string _default = "");
static int setPersistentValue (const std::string & key, int _default = 0);
static std::string updatePersistentString(const std::string & key, std::string _default = "");
static int updatePersistentValue (const std::string & key, int _default = 0);
static void dumpContainerSnapshot(Directory &, bool = false);
virtual void parseOption(Directory &) {};
virtual void body(Directory &) {};
virtual void onFatalExit(Directory &) {};
public:
Component(int order = GENERAL_PURPOSE);
virtual ~Component(void);
void activateComponent(bool = true);
static bool isEnabled(enum tagBarrier);
static void barrier(enum tagBarrier, const Message & reason);
static void parseOption(int, char **, Directory &, const char * = NULL);
static void executeComponents(Directory &);
static void fire_onFatalExit(Directory &);
};
#include <iostream>
inline void Component::enable(enum tagBarrier bf)
{ barrierFlag |= 1 << (int)bf; }
inline void Component::disable(enum tagBarrier bf)
{ barrierFlag &= ~(1 << (int)bf); }
inline bool Component::isEnabled(enum tagBarrier bf)
{ return (barrierFlag & (1 << (int)bf)) != 0; }
inline void Component::barrier(enum tagBarrier bf, const Message & reason)
{
if((barrierFlag & (1 << (int)bf)) == 0)
ExceptionMessage("The operation detailed below is not permitted.\n %\n","師偺憖嶌偼嫋壜偝傟偰偄傑偣傫\n %\n") << reason << throwException;
if(!((std::string &)reason).empty())
VerboseMessage("Configurator allows the operation below\n %\n","師偺憖嶌傪嫋壜偟傑偟偨\n %\n") << reason;
}
inline Directory & Component::getPersisitentContainer(void)
{ return persistentContainer; }
inline std::string Component::getPersistentString(const std::string & key, std::string _default)
{ return persistentContainer.findChild(key)->toString(_default); }
inline std::string Component::setPersistentString(const std::string & key, std::string value)
{
(*persistentContainer.openChild(key)) = value;
return value;
}
inline std::string Component::updatePersistentString(const std::string & key, std::string value)
{
Directory * node;
node = persistentContainer.openChild(key);
if(node->toString().compare(value) != 0)
*node = value;
return value;
}
inline int Component::getPersistentValue(const std::string & key, int _default)
{ return persistentContainer.findChild(key)->toInteger(_default); }
inline int Component::setPersistentValue(const std::string & key, int value)
{ return *persistentContainer.openChild(key) = value; }
inline int Component::updatePersistentValue(const std::string & key, int value)
{
Directory * node;
node = persistentContainer.openChild(key);
if(node->toInteger() != value)
*node = value;
return value;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -