コード例 #1
0
ファイル: body_test.cpp プロジェクト: Wavechaser/Principia
TEST_F(BodyTest, RotatingSerializationSuccess) {
  EXPECT_FALSE(rotating_body_.is_massless());
  EXPECT_FALSE(rotating_body_.is_oblate());

  serialization::Body message;
  RotatingBody<World> const* cast_rotating_body;
  rotating_body_.WriteToMessage(&message);
  EXPECT_TRUE(message.has_massive_body());
  EXPECT_FALSE(message.has_massless_body());
  EXPECT_TRUE(message.massive_body().HasExtension(
                  serialization::RotatingBody::rotating_body));
  EXPECT_EQ(17, message.massive_body().gravitational_parameter().magnitude());
  serialization::RotatingBody const rotating_body_extension =
      message.massive_body().GetExtension(
          serialization::RotatingBody::rotating_body);
  EXPECT_EQ(3, rotating_body_extension.reference_angle().magnitude());
  EXPECT_EQ(4,
            rotating_body_extension.reference_instant().scalar().magnitude());
  EXPECT_EQ(angular_velocity_,
            AngularVelocity<World>::ReadFromMessage(
                rotating_body_extension.angular_velocity()));

  // Dispatching from |MassiveBody|.
  not_null<std::unique_ptr<MassiveBody const>> const massive_body =
      MassiveBody::ReadFromMessage(message);
  EXPECT_EQ(rotating_body_.gravitational_parameter(),
            massive_body->gravitational_parameter());
  cast_rotating_body = dynamic_cast<RotatingBody<World> const*>(&*massive_body);
  EXPECT_THAT(cast_rotating_body, NotNull());
  EXPECT_EQ(rotating_body_.gravitational_parameter(),
            cast_rotating_body->gravitational_parameter());
  EXPECT_EQ(rotating_body_.angular_velocity(),
            cast_rotating_body->angular_velocity());
  EXPECT_EQ(rotating_body_.AngleAt(Instant()),
            cast_rotating_body->AngleAt(Instant()));

  // Dispatching from |Body|.
  not_null<std::unique_ptr<Body const>> const body =
      Body::ReadFromMessage(message);
  cast_rotating_body = dynamic_cast<RotatingBody<World> const*>(&*body);
  EXPECT_THAT(cast_rotating_body, NotNull());
  EXPECT_EQ(rotating_body_.gravitational_parameter(),
            cast_rotating_body->gravitational_parameter());
  EXPECT_EQ(rotating_body_.angular_velocity(),
            cast_rotating_body->angular_velocity());
  EXPECT_EQ(rotating_body_.AngleAt(Instant()),
            cast_rotating_body->AngleAt(Instant()));
}
コード例 #2
0
bool HTTPBodyParameterMapper::DoFinalGetStream(const char *key, std::ostream &os, Context &ctx) {
	StartTrace1(HTTPBodyParameterMapper.DoFinalGetStream, NotNull(key));
	bool mapSuccess = true;
	ROAnything params(ctx.Lookup(key)); //!@FIXME ??: use Get(key,any,ctx) instead?
	if (!params.IsNull()) {
		long bPSz = params.GetSize();
		String value;
		for (long i = 0; i < bPSz; ++i) {
			const char *lookupVal = params.SlotName(i);
			if (!lookupVal) {
				lookupVal = params[i].AsCharPtr("");
			}
			if (lookupVal && (mapSuccess = Get(lookupVal, value, ctx))) {
				Trace("Param[" << lookupVal << "]=<" << value << ">");
				os << lookupVal << "=" << value;
				if (i < (bPSz - 1)) {
					os << "&";
				}
			} else {
				mapSuccess = true;
				os << lookupVal;
			}
			value.clear();
		}
	} else {
		String bodyParams;
		if ((mapSuccess = Get(key, bodyParams, ctx))) {
			os << bodyParams;
		}
	}
	Trace("retval: " << mapSuccess);
	return mapSuccess;
}
コード例 #3
0
/**
 * @brief Convenience function to pass a single logical tile through an
 *        executor which has only one child.
 * @param executor Executor to pass logical tile through.
 * @param source_logical_tile Logical tile to pass through executor.
 * @param check the value of logical tiles
 *
 * @return Pointer to processed logical tile.
 */
