Esempio n. 1
0
/* If the si is negative, set the homeworld to our best shot at a system path
    pointing to a valid system, close to passed co-ordinates.

   Otherwise trust the caller, and just set the system path for the co-ordinates.

   Used by the Lua interface, to support autogenerated factions.
*/
void Faction::SetBestFitHomeworld(Sint32 x, Sint32 y, Sint32 z, Sint32 si, Uint32 bi, Sint32 axisChange)
{
	// search for a home system until we either find one sutiable, hit one of the axes,
	// or hit the edge of inhabited space
	Uint32 i = 0;
	RefCountedPtr<StarSystem> sys;
	while (si < 0 && (abs(x) != 90 && abs(y) != 90 && abs(z) != 90)
		          && (    x  != 0  &&     y  !=  0 &&     z  != 0 )) {

		// search for a suitable homeworld in the current sector
		Sector sec(x,y,z);
		Uint32 candidateSi = 0;
		while (candidateSi < sec.m_systems.size()) {
			sys = StarSystem::GetCached(SystemPath(x,y,z,candidateSi));
			if (sys->m_spaceStations.size() > 0) { 
				si = Sint32(candidateSi); 
				break;
			}
			candidateSi++;
		}

		// set the co-ordinates of the next sector to examine, cycling through x, y and z
		if      (si < 0 && i%3==0) { if (x >= 0) { x = x + axisChange; } else { x = x - axisChange; }; }
		else if (si < 0 && i%3==1) { if (y >= 0) { y = y + axisChange; } else { y = y - axisChange; }; }
		else if (si < 0 && i%3==2) { if (z >= 0) { z = z + axisChange; } else { z = z - axisChange; }; }
		i++;
	}
	homeworld = SystemPath(x, y, z, si);
}
Esempio n. 2
0
			virtual void pull(AudioChunk &chunk)
			{
				if (!chunk.length())   return;
				if (!valid || finished) {chunk.silence(); return;}

				int samples, have = 0, need = chunk.length();

				//Create pointers to 16-bit data
				short *d16[PG_MAX_CHANNELS];
				for (Uint32 i = 0; i < chunk.format().channels; ++i)
					d16[i] = (short*) chunk.start(i);

				while (true)
				{
					samples = stb_vorbis_get_samples_short(ogg,
						chunk.format().channels, d16, (need-have));

					if (samples < 0)
					{
						finished = true;
						//cout << " VORBIS ERROR" << endl;
						break;
					}
					if (samples == 0)
					{
						//File's end
						if (loop)
						{
							stb_vorbis_seek_start(ogg);
							continue;
						}
						else
						{
							finished = true;
							break;
						}
					}

					for (Uint32 i=0; i < chunk.format().channels; ++i)
						d16[i] += samples;
					have += samples;
					//if (have > need) cout << "VORBIS OVERDRAW" << endl;

					//std::cout << "OGG pull: " << have << "/" << need << std::endl;

					if (have >= need) break;
				}

				//Cutoff marker if necessary
				if (have < need) chunk.cutoff(have);

				//Upsample data to 24-bit Sint32s
				for (Uint32 i=0; i < chunk.format().channels; ++i)
				{
					Sint32 *start = chunk.start(i), *op = start + have;
					short *ip = d16[i];
					while (op!=start) {*(--op) = 256 * Sint32(*(--ip));}
				}
			}
