Changeset 104 for cpp/gdk/gdktest.cpp


Ignore:
Timestamp:
07/23/13 18:15:30 (11 years ago)
Author:
sz
Message:

introducing object de/serialization - see serialtest.cpp
the core GDK classes can be now used in multiple threads (ifdef MULTITHREADED)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/gdk/gdktest.cpp

    r81 r104  
    2828       "    ########################################\n",title);
    2929}
    30 void printProperties(ParamInterface &pi)
     30void printProperties(Param &pi)
    3131{
    3232printf(" #        id                      type  name        group (%d properties)\n",pi.getPropCount());
     
    3939}
    4040
    41 void changeOneProperty(ParamInterface &pi)
     41#define PRINT_PROPERTIES(p) {Param tmp_param(p); printProperties(tmp_param);}
     42
     43void changeOneProperty(Param &pi)
    4244{
    4345if (pi.getPropCount()<=0) return;
     
    5456}
    5557
     58#define CHANGE_ONE_PROPERTY(p) {Param tmp_param(p); changeOneProperty(tmp_param);}
     59
    5660void moreAboutPart(Part* p)
    5761{
     
    6165       "and should be handled with care, because they influence other elements of the model.\n\n"
    6266       " [this data is provided by Part::properties() ]\n");
    63 printProperties(p->properties());
     67PRINT_PROPERTIES(p->properties());
    6468printf("\nHowever, there is a subset of properties which may be modified more freely.\n"
    6569       "Properties on this list are related only to this part and can be changed\n"
     
    6771       "will be silently repaired.\n"
    6872       "\n [this data is provided by Part::extraProperties() ]\n");
    69 printProperties(p->extraProperties());
     73PRINT_PROPERTIES(p->extraProperties());
    7074printf("\nThis set of properties can vary from release to release,\n"
    7175       "but can be safely accessed by using extraProperties() call.\n"
     
    7478       "Now we will try to change some of properties:\n\n");
    7579p->getModel().open();
    76 changeOneProperty(p->extraProperties());
     80CHANGE_ONE_PROPERTY(p->extraProperties());
    7781p->getModel().close();
    7882printf("\nLet's see f0... (check out part #%d !)\n\n%s\n", p->refno, (const char*)p->getModel().getF0Geno().getGene());
     
    127131{
    128132printf("Similarly as with Part, the full list of properties comes first:\n\n");
    129 printProperties(j->properties());
     133CHANGE_ONE_PROPERTY(j->properties());
    130134printf("\nActually, there are two kinds of Joints: delta and absolute.\n"
    131135       "For this object, Joint::isDelta() returns %d, so this is the %s Joint.\n",
     
    147151       "The other properties are available from Joint::extraProperties()\n"
    148152       "and at the moment are defined as follows:\n\n");
    149 printProperties(j->extraProperties());
     153PRINT_PROPERTIES(j->extraProperties());
    150154printf("\nThey can be changed just like Part's extra properties:\n");
    151155j->getModel().open();
    152 changeOneProperty(j->extraProperties());
     156CHANGE_ONE_PROPERTY(j->extraProperties());
    153157j->getModel().close();
    154158printf("And after that we have this genotype:\n\n%s\n", (const char*)j->getModel().getF0Geno().getGene());
     
    161165printf("Basic features of Neuro object are similar to those of Part and Joint.\n"
    162166       "We can request a property list:\n\n");
    163 printProperties(n->properties());
     167PRINT_PROPERTIES(n->properties());
    164168printf("\n...and extra properties (which are designed to be always valid and easy to change):\n\n");
    165 printProperties(n->extraProperties());
     169PRINT_PROPERTIES(n->extraProperties());
    166170printf("\nAs usual, we will change something:\n");
    167171n->getModel().open();
    168 changeOneProperty(n->extraProperties());
     172CHANGE_ONE_PROPERTY(n->extraProperties());
    169173n->getModel().close();
    170174printf("Each neuron can have any number of inputs = weighted connections\n with other neurons.\n"
Note: See TracChangeset for help on using the changeset viewer.