Example #1
0
	TQmParam(const TStr& FNm) {
		EAssertR(TFile::Exists(FNm), "Missing configuration file " + FNm);
		// load configuration file
		PJsonVal ConfigVal = TJsonVal::GetValFromSIn(TFIn::New(FNm));
		EAssertR(ConfigVal->IsObj(), "Invalid setting file - not valid JSON");
		// parse out common stuff
		RootFPath = TStr::GetNrFPath(ConfigVal->GetObjStr("directory", TDir::GetCurDir()));
		LockFNm = RootFPath + "./lock";
		DbFPath = ConfigVal->GetObjStr("database", "./db/");
		PortN = TFlt::Round(ConfigVal->GetObjNum("port"));
		// parse out unicode definition file
		TStr UnicodeFNm = ConfigVal->GetObjStr("unicode", TQm::TEnv::QMinerFPath + "./UnicodeDef.Bin");
		if (!TUnicodeDef::IsDef()) { TUnicodeDef::Load(UnicodeFNm); }

		// parse cache
		if (ConfigVal->IsObjKey("cache")) { 
			PJsonVal CacheVal = ConfigVal->GetObjKey("cache");
			// parse out index and default store cache sizes
			IndexCacheSize = int64(CacheVal->GetObjNum("index", 1024)) * int64(TInt::Mega);
			DefStoreCacheSize = int64(CacheVal->GetObjNum("store", 1024)) * int64(TInt::Mega);
			// prase out store specific sizes, when available
			if (CacheVal->IsObjKey("stores")) {
				PJsonVal StoreCacheVals = CacheVal->GetObjKey("stores");
				for (int StoreN = 0; StoreN < StoreCacheVals->GetArrVals(); StoreN++) {
					PJsonVal StoreCacheVal = StoreCacheVals->GetArrVal(StoreN);					
					TStr StoreName = StoreCacheVal->GetObjStr("name");
					uint64 StoreCacheSize = int64(StoreCacheVal->GetObjNum("size")) * int64(TInt::Mega);
					StoreNmCacheSizeH.AddDat(StoreName, StoreCacheSize);
				}
			}
		} else {
			// default sizes are set to 1GB for index and stores			
			IndexCacheSize = int64(1024) * int64(TInt::Mega);
			DefStoreCacheSize = int64(1024) * int64(TInt::Mega);
		}

		// load scripts
		if (ConfigVal->IsObjKey("script")) {
			// we have configuration file, read it
			PJsonVal JsVals = ConfigVal->GetObjKey("script");
			if (JsVals->IsArr()) {
				for (int JsValN = 0; JsValN < JsVals->GetArrVals(); JsValN++) {
					JsParamV.Add(TJsParam(RootFPath, JsVals->GetArrVal(JsValN)));
				}
			} else {
				JsParamV.Add(TJsParam(RootFPath, JsVals));
			}
		} else {
			// no settings for scripts, assume default setting
			TStr SrcFPath = TStr::GetNrAbsFPath("src", RootFPath);
			TFFile File(SrcFPath, ".js", false); TStr SrcFNm;
			while (File.Next(SrcFNm)) {
				JsParamV.Add(TJsParam(RootFPath, SrcFNm));
			}
		}

		// load serving folders
		//TODO: Add to qm config ability to edit this
		if (ConfigVal->IsObjKey("wwwroot")) {
			PJsonVal WwwVals = ConfigVal->GetObjKey("wwwroot");
			if (WwwVals->IsArr()) {
				for (int WwwValN = 0; WwwValN < WwwVals->GetArrVals(); WwwValN++) {
					AddWwwRoot(WwwVals->GetArrVal(WwwValN));
				}
			} else {
				AddWwwRoot(WwwVals);
			}			
		}
		// check for folder with admin GUI
		TStr GuiFPath = TStr::GetNrAbsFPath("gui", TQm::TEnv::QMinerFPath);
		if (TDir::Exists(GuiFPath)) {
			WwwRootV.Add(TStrPr("admin", GuiFPath));
		}
        // check for any default wwwroot
        TStr DefaultWwwRootFPath = TStr::GetNrAbsFPath("www", RootFPath);
        if (TDir::Exists(DefaultWwwRootFPath)) {
            WwwRootV.Add(TStrPr("www", DefaultWwwRootFPath));
        }
	}