Esempio n. 3
0
void myMusicPlayer(void *udata, Uint8 *stream, int len)
{
	int i,act=0;
	Sint16 *ptr2;

	if (stream!=0) {
		ptr2=(Sint16 *)stream;
		if (playing_music) {
			while(act<len) {
				if (music_loaded[music_position]) {
					/* Play a music file: */ 

					if ((music_sound[music_position]->flags&SOUND_SAMPLEFLAG_EOF)) {
						/* End of file: */ 
						if (music_loaded[music_position+1]) {
							music_position++;
						} /* if */ 
						Sound_Rewind(music_sound[music_position]);
					} else {
						/* In the middle of the file: */ 
						int decoded=0;
						Sint16 *ptr;

						Sound_SetBufferSize(music_sound[music_position], len-act);
						
						decoded=Sound_Decode(music_sound[music_position]);
						ptr=(Sint16 *)music_sound[music_position]->buffer;
						for(i=0;i<decoded;i+=2,ptr++,ptr2++) {
							*ptr2=((Sint32(*ptr)*Sint32(music_volume))/127);
						} /* for */ 
						act+=decoded;
					} /* if */ 
				} else {
					/* No music file loaded: */ 
					for(i=act;i<len;i++) stream[i]=0;
					act=len;
				} /* if */ 
			} /* while */ 
		} else {
			/* No music to play: */ 
			for(i=0;i<len;i++) stream[i]=0;
		} /* if */ 
	} else {
		fprintf(stderr,"ERROR in myMusicPlayer(): null music stream!!\n");
	} /* if */ 
} /* myMusicPlayer */ 
Esempio n. 4
0
void ZoneMap::render(Vector2<GLfloat> p_camPos, GLfloat p_zoom)
{
	GLfloat _tileSize = m_tileSize + p_zoom;
	Map::render(p_camPos, p_zoom);
	glColor3f(1, 1, 1);
	if(m_layerVisible[2])
		for(Uint16 i = 1; i < m_entities.size(); i++)
			Font::getInstance().print(m_entities[i].m_name, Sint32(GLfloat(m_entities[i].m_pos.x) * _tileSize - p_camPos.x * _tileSize) + _tileSize / 2, Sint32(GLfloat(m_entities[i].m_pos.y) * _tileSize - p_camPos.y * _tileSize) - Font::getInstance().getHeight() / 2 - 1);
}
Esempio n. 5
0
Sint16 AudioMixer::tick()
{
  Sint32 val=0;
  Sint16 sint16tick;
  int i;

  for (i=0;i<TRACK_MAX;i++)
    val=val+Sint32(MM[i].tick());
  val=(val*volume)>>7;

  if (val>32000)  val=32000-(val-32000);
  if (val<-32000) val=-32000-(val+32000);

  sint16tick=val;
  return sint16tick;
}
Esempio n. 6
0
void ZoneMap::redo()
{
	if(m_cEdit < Sint32(m_redoEdits.size()) - 1)
	{
		Edit::Tile _tile;
		m_editting = true;
		for(Uint16 i = 0; i < m_redoEdits[m_cEdit + 1].m_tile.size(); i++)
		{
			_tile = m_redoEdits[m_cEdit + 1].m_tile[i];
			setTile(_tile.layer, _tile.x, _tile.y, _tile.id);
		}
		if(m_redoEdits[m_cEdit + 1].m_entity.id != -1)
		m_entities[m_redoEdits[m_cEdit + 1].m_entity.id].m_pos = m_redoEdits[m_cEdit + 1].m_entity.pos;
		m_cEdit++;
		m_editting = false;
	}
}
Esempio n. 7
0
File: Bar.cpp Progetto: Ksan0/cpp
void Bar::Draw(SDL_Renderer *renderer)
{
    if(_texture == nullptr)
        throw Exception("No bar texture");
    
    Uint32 ux, uy, uw, uh;
    Converter::ScreenPercentToPixel(_pos.x, _pos.y, &ux, &uy);
    Converter::ScreenPercentToPixel(_pos.w, _pos.h, &uw, &uh);

    Sint32 x = ux, y = uy, w = uw, h = uh;
    w = Sint32(float(w) * _val / _maxval);


    auto initto = [x, y, w, h]() -> SDL_Rect
    {
        if(w >= 0)
        {
            SDL_Rect r = {x, y, w, h};
            return r;
        }

        SDL_Rect r = { x+w, y, -w, h };
        return r;
    };
    auto initfrom = [w](Uint32 t_w, Uint32 t_h, float p) -> SDL_Rect
    {
        if(w >= 0)
        {
            SDL_Rect r = {0, 0, int(float(t_w) * p), 32};
            return r;
        }

        int need_w = int(float(t_w) * p);
        SDL_Rect r = {t_w - need_w, 0, need_w, t_h};
        return r;
    };

    SDL_Rect to = initto();
    SDL_Rect from = initfrom(256, 32, _val/_maxval);
    SDL_RenderCopy(renderer, _texture, &from, &to);
}
Esempio n. 8
0
// Test CIMKeyBinding constructor (CIMValue variety) and equal(CIMValue) method
void test03()
{
    CIMKeyBinding kb0("test0", Real32(3.14159));
    PEGASUS_TEST_ASSERT(kb0.equal(Real32(3.14159)));
    PEGASUS_TEST_ASSERT(!kb0.equal(Real32(3.141593)));

    CIMKeyBinding kb1("test1", String("3.14159"), CIMKeyBinding::NUMERIC);
    PEGASUS_TEST_ASSERT(kb1.equal(Real32(3.14159)));
    PEGASUS_TEST_ASSERT(!kb1.equal(String("3.14159")));

    CIMKeyBinding kb2("test2", Uint32(1000));
    PEGASUS_TEST_ASSERT(kb2.equal(Uint32(1000)));
    PEGASUS_TEST_ASSERT(!kb2.equal(Uint32(1001)));
    PEGASUS_TEST_ASSERT(kb2.getValue() == "1000");

    CIMKeyBinding kb3("test3", Char16('X'));
    PEGASUS_TEST_ASSERT(kb3.equal(Char16('X')));
    PEGASUS_TEST_ASSERT(!kb3.equal(Char16('Y')));
    PEGASUS_TEST_ASSERT(kb3.getValue() == "X");

    CIMKeyBinding kb4("test4", CIMDateTime("19991224120000.000000+360"));
    PEGASUS_TEST_ASSERT(kb4.equal(CIMDateTime("19991224120000.000000+360")));
    PEGASUS_TEST_ASSERT(!kb4.equal(CIMDateTime("19991225120000.000000+360")));
    PEGASUS_TEST_ASSERT(kb4.getValue() == "19991224120000.000000+360");
    kb4.setValue("0");
    PEGASUS_TEST_ASSERT(!kb4.equal(CIMDateTime("19991224120000.000000+360")));

    CIMKeyBinding kb5("test5", String("StringTest"));
    PEGASUS_TEST_ASSERT(kb5.equal(String("StringTest")));
    PEGASUS_TEST_ASSERT(!kb5.equal(String("StringTest1")));
    PEGASUS_TEST_ASSERT(kb5.getValue() == "StringTest");

    CIMKeyBinding kb6("test6", Boolean(true));
    PEGASUS_TEST_ASSERT(kb6.equal(Boolean(true)));
    PEGASUS_TEST_ASSERT(!kb6.equal(Boolean(false)));
    PEGASUS_TEST_ASSERT(kb6.getValue() == "TRUE");
    kb6.setValue("true1");
    PEGASUS_TEST_ASSERT(!kb6.equal(Boolean(true)));

    CIMKeyBinding kb7("test7",
        CIMObjectPath("//atp:77/root/cimv25:TennisPlayer."
            "last=\"Rafter\",first=\"Patrick\""));

    String path = "//atp:77/root/cimv25:TennisPlayer."
                  "last=\"Rafter\",first=\"Patrick\"";
    PEGASUS_TEST_ASSERT(kb7.equal(CIMObjectPath(path)));

    path = "//atp:77/root/cimv25:TennisPlayer."
           "FIRST=\"Patrick\",LAST=\"Rafter\"";
    PEGASUS_TEST_ASSERT(kb7.equal(CIMObjectPath(path)));

    path = "//atp:77/root/cimv25:TennisPlayer.last=\"Rafter\"";
    PEGASUS_TEST_ASSERT(!kb7.equal(CIMObjectPath(path)));

    Boolean exceptionFlag = false;
    try
    {
        CIMKeyBinding kb8("test8", Array<Uint32>());
    }
    catch (TypeMismatchException&)
    {
        exceptionFlag = true;
    }
    PEGASUS_TEST_ASSERT(exceptionFlag);

    CIMKeyBinding kb9("test9", String("1000"), CIMKeyBinding::STRING);
    PEGASUS_TEST_ASSERT(!kb9.equal(Uint32(1000)));

    CIMKeyBinding kb10("test10", String("100"), CIMKeyBinding::NUMERIC);
    PEGASUS_TEST_ASSERT(kb10.equal(Uint64(100)));
    PEGASUS_TEST_ASSERT(kb10.equal(Uint32(100)));
    PEGASUS_TEST_ASSERT(kb10.equal(Uint16(100)));
    PEGASUS_TEST_ASSERT(kb10.equal(Uint8(100)));
    PEGASUS_TEST_ASSERT(kb10.equal(Sint64(100)));
    PEGASUS_TEST_ASSERT(kb10.equal(Sint32(100)));
    PEGASUS_TEST_ASSERT(kb10.equal(Sint16(100)));
    PEGASUS_TEST_ASSERT(kb10.equal(Sint8(100)));
    PEGASUS_TEST_ASSERT(!kb10.equal(String("100")));

    CIMKeyBinding kb11("test11", String("+100"), CIMKeyBinding::NUMERIC);
    // Unsigned ints may not start with "+"
    PEGASUS_TEST_ASSERT(!kb11.equal(Uint64(100)));
    PEGASUS_TEST_ASSERT(!kb11.equal(Uint32(100)));
    PEGASUS_TEST_ASSERT(!kb11.equal(Uint16(100)));
    PEGASUS_TEST_ASSERT(!kb11.equal(Uint8(100)));
    PEGASUS_TEST_ASSERT(kb11.equal(Sint64(100)));
    PEGASUS_TEST_ASSERT(kb11.equal(Sint32(100)));
    PEGASUS_TEST_ASSERT(kb11.equal(Sint16(100)));
    PEGASUS_TEST_ASSERT(kb11.equal(Sint8(100)));
    PEGASUS_TEST_ASSERT(!kb11.equal(String("100")));
}
Esempio n. 9
0
void ZoneMap::renderEntity(Vector2<GLfloat> p_camPos, GLfloat p_tileSize)
{
	Vector2<Sint32> _tilesheetSize;
	Vector2<GLfloat> _texCorrection;
	glColor3f(1, 1, 1);
	for(Uint16 i = 0; i < m_entities.size(); i++)
	{
		glBindTexture(GL_TEXTURE_2D, m_entities[i].m_entityTex.getId());
		_tilesheetSize = m_entities[i].m_entityTex.getSize();
		_texCorrection = Vector2<GLfloat>(0.5f, 0.5f) / _tilesheetSize;
		glPushMatrix();
		{
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
			glTranslatef(GLfloat(m_entities[i].m_pos.x + 1) - p_camPos.x, GLfloat(m_entities[i].m_pos.y + 1) - p_camPos.y, 0);
			glBegin(GL_QUADS);
			{
				if(_tilesheetSize.x == 0 || _tilesheetSize.y == 0)
				{
					glBindTexture(GL_TEXTURE_2D, 0);
					glVertex2f(0, 1);
					glVertex2f(1, 1);
					glVertex2f(1, 0);
					glVertex2f(0, 0);
				}
				else
				{
					glTexCoord2f(((1.f / (_tilesheetSize.x / m_tileSize)) * (m_entities[i].m_entityTexId % Sint32(ceil(GLfloat(_tilesheetSize.x) / m_tileSize)))) + _texCorrection.x, 1.f - ((1.f / (_tilesheetSize.y / m_tileSize)) * floor(m_entities[i].m_entityTexId / (GLfloat(_tilesheetSize.x) / m_tileSize)) / (GLfloat(_tilesheetSize.y) / m_tileSize) + (1.f / (_tilesheetSize.y / m_tileSize)) - _texCorrection.y));
					glVertex2f(0, 1);
					glTexCoord2f(((1.f / (_tilesheetSize.x / m_tileSize)) * (m_entities[i].m_entityTexId % Sint32(ceil(GLfloat(_tilesheetSize.x) / m_tileSize)))) + (1.f / (_tilesheetSize.x / m_tileSize)) - _texCorrection.x, 1.f - ((1.f / (_tilesheetSize.y / m_tileSize)) * floor(m_entities[i].m_entityTexId / (GLfloat(_tilesheetSize.x) / m_tileSize)) / (GLfloat(_tilesheetSize.y) / m_tileSize) + (1.f / (_tilesheetSize.y / m_tileSize)) - _texCorrection.y));
					glVertex2f(1, 1);
					glTexCoord2f(((1.f / (_tilesheetSize.x / m_tileSize)) * (m_entities[i].m_entityTexId % Sint32(ceil(GLfloat(_tilesheetSize.x) / m_tileSize)))) + (1.f / (_tilesheetSize.x / m_tileSize)) - _texCorrection.x, 1.f - ((1.f / (_tilesheetSize.y / m_tileSize)) * floor(m_entities[i].m_entityTexId / (GLfloat(_tilesheetSize.x) / m_tileSize)) / (GLfloat(_tilesheetSize.y) / m_tileSize) + _texCorrection.y));
					glVertex2f(1, 0);
					glTexCoord2f(((1.f / (_tilesheetSize.x / m_tileSize)) * (m_entities[i].m_entityTexId % Sint32(ceil(GLfloat(_tilesheetSize.x) / m_tileSize)))) + _texCorrection.x, 1.f - ((1.f / (_tilesheetSize.y / m_tileSize)) * floor(m_entities[i].m_entityTexId / (GLfloat(_tilesheetSize.x) / m_tileSize)) / (GLfloat(_tilesheetSize.y) / m_tileSize) + _texCorrection.y));
					glVertex2f(0, 0);
				}
			}
			glEnd();
		}
		glPopMatrix();
	}
}
Esempio n. 10
0
int main(int argc, char** argv)
{
#ifdef IO
    verbose = getenv("PEGASUS_TEST_VERBOSE") ? true : false;
    if (verbose)
    cout << "Test CIMValue. To turn off display, compile with IO undefined\n";
#endif
    // Test the primitive CIMValue types with test01
    test01(Boolean(true));
    test01(Boolean(false));
    test01(Char16('Z'));
    test01(Uint8(77));
    test01(Sint8(-77));
    test01(Sint16(77));
    test01(Uint16(-77));
    test01(Sint32(77));
    test01(Uint32(-77));
    test01(Sint64(77));
    test01(Uint64(-77));
    test01(Real32(1.5));
    test01(Real64(55.5));
    test01(Uint64(123456789));
    test01(Sint64(-123456789));
    test01(String("Hello world"));
    test01(CIMDateTime("19991224120000.000000+360"));
    test01(CIMObjectPath(
        "//host1:77/root/test:Class1.key1=\"key1Value\",key2=\"key2Value\""));

    // Create and populate a declaration context:

    const CIMNamespaceName NAMESPACE = CIMNamespaceName ("/zzz");

    SimpleDeclContext* context = new SimpleDeclContext;

    context->addQualifierDecl(
    NAMESPACE, CIMQualifierDecl(CIMName ("counter"), false,
        CIMScope::PROPERTY));

    context->addQualifierDecl(
    NAMESPACE, CIMQualifierDecl(CIMName ("classcounter"), false,
        CIMScope::CLASS));

    context->addQualifierDecl(
    NAMESPACE, CIMQualifierDecl(CIMName ("min"), String(),
        CIMScope::PROPERTY));

    context->addQualifierDecl(
    NAMESPACE, CIMQualifierDecl(CIMName ("max"), String(),
        CIMScope::PROPERTY));

    context->addQualifierDecl(NAMESPACE,
    CIMQualifierDecl(CIMName ("Description"), String(),
        CIMScope::PROPERTY));

    CIMClass class1(CIMName ("MyClass"));

    class1
    .addProperty(CIMProperty(CIMName ("count"), Uint32(55))
        .addQualifier(CIMQualifier(CIMName ("counter"), true))
        .addQualifier(CIMQualifier(CIMName ("min"), String("0")))
        .addQualifier(CIMQualifier(CIMName ("max"), String("1"))))
    .addProperty(CIMProperty(CIMName ("message"), String("Hello"))
        .addQualifier(CIMQualifier(CIMName ("description"),
                String("My Message"))))
    .addProperty(CIMProperty(CIMName ("ratio"), Real32(1.5)));

    Resolver::resolveClass (class1, context, NAMESPACE);
    context->addClass(NAMESPACE, class1);

    // Test a CIMObject that is a CIMClass
    test01(CIMObject(class1));

    // Test a CIMObject that is a CIMInstance
    CIMInstance instance1(CIMName ("MyClass"));
    instance1.addQualifier(CIMQualifier(CIMName ("classcounter"), true));
    instance1.addProperty(CIMProperty(CIMName ("message"), String("Goodbye")));

    Resolver::resolveInstance (instance1, context, NAMESPACE, true);

    test01(CIMObject(instance1));

    testEmbeddedValue<CIMObject>(instance1);
    testEmbeddedValue<CIMInstance>(instance1);

    // Test CIMValue arrays

    Array<Uint8> arr1;
    arr1.append(11);
    arr1.append(22);
    arr1.append(23);
    test02(arr1);

    Array<Uint16> arr2;
    arr2.append(333);
    arr2.append(444);
    arr2.append(445);
    test02(arr2);

    Array<Uint32> arr3;
    arr3.append(5555);
    arr3.append(6666);
    arr3.append(6667);
    test02(arr3);

    Array<Uint64> arr4;
    arr4.append(123456789);
    arr4.append(987654321);
    arr4.append(987654322);
    test02(arr4);

    Array<Sint8> arr5;
    arr5.append(-11);
    arr5.append(-22);
    arr5.append(-23);
    test02(arr5);

    Array<Sint16> arr6;
    arr6.append(333);
    arr6.append(444);
    arr6.append(555);
    test02(arr6);

    Array<Sint32> arr7;
    arr7.append(555);
    arr7.append(666);
    arr7.append(777);
    test02(arr7);

    Array<Sint64> arr8;
    arr8.append(-123456789);
    arr8.append(-987654321);
    arr8.append(-987654321);
    test02(arr8);

    Array<Boolean> arr9;
    arr9.append(true);
    arr9.append(false);
    arr9.append(false);
    test02(arr9);

    Array<Real32> arr10;
    arr10.append(1.55F);
    arr10.append(2.66F);
    arr10.append(3.77F);
    test02(arr10);

    Array<Real64> arr11;
    arr11.append(55.55);
    arr11.append(66.66);
    arr11.append(77.77);
    test02(arr11);

    Array<Char16> arr12;
    arr12.append('X');
    arr12.append('Y');
    arr12.append('Z');
    test02(arr12);

    Array<String> arr13;
    arr13.append("One");
    arr13.append("Two");
    arr13.append("Three");
    test02(arr13);

    Array<CIMDateTime> arr14;
    arr14.append(CIMDateTime ("20020130120000.000000+360"));
    arr14.append(CIMDateTime ("20020201120000.000000+360"));
    arr14.append(CIMDateTime ("20020202120000.000000+360"));
    test02(arr14);

    Array<CIMObjectPath> arr15;
    arr15.append(CIMObjectPath(
        "//host1:77/root/test:Class1.key1=\"key1Value\",key2=\"key2Value\""));
    arr15.append(CIMObjectPath(
        "//host2:88/root/static:Class2.keyA=\"keyAValue\",keyB="
                "\"keyBValue\""));
    arr15.append(CIMObjectPath(
        "//host3:99/root/test/static:Class3.keyX=\"keyXValue\","
                "keyY=\"keyYValue\""));
    test02(arr15);

    testEmbeddedValueArray<CIMObject>(instance1, NAMESPACE, context);
    testEmbeddedValueArray<CIMInstance>(instance1, NAMESPACE, context);

    // Calling remaining  Array tests..
    CIMDateTime D1("19991224120000.000000+100");
    Array<CIMDateTime> arrD1(10,D1);
    CIMDateTime *D2 = new CIMDateTime("19991224120000.000000+100");
    Array<CIMDateTime> arrD2(D2,1);
    test03(arrD1, arrD2, D2, CIMDateTime("19991224120000.000000+100"),
                     CIMDateTime("29991224120000.000000+100"));
    delete D2;

    CIMName cimname1("yourName");
    Array<CIMName> arrcimname1(10,cimname1);
    CIMName *cimname2 = new CIMName("yourName");
    Array<CIMName> arrcimname2(cimname2,1);
    test03(arrcimname1, arrcimname2, cimname2, CIMName("yourName"),
            CIMName("myName"));
    delete cimname2;

    CIMKeyBinding cimbind1(cimname1, "myKey", CIMKeyBinding::STRING);
    CIMKeyBinding cimbind2(cimname1, "yourKey", CIMKeyBinding::STRING);
    Array<CIMKeyBinding> arrcimbind1(10,cimbind1);
    CIMKeyBinding *cimbind3 =
        new CIMKeyBinding(cimname1, "myKey", CIMKeyBinding::STRING);
    Array<CIMKeyBinding> arrcimbind2(cimbind3,1);
    test03(arrcimbind1, arrcimbind2, cimbind3, cimbind1, cimbind2 );
    delete cimbind3;

    CIMNamespaceName cimnamespace1("root/SampleProvider");
    Array<CIMNamespaceName> arrcimnamespace1(10,cimnamespace1);
    CIMNamespaceName *cimnamespace2 = new CIMNamespaceName(
            "root/SampleProvider");
    Array<CIMNamespaceName> arrcimnamespace2(cimnamespace2,1);
    test03(arrcimnamespace1, arrcimnamespace2, cimnamespace2,
            CIMNamespaceName("root/SampleProvider"),
            CIMNamespaceName("root/SampleProvider2"));
    delete cimnamespace2;

    Array<Boolean> arrB1(10,true);
    Boolean *b = new Boolean(true);
    Array<Boolean> arrB2(b,1);
    Array<Boolean> arrB3(2);
    Boolean b1 = true, b2=false;
    test03(arrB1, arrB2, b, Boolean(true),Boolean(false));
    delete b;

    Array<Real32> arrreal321(10);
    Real32 creal321(2.5);
    Array<Real32> arrreal322(10, creal321);
    Real32 *creal322 = new Real32(2.5);
    Array<Real32> arrreal323(creal322,1);
    Array<Real32> arrreal324(arrreal321);
    test03(arrreal322, arrreal323, creal322,Real32(2.5),Real32(3.5));
    delete creal322;

    Array<Real64> arrreal641(10);
    Real64 creal641(20000.54321);
    Array<Real64> arrreal642(10, creal641);
    Real64 *creal642 = new Real64(20000.54321);
    Array<Real64> arrreal643(creal642,1);
    Array<Real64> arrreal644(arrreal641);
    test03(arrreal642, arrreal643, creal642,Real64(20000.54321),
            Real64(30000.54321));
    delete creal642;

    Array<Sint16> arrSint161(10);
    Sint16 cSint161(-2000);
    Array<Sint16> arrSint162(10, cSint161);
    Sint16 *cSint162 = new Sint16(-2000);
    Array<Sint16> arrSint163(cSint162,1);
    Array<Sint16> arrSint164(arrSint161);
    test03(arrSint162, arrSint163, cSint162, Sint16(-2000), Sint16(-3000));
    delete cSint162;

    Array<Sint32> arrSint321(10);
    Sint32 cSint321(-200000000);
    Array<Sint32> arrSint322(10, cSint321);
    Sint32 *cSint322 = new Sint32(-200000000);
    Array<Sint32> arrSint323(cSint322,1);
    Array<Sint32> arrSint324(arrSint321);
    test03(arrSint322, arrSint323, cSint322, Sint32(-200000000),
            Sint32(-300000000));
    delete cSint322;

    Array<Sint64> arrSint641(10);
    Sint64 cSint641(Sint64(-2000000)*Sint64(10000000) );
    Array<Sint64> arrSint642(10, cSint641);
    Sint64 *cSint642 = new Sint64(Sint64(-2000000)*Sint64(10000000));
    Array<Sint64> arrSint643(cSint642,1);
    Array<Sint64> arrSint644(arrSint641);
    test03(arrSint642, arrSint643, cSint642,Sint64(-2000000)*Sint64(10000000),
                           Sint64(-3000000)*Sint64(10000000));
    delete cSint642;

    Array<Sint8> arrSint81(10);
    Sint8 cSint81(-20);
    Array<Sint8> arrSint82(10, cSint81);
    Sint8 *cSint82 = new Sint8(-20);
    Array<Sint8> arrSint83(cSint82,1);
    Array<Sint8> arrSint84(arrSint81);
    test03(arrSint82, arrSint83, cSint82, Sint8(-20), Sint8(-22));
    delete cSint82;

    Array<Uint16> arrUint161(10);
    Uint16 cUint161(200);
    Array<Uint16> arrUint162(10, cUint161);
    Uint16 *cUint162 = new Uint16(200);
    Array<Uint16> arrUint163(cUint162,1);
    Array<Uint16> arrUint164(arrUint161);
    test03(arrUint162, arrUint163, cUint162, Uint16(200), Uint16(255));
    delete cUint162;

    Array<Uint32> arrUint321(10);
    Uint32 cUint321(2000);
    Array<Uint32> arrUint322(10, cUint321);
    Uint32 *cUint322 = new Uint32(2000);
    Array<Uint32> arrUint323(cUint322,1);
    Array<Uint32> arrUint324(arrUint321);
    test03(arrUint322, arrUint323, cUint322, Uint32(2000), Uint32(3000));
    delete cUint322;

    Array<Uint64> arrUint641(10);
    Uint64 cUint641(Uint64(2000000)*Uint64(10000000));
    Array<Uint64> arrUint642(10, cUint641);
    Uint64 *cUint642 = new Uint64(Uint64(2000000)*Uint64(10000000));
    Array<Uint64> arrUint643(cUint642,1);
    Array<Uint64> arrUint644(arrUint641);
    test03(arrUint642, arrUint643, cUint642,Uint64(2000000)*Uint64(10000000),
                           Uint64(255000)*Uint64(10000000));
    delete cUint642;

    Array<Uint8> arrUint81(10);
    Uint8 cUint81(200);
    Array<Uint8> arrUint82(10, cUint81);
    Uint8 *cUint82 = new Uint8(200);
    Array<Uint8> arrUint83(cUint82,1);
    Array<Uint8> arrUint84(arrUint81);
    test03(arrUint82, arrUint83, cUint82, Uint8(200), Uint8(255));
    delete cUint82;

    Array<Char16> arrChar161(10);
    Char16 cChar161('Z');
    Array<Char16> arrChar162(10, cChar161);
    Char16 *cChar162 = new Char16('Z');
    Array<Char16> arrChar163(cChar162,1);
    Array<Char16> arrChar164(arrChar161);
    test03(arrChar162, arrChar163, cChar162, Char16('Z'), Char16('z'));
    delete cChar162;
    delete context;

    cout << argv[0] << " +++++ passed all tests" << endl;

    return 0;
}
Esempio n. 11
0
CIMInstance buildCIMInstanceSourceObject(Boolean display)
{
    // Build an instance of a class that will be embedded within
    // the instance of MyClass
    CIMInstance instembed(CIMName("EmbedClassClass"));
    instembed.addProperty(CIMProperty(CIMName("embedBool"), true));
    instembed.addProperty(CIMProperty(CIMName("embedInt"), Uint32(5)));
    instembed.addProperty(CIMProperty(CIMName("embedStr"), String("Test")));

    // Build an instance that will be the primary test instance
    CIMInstance inst(CIMName("MyClass"));
    inst.addProperty(CIMProperty(CIMName("BoolScal1"), true));
    inst.addProperty(CIMProperty(CIMName("BoolScal2"), false));

    inst.addProperty(CIMProperty(CIMName("IntScal1"), Uint32(5)));
    inst.addProperty(CIMProperty(CIMName("IntScal2"), Uint32(25)));
    inst.addProperty(CIMProperty(CIMName("IntScal3"), Sint32(-25123)));
    inst.addProperty(CIMProperty(CIMName("IntScal4"), Uint32(0)));

    inst.addProperty(CIMProperty(CIMName("Int64Scal5"), Uint64(0x6fffff)));
    inst.addProperty(CIMProperty(CIMName("Int64Scal6"), Uint64(2147483647)));
    inst.addProperty(CIMProperty(CIMName("Int64Scal7"), Uint64(4067)));
    inst.addProperty(CIMProperty(CIMName("Int64Scal8"), Uint64(0)));
    //// TODO add properties max and min integers.

    // Add real properties
    inst.addProperty(CIMProperty(CIMName("DoubleScal1"), Real64(20.9)));
    inst.addProperty(CIMProperty(CIMName("DoubleScal2"), Real64(0.9)));
    inst.addProperty(CIMProperty(CIMName("DoubleScal3"), Real32(20.9)));
    inst.addProperty(CIMProperty(CIMName("DoubleScal4"), Real32(0.9)));

    // add scalar string properties
    inst.addProperty(CIMProperty(CIMName("strScal1"), String("Test")));
    inst.addProperty(CIMProperty(CIMName("strScal2"), String("noTest")));
    inst.addProperty(CIMProperty(CIMName("strScal3"), String("")));
    // add string property with special characters.
    inst.addProperty(CIMProperty(CIMName("strScal4"),
        String("./\\\"\'!@#$%^&*()")));

    // DateTime Scalar properties - TODO create test for
    // additional formats for this field (interval, other offsets.
    CIMDateTime dt1;
    dt1.set("19991224120000.000000+360");
    inst.addProperty(CIMProperty(CIMName("dateTimeScal1"),dt1));
        CIMDateTime dt2;
    dt2.set("19991224120000.0000**+360");
    inst.addProperty(CIMProperty(CIMName("dateTimeScal2"),dt2));

    // reference literal properties
    CIMObjectPath op1 = CIMObjectPath
            ("//atp:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    inst.addProperty(CIMProperty(CIMName("referenceScal1"),op1));
    CIMObjectPath op2 = CIMObjectPath
            ("root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    inst.addProperty(CIMProperty(CIMName("referenceScal2"),op2));
    CIMObjectPath op3 = CIMObjectPath
            ("TennisPlayer.first=\"Chris\",last=\"Evert\"");
    inst.addProperty(CIMProperty(CIMName("referenceScal3"),op3));
    CIMObjectPath op4 = CIMObjectPath
            ("myclassname.p1=1");
    inst.addProperty(CIMProperty(CIMName("referenceScal4"),op4));

    // KS_TODO create a Reference array property

    // Embedded instance property
    inst.addProperty(CIMProperty(CIMName("embeddedInstance1"),instembed));

    // Array properties
    // Boolean Array
    Array<Boolean> b1; b1.append(true); b1.append(false); b1.append(true);
    inst.addProperty(CIMProperty(CIMName("BoolArrayProp1"), b1));
    Array<Boolean> b2; b2.append(true); b2.append(false); b2.append(true);
    inst.addProperty(CIMProperty(CIMName("BoolArrayProp2"), b2));
    Array<Boolean> b3; b3.append(false); b3.append(false); b3.append(false);
    inst.addProperty(CIMProperty(CIMName("BoolArrayProp3"), b1));

    // Integer Array
    Array<Sint64> a1; a1.append(4); a1.append(5); a1.append (7);
    inst.addProperty(CIMProperty(CIMName("IntArrayProp1"), a1));
    Array<Sint64> a2; a2.append(7); a2.append(8); a2.append (9);
    inst.addProperty(CIMProperty(CIMName("IntArrayProp2"), a2));
    Array<Sint64> a3; a3.append(7); a3.append(-888); a3.append (-999);
    inst.addProperty(CIMProperty(CIMName("IntArrayProp3"), a3));
    Array<Sint64> a4; a4.append(7);
    inst.addProperty(CIMProperty(CIMName("IntArrayProp4"), a4));
    Array<Sint64> a5;;
    inst.addProperty(CIMProperty(CIMName("IntArrayProp5"), a5));

    // Double Array
    Array<Real64> r1; r1.append(1011.04); r1.append(123456.8); r1.append(0.1);
    inst.addProperty(CIMProperty(CIMName("DoubleArrayProp1"), r1));
    Array<Real64> r2; r2.append(-1.04); r2.append(-123456.8); r2.append(0.1);
    inst.addProperty(CIMProperty(CIMName("DoubleArrayProp2"), r2));

    // String Array
    Array<String> s1; s1.append("zero"); s1.append("one"); s1.append("two");
        s1.append("three");
    inst.addProperty(CIMProperty(CIMName("StrArrayProp1"), s1));
    Array<String> s2; s2.append("zero"); s2.append("one"); s2.append("two");
        s2.append("three");
    inst.addProperty(CIMProperty(CIMName("StrArrayProp2"), s2));

    // DateTime Array
    Array<CIMDateTime> dta1;
    dta1.append(dt1);
    dt1.clear();dt1.set("20131224120000.000000+360"); dta1.append(dt1);
    dt1.clear();dt1.set("20011224120000.000000+360"); dta1.append(dt1);
    inst.addProperty(CIMProperty(CIMName("dateTimeArray1"),dta1));
    if (display)
    {
        VCOUT << "Instance to be used in Test" << endl;
        PrintInstance(cout, inst);
    }
    return inst;
}
Esempio n. 12
0
void PG_TestPropertyTypes::initialize(CIMOMHandle& cimom)
{
    // save cimom handle
    _cimom = cimom;

    // create default instances
    CIMInstance instance1("PG_TestPropertyTypes");

    instance1.addProperty(CIMProperty(
        "CreationClassName", String("PG_TestPropertyTypes")));   // key
    instance1.addProperty(CIMProperty("InstanceId", Uint64(1))); //key
    instance1.addProperty(CIMProperty(
        "PropertyString", String("PG_TestPropertyTypes_Instance1")));
    instance1.addProperty(CIMProperty("PropertyUint8", Uint8(120)));
    instance1.addProperty(CIMProperty("PropertyUint16", Uint16(1600)));
    instance1.addProperty(CIMProperty("PropertyUint32", Uint32(3200)));
    instance1.addProperty(CIMProperty("PropertyUint64", Uint64(6400)));
    instance1.addProperty(CIMProperty("PropertySint8", Sint8(-120)));
    instance1.addProperty(CIMProperty("PropertySint16", Sint16(-1600)));
    instance1.addProperty(CIMProperty("PropertySint32", Sint32(-3200)));
    instance1.addProperty(CIMProperty("PropertySint64", Sint64(-6400)));
    instance1.addProperty(CIMProperty("PropertyBoolean", Boolean(1)));
    instance1.addProperty(CIMProperty("PropertyReal32", Real32(1.12345670123)));
    instance1.addProperty(CIMProperty(
        "PropertyReal64", Real64(1.12345678906543210123)));
    instance1.addProperty(CIMProperty(
        "PropertyDatetime", CIMDateTime("20010515104354.000000:000")));

    // update object path
    {
        CIMObjectPath objectPath = instance1.getPath();

        Array<CIMKeyBinding> keys;

        {
            CIMProperty keyProperty = instance1.getProperty(
                instance1.findProperty("CreationClassName"));

            keys.append(
                CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
        }

        {
            CIMProperty keyProperty = instance1.getProperty(
                instance1.findProperty("InstanceId"));

            keys.append(
                CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
        }

        objectPath.setKeyBindings(keys);

        instance1.setPath(objectPath);
    }

    _instances.append(instance1);

    CIMInstance instance2("PG_TestPropertyTypes");

    instance2.addProperty(CIMProperty(
        "CreationClassName", String("PG_TestPropertyTypes")));   // key
    instance2.addProperty(CIMProperty("InstanceId", Uint64(2))); //key
    instance2.addProperty(CIMProperty(
        "PropertyString", String("PG_TestPropertyTypes_Instance2")));

    instance2.addProperty(CIMProperty("PropertyUint8", Uint8(122)));
    instance2.addProperty(CIMProperty("PropertyUint16", Uint16(1602)));
    instance2.addProperty(CIMProperty("PropertyUint32", Uint32(3202)));
    instance2.addProperty(CIMProperty("PropertyUint64", Uint64(6402)));
    instance2.addProperty(CIMProperty("PropertySint8", Sint8(-122)));
    instance2.addProperty(CIMProperty("PropertySint16", Sint16(-1602)));
    instance2.addProperty(CIMProperty("PropertySint32", Sint32(-3202)));
    instance2.addProperty(CIMProperty("PropertySint64", Sint64(-6402)));
    instance2.addProperty(CIMProperty("PropertyBoolean", Boolean(0)));
    instance2.addProperty(CIMProperty("PropertyReal32", Real32(2.12345670123)));
    instance2.addProperty(CIMProperty(
        "PropertyReal64", Real64(2.12345678906543210123)));

    instance2.addProperty(CIMProperty(
        "PropertyDatetime", CIMDateTime("20010515104354.000000:000")));

    _instances.append(instance2);

    // update object path
    {
        CIMObjectPath objectPath = instance2.getPath();

        Array<CIMKeyBinding> keys;

        {
            CIMProperty keyProperty = instance2.getProperty(
                instance2.findProperty("CreationClassName"));

            keys.append(
                CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
        }

        {
            CIMProperty keyProperty = instance2.getProperty(
                instance2.findProperty("InstanceId"));

            keys.append(
                CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
        }

        objectPath.setKeyBindings(keys);

        instance2.setPath(objectPath);
    }

    // instance3 to check for negative floating point and exponents
    CIMInstance instance3("PG_TestPropertyTypes");

    instance3.addProperty(CIMProperty(
        "CreationClassName", String("PG_TestPropertyTypes")));   // key
    instance3.addProperty(CIMProperty("InstanceId", Uint64(3))); //key
    instance3.addProperty(CIMProperty(
        "PropertyString", String("PG_TestPropertyTypes_Instance3")));
    instance3.addProperty(CIMProperty("PropertyUint8", Uint8(120)));
    instance3.addProperty(CIMProperty("PropertyUint16", Uint16(1600)));
    instance3.addProperty(CIMProperty("PropertyUint32", Uint32(3200)));
    instance3.addProperty(CIMProperty("PropertyUint64", Uint64(6400)));
    instance3.addProperty(CIMProperty("PropertySint8", Sint8(-120)));
    instance3.addProperty(CIMProperty("PropertySint16", Sint16(-1600)));
    instance3.addProperty(CIMProperty("PropertySint32", Sint32(-3200)));
    instance3.addProperty(CIMProperty("PropertySint64", Sint64(-6400)));
    instance3.addProperty(CIMProperty("PropertyBoolean", Boolean(0)));
    instance3.addProperty(CIMProperty(
        "PropertyReal32", Real32(-1.12345670123)));
    instance3.addProperty(CIMProperty(
        "PropertyReal64", Real64(0.000000012345)));
    instance3.addProperty(CIMProperty(
        "PropertyDatetime", CIMDateTime("20060301104354.000000:000")));

    // update object path
    {
        CIMObjectPath objectPath = instance3.getPath();

        Array<CIMKeyBinding> keys;

        {
            CIMProperty keyProperty = instance3.getProperty(
                instance3.findProperty("CreationClassName"));

            keys.append(
                CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
        }

        {
            CIMProperty keyProperty =
                instance3.getProperty(instance3.findProperty("InstanceId"));

            keys.append(
                CIMKeyBinding(keyProperty.getName(), keyProperty.getValue()));
        }

        objectPath.setKeyBindings(keys);

        instance3.setPath(objectPath);
    }
    realValueTestInstance = instance3;
}
Esempio n. 13
0
int main(int , char** argv)
{
    verbose = getenv("PEGASUS_TEST_VERBOSE");

    const char* arg0 = argv[0];


    CIMClient client;
    if (!connectToHost(client))
    {
        cerr << "Connection to host failed. Terminating" << endl;
        exit(1);
    }

    Array<CIMObjectPath> paths;

    //
    //  Create instances that will have specified test properties in them
    //  that we can use for queries.  We used the class
    //  Test_CLITestProviderClass because it has a broad set of testable
    //  properties.
    //

    String id1 = "PropertyOpTest1";
    CIMInstance inst1 = buildInstance(client, id1);

    {
        setPropertyValue(inst1,"scalBool", CIMValue(true));
        setPropertyValue(inst1,"scalUint8",CIMValue(Uint8(12)));
        setPropertyValue(inst1,"scalSint8",CIMValue(Sint8(12)));
        setPropertyValue(inst1,"scalUint16",CIMValue(Uint16(500)));
        setPropertyValue(inst1,"scalSint16",CIMValue(Sint16(500)));

        setPropertyValue(inst1,"scalUint32",CIMValue(Uint32(9999)));
        setPropertyValue(inst1,"scalSint32",CIMValue(Sint32(9999)));

        setPropertyValue(inst1,"scalUint64",CIMValue(Uint64(9999)));
        setPropertyValue(inst1,"scalSint64",CIMValue(Sint64(9999)));

        setPropertyValue(inst1,"scalString",CIMValue(String("String1")));
        Array<Uint32> lArrayUint32;
        lArrayUint32.append(0);
        lArrayUint32.append(128);
        lArrayUint32.append(256);
        lArrayUint32.append(65536);
        lArrayUint32.append(4294967295);
        setPropertyValue(inst1,"arrayUint32",CIMValue(lArrayUint32));
    }

    CIMObjectPath p1 = createInstance(client, inst1);
    paths.append(p1);

    String id2 = "PropertyOpTest2";
    CIMInstance inst2 = buildInstance(client, id2);
    {
        setPropertyValue(inst2,"scalBool", CIMValue(false));
        setPropertyValue(inst2,"scalUint8",CIMValue(Uint8(20)));
        setPropertyValue(inst2,"scalSint8",CIMValue(Sint8(8)));
        setPropertyValue(inst2,"scalUint16",CIMValue(Uint16(1000)));
        setPropertyValue(inst2,"scalSint16",CIMValue(Sint16(500)));

        setPropertyValue(inst2,"scalUint32",CIMValue(Uint32(7698)));
        setPropertyValue(inst2,"scalSint32",CIMValue(Sint32(9999)));

        setPropertyValue(inst2,"scalUint64",CIMValue(Uint64(9999)));
        setPropertyValue(inst2,"scalSint64",CIMValue(Sint64(9999)));

        setPropertyValue(inst2,"scalString",CIMValue(String("String2")));
        Array<Uint32> lArrayUint32;
        lArrayUint32.append(0);
        lArrayUint32.append(128);
        lArrayUint32.append(256);
        lArrayUint32.append(165536);
        lArrayUint32.append(4294967295);
        lArrayUint32.append(876543);
        setPropertyValue(inst2,"arrayUint32",CIMValue(lArrayUint32));
    }

    CIMObjectPath p2 = createInstance(client, inst2);
    paths.append(p2);

    //
    //  Execute the query tests
    //

    testEnumerate(client, "scalBool = true", 2);
    testEnumerate(client,"scalUint32 = 7698", 1);
    testEnumerate(client, "scalString = 'String2'", 1);


    testEnumerate(client, "arrayUint32[5] = 876543", 1);
    testEnumerate(client, "ANY arrayUint32 = 876543", 1);
    testEnumerate(client, "scalString <> 'NoSuchString'", 3);
    testEnumerate(client, "scalString = 'String2'", 1);

    // the following are error tests

    testEnumerate(client, "scalUint32 = 'NotANumber'", 0, CIMStatusCode(15));
    testEnumerate(client, "scalUint32 = 123a", 0, CIMStatusCode(15));
    testEnumerate(client, "scalbool = 1234", 0, CIMStatusCode(15));

    // Test associator

    CIMObjectPath assoc =
        CIMObjectPath("Test_CLITestProviderClass.Id=\"Mike\"");
    testAssociators(client, "scalBool = true",assoc, 1);
    testAssociators(client, "scalBool = false",assoc, 0);

    // Cheap test because only possible comparison is cimobject path
    // and that means building correct object path for the query
    // KS_TODO create a valid CIMObjectPath and test it.
    testReferences(client, "scalBool = false", assoc,0);

    for (Uint32 i = 0; i < paths.size(); i++)
    {
        deleteInstance(client,paths[i]);
    }

cout << arg0 << " +++++ passed all tests.";

}
Esempio n. 14
0
void FactionOctsapling::Add(Faction* faction)
{
	/*  The general principle here is to put the faction in every octbox cell that a system
	    that is a member of that faction could be in. This should let us cut the number
		of factions that have to be checked by GetNearestFaction, by eliminating right off
		all the those Factions that aren't in the same cell.

		As I'm just going for the quick performance win, I'm being very sloppy and
		treating a Faction as if it was a cube rather than a sphere. I'm also not even
		attempting to work out real faction boundaries for this.

		Obviously this all could be improved even without this Octsapling growing into
		a full Octree.

		This part happens at faction generation time so shouldn't be too performance
		critical
	*/
	Sector sec = Sector(faction->homeworld.sectorX, faction->homeworld.sectorY, faction->homeworld.sectorZ);

	/* only factions with homeworlds that are available at faction generation time can
	   be added to specific cells...
	*/
	if (faction->hasHomeworld && (faction->homeworld.systemIndex < sec.m_systems.size())) {
		/* calculate potential indexes for the octbox cells the faction needs to go into
		*/
		Sector::System sys = sec.m_systems[faction->homeworld.systemIndex];

		int xmin = BoxIndex(Sint32(sys.FullPosition().x - float((faction->Radius()))));
		int xmax = BoxIndex(Sint32(sys.FullPosition().x + float((faction->Radius()))));
		int ymin = BoxIndex(Sint32(sys.FullPosition().y - float((faction->Radius()))));
		int ymax = BoxIndex(Sint32(sys.FullPosition().y + float((faction->Radius()))));
		int zmin = BoxIndex(Sint32(sys.FullPosition().z - float((faction->Radius()))));
		int zmax = BoxIndex(Sint32(sys.FullPosition().z + float((faction->Radius()))));

		/* put the faction in all the octbox cells needed in a hideously inexact way that
		   will generate duplicates in each cell in many cases
		*/
		octbox[xmin][ymin][zmin].push_back(faction);  // 0,0,0
		octbox[xmax][ymin][zmin].push_back(faction);  // 1,0,0
		octbox[xmax][ymax][zmin].push_back(faction);  // 1,1,0
		octbox[xmax][ymax][zmax].push_back(faction);  // 1,1,1

		octbox[xmin][ymax][zmin].push_back(faction);  // 0,1,0
		octbox[xmin][ymax][zmax].push_back(faction);  // 0,1,1
		octbox[xmin][ymin][zmax].push_back(faction);  // 0,0,1
		octbox[xmax][ymin][zmax].push_back(faction);  // 1,0,1

		/* prune any duplicates from the octbox cells making things slightly saner
		*/
		PruneDuplicates(0,0,0);
		PruneDuplicates(1,0,0);
		PruneDuplicates(1,1,0);
		PruneDuplicates(1,1,1);

		PruneDuplicates(0,1,0);
		PruneDuplicates(0,1,1);
		PruneDuplicates(0,0,1);
		PruneDuplicates(1,0,1);

	} else {
	/* ...other factions, such as ones with no homeworlds, and more annoyingly ones
	   whose homeworlds don't exist yet because they're custom systems have to go in
	   *every* octbox cell
	*/
		octbox[0][0][0].push_back(faction);
		octbox[1][0][0].push_back(faction);
		octbox[1][1][0].push_back(faction);
		octbox[1][1][1].push_back(faction);

		octbox[0][1][0].push_back(faction);
		octbox[0][1][1].push_back(faction);
		octbox[0][0][1].push_back(faction);
		octbox[1][0][1].push_back(faction);
	}
}
Esempio n. 15
0
int createErrorInstance(CIMClient& client)
{
    // Build the embedded instance
    Array<CIMKeyBinding> embeddedPathKeys;
    CIMName key1Name("key1");
    CIMValue key1Value(String("fake-key1"));
    CIMName key2Name("key2");
    CIMValue key2Value(String("fake-key2"));

    embeddedPathKeys.append(CIMKeyBinding(key1Name, key1Value));
    embeddedPathKeys.append(CIMKeyBinding(key2Name, key2Value));

    CIMObjectPath embeddedPath(
        "localhost",
        TEST_NAMESPACE,
        CIMName("PG_EmbeddedClass"),
        embeddedPathKeys);

    embeddedInstance.reset(new CIMInstance(CIMName("PG_EmbeddedClass")));
    //embeddedInstance->setPath(embeddedPath);
    embeddedInstance->addProperty(CIMProperty(key1Name,
        key1Value));
    embeddedInstance->addProperty(CIMProperty(key2Name,
        key2Value));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop01"),
        Uint8(234)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop02"),
        Uint16(16234)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop03"),
        Uint32(32234)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop04"),
        Uint64(64234)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop05"),
        Sint8(-234)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop06"),
        Sint16(-16234)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop07"),
        Sint32(-32234)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop08"),
        Sint64(-64234)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop09"),
        Real32(-64234.46)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop10"),
        Real64(-23464234.78)));
    embeddedInstance->addProperty(CIMProperty(CIMName("prop11"),
        CIMDateTime(60, true)));

    // Build the embedded instance
    Array<CIMKeyBinding> errorPathKeys;
    CIMName errorKeyName("errorKey");
    CIMValue errorKeyValue(String("error key 1"));
    errorPathKeys.append(CIMKeyBinding(errorKeyName, errorKeyValue));
    CIMObjectPath localErrorPath(
        "localhost",
        TEST_NAMESPACE,
        CIMName("PG_EmbeddedError"),
        errorPathKeys);
    errorInstance.reset(new CIMInstance(CIMName("PG_EmbeddedError")));
    errorInstance->setPath(localErrorPath);
    errorInstance->addProperty(CIMProperty(errorKeyName,
        errorKeyValue));
    errorInstance->addProperty(CIMProperty(CIMName("EmbeddedInst"),
        CIMValue(*embeddedInstance)));
    try
    {
        errorPath = client.createInstance(TEST_NAMESPACE, *errorInstance);
        PEGASUS_STD(cout) << "Created EmbeddedError: " << errorPath.toString()
            << PEGASUS_STD(endl);
        errorInstance->setPath(errorPath);
    }
    catch (Exception& e)
    {
        PEGASUS_STD(cout) << "Exception while creating Error Instance: "
            << e.getMessage() << PEGASUS_STD(endl);
        return -1;
    }

    return 0;
}