executor::LogicalTile *ExecutorTestsUtil::ExecuteTile(
    executor::AbstractExecutor *executor,
    executor::LogicalTile *source_logical_tile) {
  MockExecutor child_executor;
  executor->AddChild(&child_executor);

  // Uneventful init...
  EXPECT_CALL(child_executor, DInit()).WillOnce(Return(true));
  EXPECT_TRUE(executor->Init());

  // Where the main work takes place...
  EXPECT_CALL(child_executor, DExecute())
      .WillOnce(Return(true))
      .WillOnce(Return(false));

  EXPECT_CALL(child_executor, GetOutput())
      .WillOnce(Return(source_logical_tile));

  EXPECT_TRUE(executor->Execute());
  std::unique_ptr<executor::LogicalTile> result_logical_tile(
      executor->GetOutput());
  EXPECT_THAT(result_logical_tile, NotNull());
  EXPECT_THAT(executor->Execute(), false);

  return result_logical_tile.release();
}
コード例 #4
0
ファイル: body_test.cpp プロジェクト: Wavechaser/Principia
  void TestRotatingBody() {
    using F = Frame<Tag, tag, true>;

    AngularVelocity<F> const angular_velocity =
        AngularVelocity<F>({-1 * Radian / Second,
                            2 * Radian / Second,
                            5 * Radian / Second});
    auto const rotating_body =
        RotatingBody<F>(17 * SIUnit<GravitationalParameter>(),
                        typename RotatingBody<F>::Parameters(
                            3 * Radian,
                            Instant() + 4 * Second,
                            angular_velocity));

    serialization::Body message;
    RotatingBody<F> const* cast_rotating_body;
    rotating_body.WriteToMessage(&message);
    EXPECT_TRUE(message.has_massive_body());
    EXPECT_FALSE(message.has_massless_body());
    EXPECT_TRUE(message.massive_body().HasExtension(
                    serialization::RotatingBody::rotating_body));

    not_null<std::unique_ptr<MassiveBody const>> const massive_body =
        MassiveBody::ReadFromMessage(message);
    EXPECT_EQ(rotating_body.gravitational_parameter(),
              massive_body->gravitational_parameter());
    cast_rotating_body = dynamic_cast<RotatingBody<F> const*>(&*massive_body);
    EXPECT_THAT(cast_rotating_body, NotNull());
  }
コード例 #5
0
double LookupInterface::Lookup(const char *key, double dflt, char delim, char indexdelim) const {
	StartTrace1(LookupInterface.LookupDouble, "key: <" << NotNull(key) << ">" << " default: " << dflt << " delim: " << delim << " indexdelim: " << indexdelim);
	ROAnything a;
	if (DoLookup(key, a, delim, indexdelim)) {
		return a.AsDouble(dflt);
	}
	return dflt;
}
bool RegExpFilterFieldsParameterMapper::interpretMapperScript(const char *key, std::ostream &os, Context &ctx, ROAnything script) {
	StartTrace1(RegExpFilterFieldsParameterMapper.interpretMapperScript, "( \"" << NotNull(key) << "\" , std::ostream &os, Context &ctx, ROAnything script)");
	ROAnything dummyResult;
	if ( ctx.Lookup(_ShortCutKey, dummyResult) ) {
		return ParameterMapper::interpretMapperScript(key, os, ctx, script);
	}
	return intInterpretMapperScript(key, os, ctx, script);
}
コード例 #7
0
		bool HTTPHeaderFieldParameterMapper::DoGetAny(const char *key, Anything &value, Context &ctx, ROAnything info) {
			StartTrace1(HTTPHeaderFieldParameterMapper.DoGetAny, "Key:<" << NotNull(key) << ">");
			String strBuf(128L);
			OStringStream osStr(strBuf);
			if (DoGetStream(key, osStr, ctx, info)) {
				osStr.flush();
				value = strBuf;
				return true;
			}
			return false;
		}