Example #2
0
File: exp.cpp Project: Accio/snap
void TExp::GetBiDescV(TStrPrV& BiDescV){
  BiDescV.Clr();
  // constants
  BiDescV.Add(TStrPr("True", "Logical 'True' == 1."));
  BiDescV.Add(TStrPr("False", "Logical 'False' == 0."));
  BiDescV.Add(TStrPr("E", "Nat. logarithm basis (2.7182...)."));
  BiDescV.Add(TStrPr("Pi", "Constant pi (3.1415...)."));

  // trigonometric funcions
  BiDescV.Add(TStrPr("Sin(X)", "Sine of angle in radians."));
  BiDescV.Add(TStrPr("Cos(X)", "Cosine of angle in radians."));
  BiDescV.Add(TStrPr("Tan(X)", "Tangent of angle in radians."));
  BiDescV.Add(TStrPr("ASin(X)", "Arc sine of (-1..+1)."));
  BiDescV.Add(TStrPr("ACos(X)", "Arc cosine of (-1..+1)."));
  BiDescV.Add(TStrPr("ATan(X)", "Arc tangent of (-inf..+inf)."));
  BiDescV.Add(TStrPr("SinH(X)", "Hyperbolic sine."));
  BiDescV.Add(TStrPr("CosH(X)", "Hyperbolic cosine."));
  BiDescV.Add(TStrPr("TanH(X)", "Hyperbolic tangent."));

  // exponential functions
  BiDescV.Add(TStrPr("Pow(X, Y)", "X to the power of Y."));
  BiDescV.Add(TStrPr("Exp(X)", "Exponential E to the power of X."));
  BiDescV.Add(TStrPr("Sqr(X)", "X squared."));
  BiDescV.Add(TStrPr("Sqrt(X)", "Positive square root."));
  BiDescV.Add(TStrPr("Log(X)", "Natural logarithm."));
  BiDescV.Add(TStrPr("Log10(X)", "Base 10 logarithm."));

  // number manipulation functions
  BiDescV.Add(TStrPr("Ceil(X)", "The smallest integer not less than X."));
  BiDescV.Add(TStrPr("Floor(X)", "The largest integer not greater than X."));
  BiDescV.Add(TStrPr("Int(X)", "Integer part of X."));
  BiDescV.Add(TStrPr("Frac(X)", "Fractional part of X."));
  BiDescV.Add(TStrPr("Abs(X)", "Absolute value of X."));

  // random deviates
  BiDescV.Add(TStrPr("UniDev()", "Uniform deviate (0..1)."));
  BiDescV.Add(TStrPr("NrmDev()", "Normal deviate (0, 1)."));
  BiDescV.Add(TStrPr("ExpDev()", "Exponential deviate."));
  BiDescV.Add(TStrPr("GamDev(Order)", "Gamma deviate of Order."));
  BiDescV.Add(TStrPr("PoiDev(Mean)", "Poisson deviate."));
  BiDescV.Add(TStrPr("BinDev(Prb, Trials)", "Binomial deviate."));

  // operators
  BiDescV.Add(TStrPr("+N", "Unary plus."));
  BiDescV.Add(TStrPr("-N", "Unary minus."));
  BiDescV.Add(TStrPr("!L", "Not."));
  BiDescV.Add(TStrPr("N1+N2", "Plus."));
  BiDescV.Add(TStrPr("N1-N2", "Minus."));
  BiDescV.Add(TStrPr("N1*N2", "Multiply."));
  BiDescV.Add(TStrPr("N1/N2", "Division."));
  BiDescV.Add(TStrPr("N1#N2", "Integer division."));
  BiDescV.Add(TStrPr("N1%N2", "Modulo."));
  BiDescV.Add(TStrPr("L1&L2", "And."));
  BiDescV.Add(TStrPr("L1|L2", "Or."));
  BiDescV.Add(TStrPr("E1=E2", "Equal."));
  BiDescV.Add(TStrPr("E1<>E2", "Not equal."));
  BiDescV.Add(TStrPr("E1<E2", "Less."));
  BiDescV.Add(TStrPr("E1>E2", "Greater."));
  BiDescV.Add(TStrPr("E1<=E2", "Less or equal."));
  BiDescV.Add(TStrPr("E1>=E2", "Greater or equal."));
  BiDescV.Add(TStrPr("L?E1:E2", "If L then return E1 else return E2."));
}
Example #3
0
	void AddWwwRoot(const PJsonVal& WwwVal) {
		WwwRootV.Add(TStrPr(WwwVal->GetObjStr("name"), 
			TStr::GetNrAbsFPath(WwwVal->GetObjStr("path"), RootFPath)));
	}