コード例 #8
0
ファイル: body_test.cpp プロジェクト: Wavechaser/Principia
TEST_F(BodyTest, OblateSerializationSuccess) {
  EXPECT_FALSE(oblate_body_.is_massless());
  EXPECT_TRUE(oblate_body_.is_oblate());

  serialization::Body message;
  OblateBody<World> const* cast_oblate_body;
  oblate_body_.WriteToMessage(&message);
  EXPECT_TRUE(message.has_massive_body());
  EXPECT_FALSE(message.has_massless_body());
  EXPECT_TRUE(message.massive_body().GetExtension(
                  serialization::RotatingBody::rotating_body).
                      HasExtension(serialization::OblateBody::oblate_body));
  EXPECT_EQ(17, message.massive_body().gravitational_parameter().magnitude());
  serialization::OblateBody const oblate_body_extension =
      message.massive_body().GetExtension(
                  serialization::RotatingBody::rotating_body).
                      GetExtension(serialization::OblateBody::oblate_body);
  EXPECT_EQ(163, oblate_body_extension.j2().magnitude());

  // Dispatching from |MassiveBody|.
  not_null<std::unique_ptr<MassiveBody const>> const massive_body =
      MassiveBody::ReadFromMessage(message);
  EXPECT_EQ(oblate_body_.gravitational_parameter(),
            massive_body->gravitational_parameter());
  cast_oblate_body = dynamic_cast<OblateBody<World> const*>(&*massive_body);
  EXPECT_THAT(cast_oblate_body, NotNull());
  EXPECT_EQ(oblate_body_.gravitational_parameter(),
            cast_oblate_body->gravitational_parameter());
  EXPECT_EQ(oblate_body_.j2(), cast_oblate_body->j2());
  EXPECT_EQ(oblate_body_.axis(), cast_oblate_body->axis());

  // Dispatching from |Body|.
  not_null<std::unique_ptr<Body const>> const body =
      Body::ReadFromMessage(message);
  cast_oblate_body = dynamic_cast<OblateBody<World> const*>(&*body);
  EXPECT_THAT(cast_oblate_body, NotNull());
  EXPECT_EQ(oblate_body_.gravitational_parameter(),
            cast_oblate_body->gravitational_parameter());
  EXPECT_EQ(oblate_body_.j2(), cast_oblate_body->j2());
  EXPECT_EQ(oblate_body_.axis(), cast_oblate_body->axis());
}
コード例 #9
0
bool HierarchyInstaller::InstallRoot(HierarchConfNamed *root, const char *name) {
	StartTrace1(HierarchyInstaller.InstallRoot, "root [" << NotNull(name) << "]" << (root ? "" : " is null!"));
	if (root) {
		// AB: don't create cycles in inheritance tree
		if (HasSuper(root->GetSuper(), name)) {
			Trace("");
			return false;
		}
		return true;
	}
	return false;
}
bool RegExpFilterFieldsParameterMapper::getValueWithSlotname(const char *key, String const &strSlotname, Context & ctx, ValueType & value,
		ROAnything script) {
	StartTrace1(RegExpFilterFieldsParameterMapper.getValueWithSlotname, "key [" << NotNull(key) << "] slotname [" << strSlotname << "]");
	String strNewKey = key;
	if (Lookup(_CombineKeyName, 1L) != 0) {
		strNewKey.Append(getDelim()).Append(strSlotname);
	}
	Anything slotnameBuffer = strSlotname, combinedKeyBuffer = strNewKey;
	Context::PushPopEntry<Anything> aSlotnameEntry(ctx, "CurrentSlotname", slotnameBuffer, _CurrentSlotname);
	Context::PushPopEntry<Anything> aCombinedEntry(ctx, "CombinedKey", combinedKeyBuffer, _CombinedKeyName);
	return doGetValue(strNewKey, value, ctx, script);
}
コード例 #11
0
bool AnythingLookupPathResultMapper::DoPutAnyWithSlotname(const char *key, Anything &value, Context &ctx, ROAnything roaScript, const char *slotname)
{
	StartTrace1(AnythingLookupPathResultMapper.DoPutAnyWithSlotname, "key [" << NotNull(key) << "] slotname [" << NotNull(slotname) << "]");
	Trace("Using slotname [" << slotname << "] as Lookup path in value");
	bool bRet = true;	// do not fail when lookup fails!
	Anything anyValue;
	if ( value.LookupPath(anyValue, slotname) ) {
		TraceAny(anyValue, "Calling myself again with Anything looked up at [" << slotname << "]");
		bRet = DoPutAny(key, anyValue, ctx, roaScript);
		Trace("RetCode of DoPutAny:" << (bRet ? "true" : "false"));
	}
	return bRet;
}
コード例 #12
0
void ConfiguredActionTest::DoTest(Anything testCase, const char *testCaseName, Context &ctx) {
	StartTrace1(ConfiguredActionTest.DoTest, "<" << NotNull(testCaseName) << ">");

	DoTestWithContext(testCase, testCaseName, ctx);
	// do existence tests
	Anything anyFailureStrings;
	coast::testframework::CheckStores(anyFailureStrings, testCase["Result"], ctx, testCaseName, coast::testframework::exists);
	// non-existence tests
	coast::testframework::CheckStores(anyFailureStrings, testCase["NotResult"], ctx, testCaseName, coast::testframework::notExists);
	for (long sz = anyFailureStrings.GetSize(), i = 0; i < sz; ++i) {
		t_assertm(false, anyFailureStrings[i].AsString().cstr());
	}
}
コード例 #13
0
		bool HTTPHeaderFieldParameterMapper::DoGetStream(const char *key, std::ostream &os, Context &ctx, ROAnything info) {
			StartTrace1(HTTPHeaderFieldParameterMapper.DoGetStream, "Key:<" << NotNull(key) << ">");
			Anything fieldValues;
			//! break potential loop here when our own DoGetAny is calling us
			ParameterMapper::DoGetAny(key, fieldValues, ctx, SelectScript(key, fConfig, ctx));
			String potentiallyCombinedKey = key;
			TraceAny(fieldValues, "field values available for full key [" << potentiallyCombinedKey << "]");
			String headerFieldName = potentiallyCombinedKey.SubString(potentiallyCombinedKey.StrRChr(getDelim()) + 1).ToUpper();
			Trace("field name only [" << headerFieldName << "]");
			if (!fieldValues.IsNull()) {
				coast::http::putHeaderFieldToStream(os, ctx, headerFieldName, fieldValues);
			}
			return true;
		}
bool RegExpFilterFieldsParameterMapper::intInterpretMapperScript(const char *key, ValueType &value, Context &ctx, ROAnything script) {
	StartTrace1(RegExpFilterFieldsParameterMapper.intInterpretMapperScript, "( \"" << NotNull(key) << "\" , ValueType &value, Context &ctx, ROAnything script)");
	Anything availableContent;
	if ( not DoFinalGetAny(key, availableContent, ctx) ) {
		return false;
	}
	Context::PushPopEntry<Anything> aSlotnameEntry(ctx, "ShortCutEntry", availableContent, _ShortCutKey);
	bool retval = true;
	// iterate over list of regular expressions specified in the slotname
	for (long i = 0, sz = script.GetSize(); retval && i < sz; ++i) {
		retval = getValueWithSlotnameCommon(key, script.SlotName(i), ctx, value, script[i], availableContent);
	}
	return retval;
}
コード例 #15
0
bool CgiParams::DoGetAny(const char *key, Anything &value, Context &ctx, ROAnything config) {
	StartTrace1(CgiParams.DoGetAny, "( \"" << NotNull(key) << "\" , Anything &value, Context &ctx, const ROAnything &config)");
	String k(key); // for easier comparison
	if (k == "cgienv") {
		Trace("key found");
		SynthesizeMinimalCGIEnvironment(value, ctx);
		AddToEnvironment(ctx, value, ctx.Lookup("cgienv"));
		AddToEnvironment(ctx, value, Lookup("cgienv")); //!@FIXME double entry with next one?
		AddToEnvironment(ctx, value, config["cgienv"]); // already discriminated when scripted
		return true;
	}
	Trace("unknown key [" << key << "] using ParamterMapper::DoGetAny(key, value, ctx, config)");
	return URI2FileNameMapper::DoGetAny(key, value, ctx, config);
}
コード例 #16
0
bool CgiParams::DoGetStream(const char *key, std::ostream &os, Context &ctx, ROAnything config) {
	StartTrace1(CgiParams.DoGetStream, "( \"" << NotNull(key) << "\" , ostream &os, Context &ctx, const ROAnything &config)");
	String k(key); // for easier comparison
	if (k == "stdin") {
		Trace("key found");
		//!@FIXME should use Get("WHOLE_REQUEST_BODY",body,ctx);
		String body = ctx.Lookup("WHOLE_REQUEST_BODY").AsString("");
		if (body.Length() > 0) {
			os << body;
			Trace("Written request body of length: " << body.Length());
		}
		return true;
	}
	Trace("unknown key [" << key << "] using URI2FileNameMapper::DoGetStream(key, os, ctx, config)");
	return URI2FileNameMapper::DoGetStream(key, os, ctx, config);
}
コード例 #17
0
// "Pass-through" test case. There is nothing to materialize as
// there is only one base tile in the logical tile.
TEST_F(MaterializationTests, SingleBaseTileTest) {
  const int tuple_count = 9;
  std::shared_ptr<storage::TileGroup> tile_group(
      ExecutorTestsUtil::CreateTileGroup(tuple_count));

  ExecutorTestsUtil::PopulateTiles(tile_group, tuple_count);

  // Create logical tile from single base tile.
  auto source_base_tile = tile_group->GetTileReference(0);

  // Add a reference because we are going to wrap around it and we don't own it
  std::unique_ptr<executor::LogicalTile> source_logical_tile(
      executor::LogicalTileFactory::WrapTiles({source_base_tile}));

  // Pass through materialization executor.
  executor::MaterializationExecutor executor(nullptr, nullptr);
  std::unique_ptr<executor::LogicalTile> result_logical_tile(
      ExecutorTestsUtil::ExecuteTile(&executor, source_logical_tile.release()));

  // Verify that logical tile is only made up of a single base tile.
  int num_cols = result_logical_tile->GetColumnCount();
  EXPECT_EQ(2, num_cols);
  storage::Tile *result_base_tile = result_logical_tile->GetBaseTile(0);
  EXPECT_THAT(result_base_tile, NotNull());
  EXPECT_TRUE(source_base_tile.get() == result_base_tile);
  EXPECT_EQ(result_logical_tile->GetBaseTile(1), result_base_tile);

  // Check that the base tile has the correct values.
  for (int i = 0; i < tuple_count; i++) {
    type::Value val0 = (result_base_tile->GetValue(i, 0));
    type::Value val1 = (result_base_tile->GetValue(i, 1));
    type::CmpBool cmp = (val0.CompareEquals(
      type::ValueFactory::GetIntegerValue(ExecutorTestsUtil::PopulatedValue(i, 0))));
    EXPECT_TRUE(cmp == type::CMP_TRUE);
    cmp = val1.CompareEquals(type::ValueFactory::GetIntegerValue(
        ExecutorTestsUtil::PopulatedValue(i, 1)));
    EXPECT_TRUE(cmp == type::CMP_TRUE);

    // Double check that logical tile is functioning.
    type::Value logic_val0 = (result_logical_tile->GetValue(i, 0));
    type::Value logic_val1 = (result_logical_tile->GetValue(i, 1));
    cmp = (logic_val0.CompareEquals(val0));
    EXPECT_TRUE(cmp == type::CMP_TRUE);
    cmp = (logic_val1.CompareEquals(val1));
    EXPECT_TRUE(cmp == type::CMP_TRUE);
  }
}
コード例 #18
0
ファイル: invoicelist.cpp プロジェクト: jkusniar/tara
bool InvoiceList::prepare()
{
	String sqlStatement = "select r.invoice_id, r.inv_create_date, \
					(select sum(ri.item_price) from record_item ri where ri.record_id = r.id) \
					from record r \
					where r.invoice_id is not null and r.inv_create_date between '"
					 + AsString(from) + "' and '" + AsString(to) 
					 + "' order by r.inv_create_date, r.invoice_id";
	SQL.Execute(sqlStatement);
	
	bool found = false;
	while (SQL.Fetch()) {
		found = true;
		
		VectorMap<int, String> vmap;
		vmap.Add(iliInvNum, AsString(SQL[0]));
		vmap.Add(iliDate, AsString(SQL[1]));
		vmap.Add(iliTotal, fixFuckedLinuxFormating(ConvertMoney().Format(SQL[2])));
		inv_list_items.Add(vmap);
	}
	if (!found) return false;
	
	SQL & Select(SqlSum(ITEM_PRICE.Of(RECORD_ITEM))).From(RECORD_ITEM)
		.InnerJoin(RECORD).On(RECORD_ID.Of(RECORD_ITEM) == ID.Of(RECORD))
		.Where(NotNull(INVOICE_ID.Of(RECORD)) && (Between(INV_CREATE_DATE.Of(RECORD), from, to)));
	if (SQL.Fetch())
		summary_price = SQL[0];	
	
	invoiceList.Clear();
	invoiceList.Header(String("[A0> ") + String(t_("Page")) + String(" $$P"));
	
	StringBuffer buf;
	
	buf.Cat("{{1f4 ");
	formatHeader(buf);
	buf.Cat(":: ");
	formatCompanyData(buf);
	buf.Cat(":: ");
	formatItems(buf);
	buf.Cat("}}");
	
	LOG(~buf);
	invoiceList << ~buf;

	return true;
}
コード例 #19
0
bool LocalizationModule::Init(const ROAnything config)
{
	StartTrace(LocalizationModule.Init);
	// add localized strings
	if (config.IsDefined("StringFile")) {
		Trace("loading StringFile [" << NotNull(config["StringFile"].AsCharPtr()) << "]");
		if (!ReadFromFile(fLocalizedStrings, config["StringFile"].AsCharPtr())) {
			return false;
		}
	}
	LocalizedStrings *theHandle = LocalizedStrings::LocStr();
	Assert(theHandle);
	if (theHandle) {
		theHandle->fLocalizedStrings = fLocalizedStrings;
	}
	return 0 != theHandle;
}
コード例 #20
0
bool StreamToAnythingMapper::DoPutStream(const char *key, std::istream &is, Context &ctx, ROAnything script)
{
	StartTrace1(StreamToAnythingMapper.DoPutStream, NotNull(key));
	Anything anyResult;
	bool importok;
	{
		DAAccessTimer(StreamToAnythingMapper.DoPutStream, "importing from stream", ctx);
		importok = anyResult.Import(is);
	}
	if ( importok ) {
		TraceAny(anyResult, "anything imported from stream:");
		importok = DoPutAny(key, anyResult, ctx, script);
	} else {
		SYSWARNING("importing Anything from stream failed!");
	}
	return importok;
}
コード例 #21
0
bool AnythingToStreamMapper::DoFinalGetStream(const char *key, std::ostream &os, Context &ctx)
{
	StartTrace1(AnythingToStreamMapper.DoFinalGetStream, NotNull(key));
	if ( key ) {
		// use the superclass mapper to get the anything
		Anything anyValue;
		DoFinalGetAny(key, anyValue, ctx);

		TraceAny(anyValue, "value fetched from context");

		if ( !anyValue.IsNull() ) {
			DAAccessTimer(AnythingToStreamMapper.DoFinalGetStream, "exporting to stream", ctx);
			os << anyValue << std::flush;
			TraceAny(anyValue, "written to stream:");
			return true;
		}
		Trace("Nothing written to stream, value was null.");
	}
	return false;
}
コード例 #22
0
ファイル: body_test.cpp プロジェクト: fordream/Principia
TEST_F(BodyTest, MasslessSerializationSuccess) {
    EXPECT_TRUE(massless_body_.is_massless());
    EXPECT_FALSE(massless_body_.is_oblate());

    serialization::Body message;
    MasslessBody const* cast_massless_body;
    massless_body_.WriteToMessage(&message);
    EXPECT_TRUE(message.has_massless_body());
    EXPECT_FALSE(message.has_massive_body());

    // Direct deserialization.
    // No members to test in this class, we just check that it doesn't crash.
    massless_body_ = *MasslessBody::ReadFromMessage(message);

    // Dispatching from |Body|.  Need two steps to add const and remove
    // |not_null|.
    std::unique_ptr<Body const> const body =
        not_null<std::unique_ptr<Body const>>(Body::ReadFromMessage(message));
    cast_massless_body = dynamic_cast<MasslessBody const*>(body.get());
    EXPECT_THAT(cast_massless_body, NotNull());
}
コード例 #23
0
ファイル: LevelConfig.cpp プロジェクト: danigomez/TestGame
LevelConfig::LevelConfig(std::string fileName)
{
    initialize(fileName);

    CCLOG("LevelConfig:: Parsing level file.");

    rapidxml::xml_node<>* levelRoot = this->_doc.first_node("level-config");

	this->_transitionName = NotNull(levelRoot->first_attribute("transition-to"));
	
	CCLOG("LevelConfig:: Generating BackgroundDescriptor...");
	rapidxml::xml_node<>* background = NotNullTag(levelRoot->first_node("background"));
    this->_back = new BackgroundDescriptor(background);
	
	CCLOG("LevelConfig:: Generating ElementsDescriptor...");
	rapidxml::xml_node<>* elements = NotNullTag(levelRoot->first_node("elements"));
    this->_elems = new ElementsDescriptor(elements);

     CCLOG("LevelConfig:: Level parsed successfully.");

}
コード例 #24
0
bool HierarchyInstaller::HasSuper(const HierarchConfNamed *super, const char *name) const {
	StartTrace1(HierarchyInstaller.HasSuper, "name [" << NotNull(name) << "] addr:" << (long)super);
	if (!name) {
		return false;
	}

	// get the name
	String superName;

	// check for equal names in the parent relationship
	while (super) {
		super->GetName(superName);
		Trace("current class is [" << superName << "] addr:" << (long)super);
		if (superName == name) {
			Trace("super class found with same name");
			return true;
		}
		super = super->GetSuper();
		Trace("next super-class is [" << (super ? super->GetName() : "<null>") << "] addr:" << (long)super);
	}
	return false;
}
コード例 #25
0
bool HTTPHeaderParameterMapper::DoGetStream(const char *key, std::ostream &os, Context &ctx, ROAnything info) {
	StartTrace1(HTTPHeaderParameterMapper.DoGetStream, "Key:<" << NotNull(key) << ">");
	bool mapSuccess = true;
	ROAnything headerfields(ctx.Lookup(key));
	TraceAny(headerfields, "Headerfields available for key " << key);
	if (!headerfields.IsNull()) {
		String strFieldName;
		ROAnything roaValue;
		AnyExtensions::Iterator<ROAnything> headerIterator(headerfields);
		while (headerIterator.Next(roaValue)) {
			if (headerIterator.SlotName(strFieldName)) {
				strFieldName.ToUpper();
				String strKey(constants::suppressName);
				strKey.Append('.').Append(strFieldName);
				Trace("trying to Lookup [" << strKey << "] in own or config");
				// map non suppressed headerfields
				if (Lookup(strKey).AsLong(0L) == 0L) {
					Anything value;
					ROAnything rvalue;
					Trace("slot: " << strFieldName);
					if (!Get(strFieldName, value, ctx)) {
						rvalue = roaValue;
					} else {
						rvalue = value;
					}
					coast::http::putHeaderFieldToStream(os, ctx, strFieldName, rvalue);
				}
			}
		}
	} else {
		TraceAny(ctx.GetTmpStore(), "no headers, get ReqHeader in tmp store:");
		String strHeaderfields;
		if ((mapSuccess = Get("ReqHeader", strHeaderfields, ctx))) {
			os << strHeaderfields;
		}
	}
	Trace("retval: " << mapSuccess);
	return mapSuccess;
}
コード例 #26
0
ファイル: body_test.cpp プロジェクト: Wavechaser/Principia
// The best serialization revenge.
TEST_F(BodyTest, MassiveSerializationSuccess) {
  EXPECT_FALSE(massive_body_.is_massless());
  EXPECT_FALSE(massive_body_.is_oblate());

  serialization::Body message;
  MassiveBody const* cast_massive_body;
  massive_body_.WriteToMessage(&message);
  EXPECT_TRUE(message.has_massive_body());
  EXPECT_FALSE(message.has_massless_body());
  EXPECT_EQ(42, message.massive_body().gravitational_parameter().magnitude());

  // Direct deserialization.
  MassiveBody const massive_body = *MassiveBody::ReadFromMessage(message);
  EXPECT_EQ(massive_body_.gravitational_parameter(),
            massive_body.gravitational_parameter());

  // Dispatching from |Body|.
  not_null<std::unique_ptr<Body>> body = Body::ReadFromMessage(message);
  cast_massive_body = dynamic_cast<MassiveBody*>(&*body);
  EXPECT_THAT(cast_massive_body, NotNull());
  EXPECT_EQ(massive_body_.gravitational_parameter(),
            cast_massive_body->gravitational_parameter());
}
コード例 #27
0
bool NullParameterMapper::DoGetAny(const char *key, Anything &value, Context &ctx, ROAnything script) {
	StartTrace1(NullParameterMapper.DoGetAny, NotNull(key));
	if (ParameterMapper::DoGetAny(key, value, ctx, script)) {
		Trace("value before replacement [" << (value.IsNull()?String("*"):value.AsString()) << "]");
		ROAnything roaTreatAsNullValues = Lookup("TreatAsNull");
		if (!value.IsNull() && !roaTreatAsNullValues.IsNull()) {
			ROAnything roaTestValue;
			AnyExtensions::Iterator<ROAnything> nullValIterator(roaTreatAsNullValues);
			while (nullValIterator.Next(roaTestValue)) {
				Trace("testing against listvalue [" << roaTestValue.AsString() << "]");
				if (roaTestValue.IsEqual(value)) {
					Trace("value matched in list [" << value.AsString() << "]");
					value = Anything(value.GetAllocator());
					break;
				}
			}
		}
		Trace("returning true and value [" << (value.IsNull()?String("*"):value.AsString()) << "]");
		return true;
	}
	Trace("returning false and value [" << (value.IsNull()?String("*"):value.AsString()) << "]");
	return false;
}
コード例 #28
0
ファイル: body_test.cpp プロジェクト: Wavechaser/Principia
TEST_F(BodyTest, MasslessSerializationSuccess) {
  EXPECT_TRUE(massless_body_.is_massless());
  EXPECT_FALSE(massless_body_.is_oblate());

  serialization::Body message;
  MasslessBody const* cast_massless_body;
  massless_body_.WriteToMessage(&message);
  EXPECT_TRUE(message.has_massless_body());
  EXPECT_FALSE(message.has_massive_body());

  // Direct deserialization.
  // No members to test in this class, we just check that it doesn't crash.
  massless_body_ = *MasslessBody::ReadFromMessage(message);

  // Dispatching from |Body|.
  not_null<std::unique_ptr<Body const>> const body =
      Body::ReadFromMessage(message);
  // NOTE(egg): The &* is a quick way to explicitly forget |not_null|ness. We
  // cannot strip the |not_null| from the previous line because MSVC does not
  // support move conversion at the moment.
  cast_massless_body = dynamic_cast<MasslessBody const*>(&*body);
  EXPECT_THAT(cast_massless_body, NotNull());
}
コード例 #29
0
void ExecuteTileGroupTest() {
  const int tuples_per_tilegroup_count = 10;
  const int tile_group_count = 5;
  const int tuple_count = tuples_per_tilegroup_count * tile_group_count;
  const oid_t col_count = 250;
  const bool is_inlined = true;
  const bool indexes = false;

  std::vector<catalog::Column> columns;

  for (oid_t col_itr = 0; col_itr <= col_count; col_itr++) {
    auto column =
        catalog::Column(VALUE_TYPE_INTEGER, GetTypeSize(VALUE_TYPE_INTEGER),
                        "FIELD" + std::to_string(col_itr), is_inlined);

    columns.push_back(column);
  }

  catalog::Schema *table_schema = new catalog::Schema(columns);
  std::string table_name("TEST_TABLE");

  /////////////////////////////////////////////////////////
  // Create table.
  /////////////////////////////////////////////////////////

  bool own_schema = true;
  bool adapt_table = true;
  std::unique_ptr<storage::DataTable> table(storage::TableFactory::GetDataTable(
      INVALID_OID, INVALID_OID, table_schema, table_name,
      tuples_per_tilegroup_count, own_schema, adapt_table));

  // PRIMARY INDEX
  if (indexes == true) {
    std::vector<oid_t> key_attrs;

    auto tuple_schema = table->GetSchema();
    catalog::Schema *key_schema;
    index::IndexMetadata *index_metadata;
    bool unique;

    key_attrs = {0};
    key_schema = catalog::Schema::CopySchema(tuple_schema, key_attrs);
    key_schema->SetIndexedColumns(key_attrs);

    unique = true;

    index_metadata = new index::IndexMetadata(
        "primary_index", 123, INDEX_TYPE_BTREE,
        INDEX_CONSTRAINT_TYPE_PRIMARY_KEY, tuple_schema, key_schema, unique);

    index::Index *pkey_index = index::IndexFactory::GetInstance(index_metadata);
    table->AddIndex(pkey_index);
  }

  /////////////////////////////////////////////////////////
  // Load in the data
  /////////////////////////////////////////////////////////

  // Insert tuples into tile_group.
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
  const bool allocate = true;
  auto txn = txn_manager.BeginTransaction();
  auto testing_pool = TestingHarness::GetInstance().GetTestingPool();

  for (int rowid = 0; rowid < tuple_count; rowid++) {
    int populate_value = rowid;

    storage::Tuple tuple(table_schema, allocate);

    for (oid_t col_itr = 0; col_itr <= col_count; col_itr++) {
      auto value = ValueFactory::GetIntegerValue(populate_value + col_itr);
      tuple.SetValue(col_itr, value, testing_pool);
    }

    ItemPointer tuple_slot_id = table->InsertTuple(&tuple);
    EXPECT_TRUE(tuple_slot_id.block != INVALID_OID);
    EXPECT_TRUE(tuple_slot_id.offset != INVALID_OID);
    txn_manager.PerformInsert(tuple_slot_id.block, tuple_slot_id.offset);
  }

  txn_manager.CommitTransaction();

  /////////////////////////////////////////////////////////
  // Do a seq scan with predicate on top of the table
  /////////////////////////////////////////////////////////

  txn = txn_manager.BeginTransaction();
  std::unique_ptr<executor::ExecutorContext> context(
      new executor::ExecutorContext(txn));

  // Column ids to be added to logical tile after scan.
  // std::vector<oid_t> column_ids;
  // for(oid_t col_itr = 0 ; col_itr <= 200; col_itr++) {
  //  column_ids.push_back(col_itr);
  //}
  std::vector<oid_t> column_ids({198, 206});

  // Create and set up seq scan executor
  planner::SeqScanPlan seq_scan_node(table.get(), nullptr, column_ids);
  int expected_num_tiles = tile_group_count;

  executor::SeqScanExecutor seq_scan_executor(&seq_scan_node, context.get());

  // Create and set up materialization executor
  std::vector<catalog::Column> output_columns;
  std::unordered_map<oid_t, oid_t> old_to_new_cols;
  oid_t col_itr = 0;
  for (auto column_id : column_ids) {
    auto column =
        catalog::Column(VALUE_TYPE_INTEGER, GetTypeSize(VALUE_TYPE_INTEGER),
                        "FIELD" + std::to_string(column_id), is_inlined);
    output_columns.push_back(column);

    old_to_new_cols[col_itr] = col_itr;
    col_itr++;
  }

  std::unique_ptr<catalog::Schema> output_schema(
      new catalog::Schema(output_columns));
  bool physify_flag = true;  // is going to create a physical tile
  planner::MaterializationPlan mat_node(old_to_new_cols,
                                        output_schema.release(), physify_flag);

  executor::MaterializationExecutor mat_executor(&mat_node, nullptr);
  mat_executor.AddChild(&seq_scan_executor);

  EXPECT_TRUE(mat_executor.Init());

  std::vector<std::unique_ptr<executor::LogicalTile>> result_tiles;
  for (int i = 0; i < expected_num_tiles; i++) {
    EXPECT_TRUE(mat_executor.Execute());
    std::unique_ptr<executor::LogicalTile> result_tile(
        mat_executor.GetOutput());
    EXPECT_THAT(result_tile, NotNull());
    result_tiles.emplace_back(result_tile.release());
  }

  EXPECT_FALSE(mat_executor.Execute());

  txn_manager.CommitTransaction();
}
コード例 #30
0
ファイル: XMLElement.cpp プロジェクト: rokups/Urho3D
XMLElement::operator bool() const
{
    return NotNull();
}