NSFState::NSFState(const NSFString& name, NSFCompositeState* parentState, NSFVoidAction<NSFStateMachineContext>* entryAction, NSFVoidAction<NSFStateMachineContext>* exitAction)
     : NSFTaggedObject(name), EntryActions(entryAction), ExitActions(exitAction), active(false), logEntry(true), parentRegion(parentState->getDefaultRegion())
 {
     construct();
 }
Esempio n. 2
0
 A() {
   construct();
 }
Esempio n. 3
0
 Binary::Binary(std::string n, BinaryFormat f)
     : EPAXExport(EPAXExportClass_BIN), binary(INVALID_PTR), lineinfo(INVALID_PTR)
 {
     construct(n, f);
 }
Esempio n. 4
0
Ptr<ModelBase> by_type(std::string type, usage use, Ptr<Options> options) {
  Ptr<ExpressionGraph> graph = nullptr; // graph unknown at this stage
  // clang-format off
  if(type == "s2s" || type == "amun" || type == "nematus") {
    return models::encoder_decoder()(options)
        ("usage", use)
        ("original-type", type)
            .push_back(models::encoder()("type", "s2s"))
            .push_back(models::decoder()("type", "s2s"))
            .construct(graph);
  }

  if(type == "transformer") {
    return models::encoder_decoder()(options)
        ("usage", use)
        .push_back(models::encoder()("type", "transformer"))
        .push_back(models::decoder()("type", "transformer"))
        .construct(graph);
  }

  if(type == "transformer_s2s") {
    return models::encoder_decoder()(options)
        ("usage", use)
        ("original-type", type)
            .push_back(models::encoder()("type", "transformer"))
            .push_back(models::decoder()("type", "s2s"))
            .construct(graph);
  }

  if(type == "lm") {
    auto idx = options->has("index") ? options->get<size_t>("index") : 0;
    std::vector<int> dimVocabs = options->get<std::vector<int>>("dim-vocabs");
    int vocab = dimVocabs[0];
    dimVocabs.resize(idx + 1);
    std::fill(dimVocabs.begin(), dimVocabs.end(), vocab);

    return models::encoder_decoder()(options)
        ("usage", use)
        ("type", "s2s")
        ("original-type", type)
            .push_back(models::decoder()
                       ("index", idx)
                       ("dim-vocabs", dimVocabs))
            .construct(graph);
  }

  if(type == "multi-s2s") {
    size_t numEncoders = 2;
    auto ms2sFactory = models::encoder_decoder()(options)
        ("usage", use)
        ("type", "s2s")
        ("original-type", type);

    for(size_t i = 0; i < numEncoders; ++i) {
      auto prefix = "encoder" + std::to_string(i + 1);
      ms2sFactory.push_back(models::encoder()("prefix", prefix)("index", i));
    }

    ms2sFactory.push_back(models::decoder()("index", numEncoders));

    return ms2sFactory.construct(graph);
  }

  if(type == "shared-multi-s2s") {
    size_t numEncoders = 2;
    auto ms2sFactory = models::encoder_decoder()(options)
        ("usage", use)
        ("type", "s2s")
        ("original-type", type);

    for(size_t i = 0; i < numEncoders; ++i) {
      auto prefix = "encoder";
      ms2sFactory.push_back(models::encoder()("prefix", prefix)("index", i));
    }

    ms2sFactory.push_back(models::decoder()("index", numEncoders));

    return ms2sFactory.construct(graph);
  }

  if(type == "multi-transformer") {
    size_t numEncoders = 2;
    auto mtransFactory = models::encoder_decoder()(options)
        ("usage", use)
        ("type", "transformer")
        ("original-type", type);

    for(size_t i = 0; i < numEncoders; ++i) {
      auto prefix = "encoder" + std::to_string(i + 1);
      mtransFactory.push_back(models::encoder()("prefix", prefix)("index", i));
    }
    mtransFactory.push_back(models::decoder()("index", numEncoders));

    return mtransFactory.construct(graph);
  }

  if(type == "shared-multi-transformer") {
    size_t numEncoders = 2;
    auto mtransFactory = models::encoder_decoder()(options)
        ("usage", use)
        ("type", "transformer")
        ("original-type", type);

    for(size_t i = 0; i < numEncoders; ++i) {
      auto prefix = "encoder";
      mtransFactory.push_back(models::encoder()("prefix", prefix)("index", i));
    }
    mtransFactory.push_back(models::decoder()("index", numEncoders));

    return mtransFactory.construct(graph);
  }

  if(type == "lm-transformer") {
    auto idx = options->has("index") ? options->get<size_t>("index") : 0;
    std::vector<int> dimVocabs = options->get<std::vector<int>>("dim-vocabs");
    int vocab = dimVocabs[0];
    dimVocabs.resize(idx + 1);
    std::fill(dimVocabs.begin(), dimVocabs.end(), vocab);

    return models::encoder_decoder()(options)
        ("usage", use)
        ("type", "transformer")
        ("original-type", type)
            .push_back(models::decoder()
                       ("index", idx)
                       ("dim-vocabs", dimVocabs))
            .construct(graph);
  }

  if(type == "bert") {                           // for full BERT training
    return models::encoder_classifier()(options) //
        ("original-type", "bert")                // so we can query this
        ("usage", use)                           //
        .push_back(models::encoder()             //
                    ("type", "bert-encoder")     // close to original transformer encoder
                    ("index", 0))                //
        .push_back(models::classifier()          //
                    ("prefix", "masked-lm")      // prefix for parameter names
                    ("type", "bert-masked-lm")   //
                    ("index", 0))                // multi-task learning with MaskedLM
        .push_back(models::classifier()          //
                    ("prefix", "next-sentence")  // prefix for parameter names
                    ("type", "bert-classifier")  //
                    ("index", 1))                // next sentence prediction
        .construct(graph);
  }

  if(type == "bert-classifier") {                // for BERT fine-tuning on non-BERT classification task
    return models::encoder_classifier()(options) //
        ("original-type", "bert-classifier")     // so we can query this if needed
        ("usage", use)                           //
        .push_back(models::encoder()             //
                    ("type", "bert-encoder")     //
                    ("index", 0))                // close to original transformer encoder
        .push_back(models::classifier()          //
                    ("type", "bert-classifier")  //
                    ("index", 1))                // next sentence prediction
        .construct(graph);
  }

#ifdef COMPILE_EXAMPLES
  // @TODO: examples should be compiled optionally
  if(type == "mnist-ffnn") {
    auto mnist = New<MnistFeedForwardNet>(options);
    if(use == usage::scoring)
      return New<Scorer>(mnist, New<MNISTLogsoftmax>());
    else if(use == usage::training)
      return New<Trainer>(mnist, New<MNISTCrossEntropyCost>());
    else
      return mnist;
  }
#endif

#ifdef CUDNN
#ifdef COMPILE_EXAMPLES
  if(type == "mnist-lenet") {
    auto mnist = New<MnistLeNet>(options);
    if(use == usage::scoring)
      return New<Scorer>(mnist, New<MNISTLogsoftmax>());
    else if(use == usage::training)
      return New<Trainer>(mnist, New<MNISTCrossEntropyCost>());
    else
      return mnist;
  }
#endif
  if(type == "char-s2s") {
    return models::encoder_decoder()(options)
        ("usage", use)
        ("original-type", type)
            .push_back(models::encoder()("type", "char-s2s"))
            .push_back(models::decoder()("type", "s2s"))
            .construct(graph);
  }
#endif

  // clang-format on
  ABORT("Unknown model type: {}", type);
}
Esempio n. 5
0
main ()
{
/*	One extra set of data structures are allocated for A's and B's.
	The last A and B will be connected as a dipole.
*/
int		sts, i, half_A, half_B;
OM_S_OBJID	a_objid[MAXA+1], b_objid[MAXB+1];
OM_S_OBJID	resa_objid[MAXA+1], resb_objid[MAXB+1];
int		relindex=0;
uword		minorchan=0;
OM_S_MESSAGE	disconnect_msg,connect_msg,showa, showb;
OM_S_MESSAGE    range_disconnect_msg;
OM_S_CHANSELECT chansel;
char            *chan_acb,*chan_bca, *chan_resacb, *chan_resbca;

struct connect_struct
       {
	 OM_S_CHANSELECT      to_sel;
	 int		      to_idx;
	 OM_S_OBJID	      fr_objid;
	 OMuword              fr_os;
	 OM_S_CHANSELECT      fr_sel;
	 int		      fr_idx;
       } connect_args;

struct disconnect_struct
       {
	 OM_S_CHANSELECT      to_sel;
	 OM_S_OBJID	      fr_objid;
	 OMuword              fr_os;
	 OM_S_CHANSELECT      fr_sel;
       } disconnect_args;

struct range_disconnect_struct
       {
         OM_S_CHANSELECT      to_sel;
         int                  low_index;
         int                  hi_index;
       } range_disconnect_args;


half_A=MAXA/2; half_B=MAXB/2;

sts = om$runtime_init();
if (!(sts&1))
 {
  printf ("error in om$runtime_init: %x \n", sts );
  om$report_error(sts=sts);
  exit();
 }

chan_acb = "A.acb";
chan_bca = "B.bca";

/*
	Construct A's
*/
printf("\n>>> Table of A's object IDs::\n");
for (i=0; i<MAXA+1; i++)
 {
   sts = om$construct (osname="OM_TransOS_0",classname="A",	
					p_objid=&a_objid[i] );

  if (!(sts&1))
   {
    printf ("error in om$construct object A[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    exit();
   }
  printf("\n>>> A[%d]: %d",i,a_objid[i]);
 }
/*
	Construct B's
*/
printf("\n\n>>> Table of B's object IDs::\n");
for (i=0; i<MAXB+1; i++)
 {
   sts = om$construct (osname="OM_TransOS_0",classname="B",	
					p_objid=&b_objid[i] );

  if (!(sts&1))
   {
    printf ("error in om$construct object B[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    exit();
   }
  printf("\n>>> B[%d]: %d ",i,b_objid[i]);
 }
/*
	Connect last A to last B
*/
printf("\n\n>>> Connect Last A to Last B\n");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_bca;
	connect_args.to_idx = 0;
	connect_args.fr_objid = a_objid[MAXA];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_acb;
	connect_args.fr_idx            = 0;

	sts = om$make_message(classname = "Root",		
			      methodname = "connect",		
			      size = sizeof( struct connect_struct),
			      p_arglist = &connect_args,	
			      p_msg = &connect_msg );
	if(!(sts&1))
 	{
  	   printf("error in om$make_message for connect: %x\n",  sts);
  	   om$report_error(sts=sts);
  	   exit();
 	}
	sts = om$send (msg = &connect_msg,			
		       senderid = a_objid[MAXA],			
		       targetid = b_objid[MAXB] );

if (!(sts&1))
 {
  printf ("error in om$send msg=connect LAST A to LAST B: %x\n", i, sts );
  om$report_error(sts=sts);
  exit();
 }
/*
	Connect last half of B's to A[0]

*/
printf("\n\n>>> Connect last half of B's to A[0]");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_bca;
	connect_args.to_idx = 0;
	connect_args.fr_objid = a_objid[0];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_acb;
	connect_args.fr_idx            = 0;

for (i=half_B; i<MAXB; i++)
 {
	sts = om$send (msg = &connect_msg,			
		       senderid = a_objid[0],			
		       targetid = b_objid[i] );

  if (!(sts&1))
   {
    printf ("error in om$send msg=connect B[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    printf("iteration: %d\n", i);
    exit();
   }
 }
/*
	Connect last half of A's to B[0]

*/

printf("\n\n>>> Connect last half of A's to B[0]");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_acb;
	connect_args.to_idx = 0;
	connect_args.fr_objid = b_objid[0];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_bca;
	connect_args.fr_idx            = 0;

for (i=half_A; i<MAXA; i++)
 {
	sts = om$send (msg = &connect_msg,			
		       senderid = b_objid[0],			
		       targetid = a_objid[i] );

  if (!(sts&1))
   {
    printf ("error in om$send msg=connect A[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    printf("iteration: %d\n", i);
    exit();
   }
 }
/*
	Connect first half of B's to A[1]

  note: a many-to-many object existed for B[0] thus a connection between
	two many-to-many objects occurs

*/

printf("\n\n>>> Connect first half of B's to A[1]");
printf("\n>>>>>> note: an entry was inserted into B[0]'s bca channel");
printf("\n>>>>>>       linking itself to A[1]'s acb channel");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_bca;
	connect_args.to_idx = 0;
	connect_args.fr_objid = a_objid[1];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_acb;
	connect_args.fr_idx            = 0;

for (i=0; i<half_B; i++)
 {
	sts = om$send (msg = &connect_msg,			
		       senderid = a_objid[1],			
		       targetid = b_objid[i] );
 
  if (!(sts&1))
   {
    printf ("error in om$send msg=connect B[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    printf("iteration: %d\n", i);
    exit();
   }
 }
/*
	Connect first half of A's to B[1]

  note: a many-to-many connection existed for A[0] thus a connection between
	two many-to-many connections occurs

*/

printf("\n\n>>> Connect first half of A's to B[1]");
printf("\n>>>>>> note: an entry was inserted into A[0]'s acb channel");
printf("\n>>>>>>       linking itself to B[1]'s bca channel");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_acb;
	connect_args.to_idx = 0;
	connect_args.fr_objid = b_objid[1];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_bca;
	connect_args.fr_idx            = 0;

for (i=0; i<half_A; i++)
 {
	sts = om$send (msg = &connect_msg,			
		       senderid = b_objid[1],			
		       targetid = a_objid[i] );
 
  if (!(sts&1))
   {
    printf ("error in om$send msg=connect A[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    printf("iteration: %d\n", i);
    exit();
   }
 }
/*
	For each B dump relations
*/
printf("\n\n>>> For each B dump relations::\n");
for(i=0; i<MAXB+1; i++)
 {
  printf("\n>>> B[%d]:",i);
  sts = OMT_dump_relation( OM_Gw_current_OS, b_objid[i], chan_bca);
  if(!(sts&1))
   {
    printf("error in OMT_dump_relation for B[%d]: %x\n", i, sts);
    om$report_error(sts=sts);
    exit();
   }
 }
/*
	Make message to send to B objects
*/
sts = om$make_message(classname="B",methodname="show_b",p_msg=&showb);

if(!(sts&1))
 {
  printf("error in om$make_message for show_b: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Send message to all B objects connected on A[0]'s "acb" channel
*/
printf("\n>>> Send message to all B's connected on A[0]'s \"acb\" chan\n");
chansel.type = OM_e_name;
chansel.u_sel.name = "acb";
sts = om$send (msg=&showb,mode=OM_e_wrt_object,senderid=a_objid[0],
					p_chanselect=&chansel );
if(!(sts&1))
 {
  printf("error in om$send msg=show_b A[0]: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Send message to all B objects connected on A[1]'s "acb" channel
*/
printf("\n>>> Send message to all B's connected on A[1]'s \"acb\" chan\n");
chansel.type = OM_e_name;
chansel.u_sel.name = "acb";
sts = om$send (msg=&showb,mode=OM_e_wrt_object,senderid=a_objid[1],
					p_chanselect=&chansel );

if(!(sts&1))
 {
  printf("error in om$send msg= show_b A[1]: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	For each A dump relations
*/
printf("\n>>> For each A dump relations\n");
for(i=0; i<MAXA+1; i++)
 {
  printf("\n>>> A[%d]:",i);
  sts = OMT_dump_relation( OM_Gw_current_OS, a_objid[i], chan_acb);
  if(!(sts&1))
   {
    printf("error in OMT_dump_relation for A[%d]: %x\n", i, sts);
    om$report_error(sts=sts);
    exit();
   }
 }
/*
	Make message to send to A objects
*/
sts = om$make_message(classname="A",methodname="show_a",p_msg=&showa);

if(!(sts&1))
 {
  printf("error in om$make_message for show_a: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Send message to all A objects connected on B[0]'s "bca" channel
*/
printf("\n>>> Send message to all A's connected on B[0]'s \"bca\" chan\n");
chansel.type = OM_e_name;
chansel.u_sel.name = "bca";
sts = om$send (msg=&showa,mode=OM_e_wrt_object,senderid=b_objid[0],
					p_chanselect=&chansel );

if(!(sts&1))
 {
  printf("error in om$send msg= show_a B[0]: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Send message to all A objects connected on B[1]'s "bca" channel
*/
printf("\n>>> Send message to all A's connected on B[1]'s \"bca\" chan\n");
chansel.type = OM_e_name;
chansel.u_sel.name = "bca";
sts = om$send (msg=&showa,mode=OM_e_wrt_object,senderid=b_objid[1],
					p_chanselect=&chansel );

if(!(sts&1))
 {
  printf("error in om$send msg= show_a B[1]: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Disconnect the first A contained wihtin the last half of A's
	from it's associated B.

  note:	Remember that the last half of the A's were connected to B[0] (see above).
*/
printf("\n>>> Disconnect the 1st in the 2nd half of A from corresponding B\n");

     range_disconnect_args.to_sel.type = OM_e_name;
     range_disconnect_args.to_sel.u_sel.name = chan_acb;
     range_disconnect_args.low_index = 0;
     range_disconnect_args.hi_index = 0;

     sts = om$make_message(classname = "Root",		
		           methodname = "range_disconnect",		
			   size = sizeof( struct range_disconnect_struct),
			   p_arglist = &range_disconnect_args,	
			   p_msg = &range_disconnect_msg );
     
     sts = om$send (msg = &range_disconnect_msg,			
		    senderid = a_objid[half_A],			
	            targetid = a_objid[half_A]);

if (!(sts&1))
 {
  printf ("error in om$send msg=disconnect A[half_A] case: %x \n", sts );
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "acb" of A[half_A]
*/
printf("\n>>> Dump relations of the channel \"acb\" of A[half_A]\n");
printf("\n>>> A[%d]:",half_A);
sts = OMT_dump_relation( OM_Gw_current_OS, a_objid[half_A], chan_acb);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for A[half_A]: %x\n", sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "bca" for B[0]
*/
printf("\n>>> Dump relations of the channel \"bca\" of B[0] (A[MAXA/2])\n");
printf("\n>>>>>> note: \"A[half_A]\" was connected to B[0]");
printf("\n>>> B[0]:");
sts = OMT_dump_relation( OM_Gw_current_OS, b_objid[0], chan_bca);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for B[0] ( A[MAXA/2] case ): %x\n",i,sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Disconnect 1st half of objects connected to B[1]
*/
printf("\n>>> Disconnect 1st half of objects connected to B[1]\n");

     range_disconnect_args.to_sel.type = OM_e_name;
     range_disconnect_args.to_sel.u_sel.name = chan_bca;
     range_disconnect_args.low_index = 0;
     range_disconnect_args.hi_index = half_A/2;

     sts = om$send (msg = &range_disconnect_msg,			
		    senderid = b_objid[1],			
	            targetid = b_objid[1] );

if (!(sts&1))
 {
  printf ("error in om$disconnect range B[1] case: %x \n", sts );
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "bca" of B[1]
*/
printf("\n>>> Dump relations on the channel \"bca\" of B[1]\n");
sts = OMT_dump_relation( OM_Gw_current_OS, b_objid[1], chan_bca);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for B[1]: %x\n", sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations on channel "acb" of all A's
*/
printf("\n>>> Dump relations on channel \"acb\" of all A's\n");
for(i=0; i<MAXA+1; i++)
 {
  printf("\n>>> A[%d]:",i);
  sts = OMT_dump_relation( OM_Gw_current_OS, a_objid[i], chan_acb);
  if(!(sts&1))
   {
    printf("error in OMT_dump_relation for A[%d]: %x\n", i, sts);
    om$report_error(sts=sts);
    exit();
   }
 }
/*
	Disconnect All objects connected to A[0] on channel "acb"

  note: the last index of the relation is used if it is exceeded by the
	given "end" index

*/
printf("\n>>> Disconnect All objects connected to A[0] on channel \"acb\"\n");

     range_disconnect_args.to_sel.type = OM_e_name;
     range_disconnect_args.to_sel.u_sel.name = chan_acb;
     range_disconnect_args.low_index = 0;
     range_disconnect_args.hi_index = MAXB+99;

     sts = om$send (msg = &range_disconnect_msg,			
		    senderid = a_objid[0],			
	            targetid = a_objid[0] );

if (!(sts&1))
 {
  printf ("error in om$disconnect range A[0] case: %x \n", sts );
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "acb" of A[0]
*/
printf("\n>>> Dump relations of the channel \"acb\" of A[0]\n");
sts = OMT_dump_relation( OM_Gw_current_OS, a_objid[0], chan_acb);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for A[0]: %x\n", sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "bca" for all B's
*/
printf("\n>>> Dump relations of the channel \"bca\" for all B's\n");
for(i=0; i<MAXB+1; i++)
 {
  printf("\n>>> B[%d]:",i);
  sts = OMT_dump_relation( OM_Gw_current_OS, b_objid[i], chan_bca);
  if(!(sts&1))
   {
    printf("error in OMT_dump_relation for B[%d]: %x\n", i, sts);
    om$report_error(sts=sts);
    exit();
   }
 }
/*
	Disconnect LAST A from LAST B
*/
printf("\n>>> Disconnect LAST A from LAST B \"acb\"\n");
     range_disconnect_args.to_sel.type = OM_e_name;
     range_disconnect_args.to_sel.u_sel.name = chan_acb;
     range_disconnect_args.low_index = 0;
     range_disconnect_args.hi_index = MAXA;
     
     sts = om$send (msg = &range_disconnect_msg,			
		    senderid = a_objid[MAXA],			
	            targetid = a_objid[MAXA] );

if (!(sts&1))
 {
  printf ("error in om$disconnect range LAST A & B case: %x \n", sts );
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "acb" of A[MAXA]
*/
printf("\n>>> Dump relations of the channel \"acb\" of LAST A\n");
printf("\n>>> A[%d]:",MAXA);
sts = OMT_dump_relation( OM_Gw_current_OS, a_objid[MAXA], chan_acb);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for LAST A: %x\n", sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "bca" for B[MAXB]
*/
printf("\n>>> Dump relations of the channel \"bca\" of LAST B\n");
printf("\n>>> B[%d]:",MAXB);
sts = OMT_dump_relation( OM_Gw_current_OS, b_objid[MAXB], chan_bca);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for LAST B: %x\n", i, sts);
  om$report_error(sts=sts);
  exit();
 }

/*************************************************************/
/*		Restricted Section			     */
/*************************************************************/

printf("\n\n******************************************************\n");
printf("	     Restricted Tests\n");
printf("******************************************************\n\n");

chan_resacb = "ResA.acb";
chan_resbca = "ResB.bca";

/*
	Construct ResA's
*/

printf("\n>>> Table of ResA's object IDs::\n");
for (i=0; i<MAXA+1; i++)
 {
   sts = om$construct (osname="OM_TransOS_0",classname="ResA",	
					p_objid=&resa_objid[i] );

  if (!(sts&1))
   {
    printf ("error in om$construct object ResA[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    exit();
   }
  printf("\n>>> ResA[%d]: %d",i,resa_objid[i]);
 }

/*
	Construct ResB's
*/

printf("\n\n>>> Table of ResB's object IDs::\n");
for (i=0; i<MAXB+1; i++)
 {
   sts = om$construct (osname="OM_TransOS_0",classname="ResB",	
					p_objid=&resb_objid[i] );

  if (!(sts&1))
   {
    printf ("error in om$construct object ResB[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    exit();
   }
  printf("\n>>> ResB[%d]: %d ",i,resb_objid[i]);
 }

/*
	Connect last ResA to last ResB
*/

printf("\n\n>>> Connect Last ResA to Last ResB\n");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_resbca;
	connect_args.to_idx = 0;
	connect_args.fr_objid = resa_objid[MAXA];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_resacb;
	connect_args.fr_idx            = 0;

	sts = om$make_message(classname = "Root",		
			      methodname = "connect",		
			      size = sizeof( struct connect_struct),
			      p_arglist = &connect_args,	
			      p_msg = &connect_msg );
	if(!(sts&1))
 	{
  	   printf("error in om$make_message for connect: %x\n",  sts);
  	   om$report_error(sts=sts);
  	   exit();
 	}
	sts = om$send (msg = &connect_msg,			
		       senderid = resa_objid[MAXA],			
		       targetid = resb_objid[MAXB] );

if (!(sts&1))
 {
  printf ("error in om$send msg=connect LAST ResA to LAST ResB: %x\n", i,
sts );
  om$report_error(sts=sts);
  exit();
 }

/*
	Connect last half of ResB's to ResA[0]

*/

printf("\n\n>>> Connect last half of ResB's to ResA[0]");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_resbca;
	connect_args.to_idx = 0;
	connect_args.fr_objid = resa_objid[0];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_resacb;
	connect_args.fr_idx            = 0;

for (i=half_B; i<MAXB; i++)
 {
	sts = om$send (msg = &connect_msg,			
		       senderid = resa_objid[0],			
		       targetid = resb_objid[i] );

  if (!(sts&1))
   {
    printf ("error in om$send msg=connect ResB[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    printf("iteration: %d\n", i);
    exit();
   }
 }

/*
	Connect last half of ResA's to ResB[0]

*/

printf("\n\n>>> Connect last half of ResA's to ResB[0]");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_resacb;
	connect_args.to_idx = 0;
	connect_args.fr_objid = resb_objid[0];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_resbca;
	connect_args.fr_idx            = 0;

for (i=half_A; i<MAXA; i++)
 {
	sts = om$send (msg = &connect_msg,			
		       senderid = resb_objid[0],			
		       targetid = resa_objid[i] );

  if (!(sts&1))
   {
    printf ("error in om$send msg=connect ResA[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    printf("iteration: %d\n", i);
    exit();
   }
 }

/*
	Connect first half of ResB's to ResA[1]

  note: a many-to-many object existed for ResB[0] thus a connection between
	two many-to-many objects occurs

*/

printf("\n\n>>> Connect first half of ResB's to ResA[1]");
printf("\n>>>>>> note: an entry was inserted into ResB[0]'s bca channel");
printf("\n>>>>>>       linking itself to ResA[1]'s acb channel");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_resbca;
	connect_args.to_idx = 0;
	connect_args.fr_objid = resa_objid[1];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_resacb;
	connect_args.fr_idx            = 0;

for (i=0; i<half_B; i++)
 {
	sts = om$send (msg = &connect_msg,			
		       senderid = resa_objid[1],			
		       targetid = resb_objid[i] );
 
  if (!(sts&1))
   {
    printf ("error in om$send msg=connect ResB[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    printf("iteration: %d\n", i);
    exit();
   }
 }

/*
	Connect first half of ResA's to ResB[1]

  note: a many-to-many connection existed for ResA[0] thus a connection
between
	two many-to-many connections occurs

*/

printf("\n\n>>> Connect first half of ResA's to ResB[1]");
printf("\n>>>>>> note: an entry was inserted into ResA[0]'s acb channel");
printf("\n>>>>>>       linking itself to ResB[1]'s bca channel");

	connect_args.to_sel.type = OM_e_name;
	connect_args.to_sel.u_sel.name = chan_resacb;
	connect_args.to_idx = 0;
	connect_args.fr_objid = resb_objid[1];
	connect_args.fr_os = OM_Gw_current_OS;
	connect_args.fr_sel.type = OM_e_name;
	connect_args.fr_sel.u_sel.name = chan_resbca;
	connect_args.fr_idx            = 0;

for (i=0; i<half_A; i++)
 {
	sts = om$send (msg = &connect_msg,			
		       senderid = resb_objid[1],			
		       targetid = resa_objid[i] );
 
  if (!(sts&1))
   {
    printf ("error in om$send msg=connect ResA[%d]: %x \n", i, sts );
    om$report_error(sts=sts);
    printf("iteration: %d\n", i);
    exit();
   }
 }

/*
	For each ResB dump relations
*/

printf("\n\n>>> For each ResB dump relations::\n");
for(i=0; i<MAXB+1; i++)
 {
  printf("\n>>> ResB[%d]:",i);
  sts = OMT_dump_relation( OM_Gw_current_OS, resb_objid[i], chan_resbca);
  if(!(sts&1))
   {
    printf("error in OMT_dump_relation for ResB[%d]: %x\n", i, sts);
    om$report_error(sts=sts);
    exit();
   }
 }

/*
	Make message to send to ResB objects
*/

sts = om$make_message(classname="ResB",methodname="show_b",p_msg=&showb);

if(!(sts&1))
 {
  printf("error in om$make_message for show_b: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }

/*
	Send message to all ResB objects connected on ResA[0]'s "acb" channel
*/

printf("\n>>> Send message to all ResB's connected on ResA[0]'s \"acb\" chan\n");
chansel.type = OM_e_name;
chansel.u_sel.name = "ResA.acb";
sts = om$send (msg=&showb,mode=OM_e_wrt_object,senderid=resa_objid[0],
					p_chanselect=&chansel );
if(!(sts&1))
 {
  printf("error in om$send msg=show_b ResA[0]: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }

/*
	Send message to all ResB objects connected on ResA[1]'s "acb" channel
*/

printf("\n>>> Send message to all ResB's connected on ResA[1]'s \"acb\" chan\n");
chansel.type = OM_e_name;
chansel.u_sel.name = "ResA.acb";
sts = om$send (msg=&showb,mode=OM_e_wrt_object,senderid=resa_objid[1],
					p_chanselect=&chansel );

if(!(sts&1))
 {
  printf("error in om$send msg= show_b ResA[1]: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }

/*
	For each ResA dump relations
*/

printf("\n>>> For each ResA dump relations\n");
for(i=0; i<MAXA+1; i++)
 {
  printf("\n>>> ResA[%d]:",i);
  sts = OMT_dump_relation( OM_Gw_current_OS, resa_objid[i], chan_resacb);
  if(!(sts&1))
   {
    printf("error in OMT_dump_relation for ResA[%d]: %x\n", i, sts);
    om$report_error(sts=sts);
    exit();
   }
 }

/*
	Make message to send to ResA objects
*/

sts = om$make_message(classname="ResA",methodname="show_a",p_msg=&showa);

if(!(sts&1))
 {
  printf("error in om$make_message for show_a: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }

/*
	Send message to all ResA objects connected on ResB[0]'s "bca" channel
*/

printf("\n>>> Send message to all ResA's connected on ResB[0]'s \"bca\" chan\n");
chansel.type = OM_e_name;
chansel.u_sel.name = "ResB.bca";
sts = om$send (msg=&showa,mode=OM_e_wrt_object,senderid=resb_objid[0],
					p_chanselect=&chansel );

if(!(sts&1))
 {
  printf("error in om$send msg= show_a ResB[0]: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }

/*
	Send message to all ResA objects connected on ResB[1]'s "bca" channel
*/

printf("\n>>> Send message to all ResA's connected on ResB[1]'s \"bca\" chan\n");
chansel.type = OM_e_name;
chansel.u_sel.name = "ResB.bca";
sts = om$send (msg=&showa,mode=OM_e_wrt_object,senderid=resb_objid[1],
					p_chanselect=&chansel );

if(!(sts&1))
 {
  printf("error in om$send msg= show_a ResB[1]: %x\n",  sts);
  om$report_error(sts=sts);
  exit();
 }

/*
	Disconnect the first ResA contained wihtin the last half of ResA's
	from it's associated ResB.

  note:	Remember that the last half of the ResA's were connected to
ResB[0] (see above).
*/

printf("\n>>> Disconnect the 1st in the 2nd half of ResA from corresponding ResB\n");

     range_disconnect_args.to_sel.type = OM_e_name;
     range_disconnect_args.to_sel.u_sel.name = chan_resacb;
     range_disconnect_args.low_index = 0;
     range_disconnect_args.hi_index = 0;

     sts = om$make_message(classname = "Root",		
		           methodname = "range_disconnect",		
			   size = sizeof( struct range_disconnect_struct),
			   p_arglist = &range_disconnect_args,	
			   p_msg = &range_disconnect_msg );
     
     sts = om$send (msg = &range_disconnect_msg,			
		    senderid = resa_objid[half_A],			
	            targetid = resa_objid[half_A]);

if (!(sts&1))
 {
  printf ("error in om$send msg=disconnect ResA[half_A] case: %x \n",
sts );
  om$report_error(sts=sts);
  exit();
 }

/*
	Dump relations of the channel "acb" of ResA[half_A]
*/

printf("\n>>> Dump relations of the channel \"acb\" of ResA[half_A]\n");
printf("\n>>> ResA[%d]:",half_A);
sts = OMT_dump_relation( OM_Gw_current_OS, resa_objid[half_A], chan_resacb);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for ResA[half_A]: %x\n", sts);
  om$report_error(sts=sts);
  exit();
 }

/*
	Dump relations of the channel "bca" for ResB[0]
*/

printf("\n>>> Dump relations of the channel \"bca\" of ResB[0] (ResA[MAXA/2])\n");
printf("\n>>>>>> note: \"ResA[half_A]\" was connected to ResB[0]");
printf("\n>>> ResB[0]:");
sts = OMT_dump_relation( OM_Gw_current_OS, resb_objid[0], chan_resbca);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for ResB[0] ( ResA[MAXA/2] case ): %x\n",i,sts);
  om$report_error(sts=sts);
  exit();
 }

/*
	Disconnect 1st half of objects connected to ResB[1]
*/

printf("\n>>> Disconnect 1st half of objects connected to ResB[1]\n");

     range_disconnect_args.to_sel.type = OM_e_name;
     range_disconnect_args.to_sel.u_sel.name = chan_resbca;
     range_disconnect_args.low_index = 0;
     range_disconnect_args.hi_index = half_A/2;

     sts = om$send (msg = &range_disconnect_msg,			
		    senderid = resb_objid[1],			
	            targetid = resb_objid[1] );

if (!(sts&1))
 {
  printf ("error in om$disconnect range ResB[1] case: %x \n", sts );
  om$report_error(sts=sts);
  exit();
 }

/*
	Dump relations of the channel "bca" of ResB[1]
*/

printf("\n>>> Dump relations on the channel \"bca\" of ResB[1]\n");
sts = OMT_dump_relation( OM_Gw_current_OS, resb_objid[1], chan_resbca);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for ResB[1]: %x\n", sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations on channel "acb" of all ResA's
*/
printf("\n>>> Dump relations on channel \"acb\" of all A's\n");
for(i=0; i<MAXA+1; i++)
 {
  printf("\n>>> ResA[%d]:",i);
  sts = OMT_dump_relation( OM_Gw_current_OS, resa_objid[i], chan_resacb);
  if(!(sts&1))
   {
    printf("error in OMT_dump_relation for ResA[%d]: %x\n", i, sts);
    om$report_error(sts=sts);
    exit();
   }
 }

/*
	Disconnect All objects connected to ResA[0] on channel "acb"

  note: the last index of the relation is used if it is exceeded by the
	given "end" index

*/
printf("\n>>> Disconnect All objects connected to ResA[0] on channel \"acb\"\n");

     range_disconnect_args.to_sel.type = OM_e_name;
     range_disconnect_args.to_sel.u_sel.name = chan_resacb;
     range_disconnect_args.low_index = 0;
     range_disconnect_args.hi_index = MAXB+99;

     sts = om$send (msg = &range_disconnect_msg,			
		    senderid = resa_objid[0],			
	            targetid = resa_objid[0] );

if (!(sts&1))
 {
  printf ("error in om$disconnect range ResA[0] case: %x \n", sts );
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "acb" of A[0]
*/
printf("\n>>> Dump relations of the channel \"acb\" of ResA[0]\n");
sts = OMT_dump_relation( OM_Gw_current_OS, resa_objid[0], chan_resacb);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for ResA[0]: %x\n", sts);
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "bca" for all ResB's
*/
printf("\n>>> Dump relations of the channel \"bca\" for all ResB's\n");
for(i=0; i<MAXB+1; i++)
 {
  printf("\n>>> ResB[%d]:",i);
  sts = OMT_dump_relation( OM_Gw_current_OS, resb_objid[i], chan_resbca);
  if(!(sts&1))
   {
    printf("error in OMT_dump_relation for ResB[%d]: %x\n", i, sts);
    om$report_error(sts=sts);
    exit();
   }
 }

/*
	Disconnect LAST A from LAST ResB
*/
printf("\n>>> Disconnect LAST ResA from LAST ResB \"acb\"\n");
     range_disconnect_args.to_sel.type = OM_e_name;
     range_disconnect_args.to_sel.u_sel.name = chan_resacb;
     range_disconnect_args.low_index = 0;
     range_disconnect_args.hi_index = MAXA;
     
     sts = om$send (msg = &range_disconnect_msg,			
		    senderid = resa_objid[MAXA],			
	            targetid = resa_objid[MAXA] );

if (!(sts&1))
 {
  printf ("error in om$disconnect range LAST ResA & ResB case: %x \n", sts
);
  om$report_error(sts=sts);
  exit();
 }
/*
	Dump relations of the channel "acb" of ResA[MAXA]
*/
printf("\n>>> Dump relations of the channel \"acb\" of LAST ResA\n");
printf("\n>>> ResA[%d]:",MAXA);
sts = OMT_dump_relation( OM_Gw_current_OS, resa_objid[MAXA], chan_resacb);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for LAST ResA: %x\n", sts);
  om$report_error(sts=sts);
  exit();
 }

/*
	Dump relations of the channel "bca" for ResB[MAXB]
*/

printf("\n>>> Dump relations of the channel \"bca\" of LAST ResB\n");
printf("\n>>> ResB[%d]:",MAXB);
sts = OMT_dump_relation( OM_Gw_current_OS, resb_objid[MAXB], chan_resbca);
if(!(sts&1))
 {
  printf("error in OMT_dump_relation for LAST ResB: %x\n", i, sts);
  om$report_error(sts=sts);
  exit();
 }

}
Esempio n. 6
0
	SealData::SealData()
	{
		construct();
	}
Esempio n. 7
0
	SealData::SealData(const std::string & path, float piece_size)
	{
		construct();
		load(path, piece_size);
	}
Esempio n. 8
0
WndText::WndText( const QString & i_name, const std::string & i_str):
	Wnd( i_name)
{
	construct();
	insertText( i_str);
}
StringWrapper::StringWrapper(const StringWrapper& other)
	: value(other.value)
{
	construct();
}
Esempio n. 10
0
WndText::WndText( const QString & i_name):
	Wnd( i_name)
{
	construct();
}
Esempio n. 11
0
WndText::WndText( const QString & i_name, af::Msg * i_msg):
	Wnd( i_name)
{
	construct();
	caseMsg( i_msg);
}
Esempio n. 12
0
 index_wcsearch3(collection& col)
 {
     sdsl::cache_config cc(false,".","WCSEARCH_TMP");
     construct(index, col.file_map[consts::KEY_TEXT], cc, 0);
 }
 TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
     return construct(preorder, inorder, 0, preorder.size()-1, 0, inorder.size()-1);
 }
Esempio n. 14
0
bool ConcurrentTableSharedStore::store(const String& key, CVarRef value,
                                       int64_t ttl,
                                       bool overwrite /* = true */,
                                       bool limit_ttl /* = true */) {
  StoreValue *sval;
  APCHandle* svar = construct(value);
  ConditionalReadLock l(m_lock, !apcExtension::ConcurrentTableLockFree ||
                                m_lockingFlag);
  const char *kcp = strdup(key.data());
  bool present;
  time_t expiry = 0;
  bool overwritePrime = false;
  {
    Map::accessor acc;
    present = !m_vars.insert(acc, kcp);
    sval = &acc->second;
    bool update = false;
    if (present) {
      free((void *)kcp);
      if (overwrite || sval->expired()) {
        // if ApcTTLLimit is set, then only primed keys can have expiry == 0
        overwritePrime = (sval->expiry == 0);
        if (sval->inMem()) {
          stats_on_update(key.get(), sval, svar,
                          adjust_ttl(ttl, overwritePrime || !limit_ttl));
          sval->var->decRef();
          update = true;
        } else {
          // mark the inFile copy invalid since we are updating the key
          sval->sAddr = nullptr;
          sval->sSize = 0;
        }
      } else {
        svar->decRef();
        return false;
      }
    }
    int64_t adjustedTtl = adjust_ttl(ttl, overwritePrime || !limit_ttl);
    if (check_noTTL(key.data(), key.size())) {
      adjustedTtl = 0;
    }
    sval->set(svar, adjustedTtl);
    expiry = sval->expiry;
    if (!update) {
      stats_on_add(key.get(), sval, adjustedTtl, false, false);
    }
  }
  if (expiry) {
    addToExpirationQueue(key.data(), expiry);
  }
  if (apcExtension::ExpireOnSets) {
    purgeExpired();
  }
  if (present) {
    log_apc(std_apc_update);
  } else {
    log_apc(std_apc_new);
    if (RuntimeOption::EnableStats && RuntimeOption::EnableAPCKeyStats) {
      string prefix = "apc.new." + GetSkeleton(key);
      ServerStats::Log(prefix, 1);
    }
  }
  return true;
}
Esempio n. 15
0
/*! \reimp */
QSObject QSFuncRefClass::cast(const QSList &args) const
{
  return construct(args);
}
StringWrapper::StringWrapper(const StringWrapper& other, size_t pos, size_t n)
	: value(other.value, pos, n)
{
	construct();
}
/**
 * Create the input set: an array of given size with random strings. 
 *
 * use character-swapping algorithm from strfry.c in glibc
 * 
 * http://www.koders.com/c/fidBD83E492934F9F671DE79B11E6AC0277F9887CF5.aspx
 */
void prepareInput (int size, int argc, char **argv) {
  int i, failed, failedIdx, cycleIdx;
  char ch;
  int *integers;
  int sameId = 0;
  int numInCollection = 1000;

  int done = 0;
  opterr = 0;   /* disable errors */
  while (!done && (ch = getopt(argc, argv, "op:fsz:")) != -1) {
    switch (ch) {
      
    case 'p':
      p = atof(optarg);
      break;

    case 's':
      sameId = 1;
      break;

    case 'f':
      first = 1;
      break;

    case 'z':
      numInCollection = atoi(optarg);
      break;

    case '?':
      done = 1;
      break;
    }
  }

  optind = 0;  /* reset getopt for next time around */

  /* -n is the number of queries. */

  /* create integer collection, populated from range [0,numInCollection). */
  integers = calloc (numInCollection, sizeof (int));
  for (i = 0; i < numInCollection; i++) {
    integers[i] = i;
  }

  /* create searchList by cycling through all numbers */
  cycleIdx = 0;
  searchList = (int *) calloc (numElements, sizeof(int));
  for (i = 0; i < numElements; i++) {
    searchList[i] = cycleIdx++;
    if (cycleIdx >= numInCollection) {
      cycleIdx = 0;
    }
  }

  /* now go through and ensure proper number are failed. */
  failed = (int)((1-p)*numElements);
  failedIdx = -1;
				     
  for (i = 0; i < failed; i++) {
    searchList[i] = failedIdx;
    if (sameId) { failedIdx--;  }
  }

  /* Ensure all queries are first. */
  if (first) {
    for (i = 0; i < numElements; i++) {
      searchList[i] = integers[0];
    }
  }

  construct (numInCollection);
  for (i = 0; i < numInCollection; i++) {
    insert(integers[i]);
  }
}
StringWrapper::StringWrapper(const char* cString)
	: value(cString)
{
	construct();
}
Esempio n. 19
0
	SealData::SealData(const char * path, float piece_size)
	{
		construct();
		load(path, piece_size);
	}
// TODO: These are going to die when using CharWrappers
StringWrapper::StringWrapper(const char* cString, size_t n)
	: value(cString, n)
{
	construct();
}
Esempio n. 21
0
AudioSink_base::AudioSink_base(const char *uuid, const char *label) :
                                     Resource_impl(uuid, label), serviceThread(0) {
    construct();
}
StringWrapper::StringWrapper(size_t n, char c)
	: value(n, c)
{
	construct();
}
Esempio n. 23
0
ATCommand::ATCommand()
{
    mHexOutput = false;

    construct();
}
StringWrapper::StringWrapper() 
{
	construct();
}
Esempio n. 25
0
int
main(void) {
  StackList  object;
  StackListIter *ptr;
  unsigned int x, y;
  unsigned int *value;
  memset(&object, 0, sizeof (object));
  x = RUNS;
  construct(StackList, &object,sizeof(x),FREEOBJ);
  set_alloc(StackList,  &object, ckalloc);
  set_dealloc(StackList,  &object, ckfree);
  set_compare(StackList,  &object, intcmp);
  set_print(StackList,  &object, print);
  for (y = 0; y < x; y++) {
    srand((x * y) / (x - y) + (x + y / x));
    switch ((rand() % NUMCASES) + BASE) {
        case 0:
        case 10:
        case 11:
        case 1:
        case 12:
        case 13:
        case 2:
          value = ckalloc(sizeof *value);
          *value = rand() % BOUND;
          push(StackList,  &object, value, DYNAMIC);
          break;
        case 3:
        case 15:
        case 4:
        case 5:
        case 6:
        case 16:
          pop(StackList,  &object);
          break;
        case 14:
        case 7:
        case 17:
        case 8:
        case 9:
          top(StackList,  &object);
          break;
        default:
          break;
    };
  }
  destruct(StackList,  &object);
  fprintf(stderr, "Now testing the iterators!\n");
  construct_func(StackList,&object, sizeof(x),FREEOBJ, ckalloc, ckfree, intcmp,  print,
                 memcpy);
  for (x = 0; x < RUNS; x++) {
	  value = ckalloc(sizeof *value);
	  *value = rand();
    push(StackList,  &object, value, DYNAMIC);
  }

  ptr = create(StackListIter,  &object);
  head(StackListIter, ptr);
  do {
    value = (unsigned int *) retrieve(StackListIter, ptr);
  }
  while (!next(StackListIter, ptr));
  assign(StackListIter, ptr, &object);
  tail(StackListIter, ptr);
  do {
    value = (unsigned int *) retrieve(StackListIter, ptr);
  } while (!prev(StackListIter, ptr));
  for(x = 0; x < RUNS; x++) {
	  switch(rand() % 2) {
		  case 1:
			  next(StackListIter,ptr);
			  break;
		  case 2:
			  prev(StackListIter,ptr);
			  break;
	  }
  }
  destroy(StackListIter, ptr);
  destruct(StackList,  &object);
  return EXIT_SUCCESS;
}
Esempio n. 26
0
/**
 * Create the input set: an array of given size with random strings. 
 *
 * use character-swapping algorithm from strfry.c in glibc
 * 
 * http://www.koders.com/c/fidBD83E492934F9F671DE79B11E6AC0277F9887CF5.aspx
 *
 */
void prepareInput (int size, int argc, char **argv) {
  int j, idx, ct, pk, numPad;
  char ch;
  char **strings, *paddedString;

  int done = 0;
  opterr = 0;   /* disable errors */
  while (!done && (ch = getopt(argc, argv, "p:d:k:fz:")) != -1) {
    switch (ch) {
      
    case 'p':
      p = atof(optarg);
      break;

    case 'd':
      if (!strcmp ("u", optarg)) {
	distrib=UNIFORM;
      } else if (!strcmp ("w", optarg)) {
	distrib=WEIGHTED;
      }
      break;

    case 'k':
      elementSize = atoi(optarg);
      break;
	
    case 'f':
      first = 1;
      break;

    case 'z':
      z = atof(optarg);
      break;

    case '?':
      done = 1;
      break;
    }
  }
  optind = 0;  /* reset getopt for next time around */

  strings = materializeStrings();

  /* construct DS collection: This is the linear list over which we are
   * searching.  the goal is to ensure that this collection has exactly z
   * elements.  if z = 2^k then all strings in the domain are present in
   * C. If z < 2^k then some legal strings are simply not present. If z >
   * 2^k then the collection contains extra strings of length k that are
   * guaranteed not to belong to the domain Sk (for example, if k=6 then
   * one of these extra strings could be "c00001").
   */
  pk = (int) pow (2, elementSize);
  numPad = 0;
  if (z > pk) {
    /* we will have to pad with known failures missing strings.
     * note that this will have to be a random act. Tricky. */
    numPad = z-pk;
  }

  construct(z);
  elementsInC = (char **) calloc (z, sizeof (char *));

  /* make sure we have 24*z as number of elements */
  numElements = 24*z; 

  idx = pk;
  ct = 0;

  /* create a string that can't belong in Sk. Each time this string is
   * accessed, we bump up the ctr from the right, even if we roll over to
   * the first char, we will never get back to the 'a'. */
  paddedString = calloc(elementSize+1, sizeof(char));
  paddedString[0]='c';
  for (j = 1; j < elementSize; j++) { paddedString[j]=(char)1;}

  while (ct < z) {
    char *ins = 0;
    /* add a real string or a padded string? Randomly choose, unless we are
     * out of real strings (idx==0) */

    if ((numPad > 0 && ((float)rand())/RAND_MAX < 0.5) || (idx==0)) {
      /* padded string */
      ins = strdup(paddedString);
      insert (ins);

      numPad--;
      rotate(paddedString);
   } else {
     /* real string */
     j = (int) (idx * (rand() / (RAND_MAX + 1.0)));

     /* each search problem must provide its own insert method. */
     ins = strings[j];
     insert (ins);

     strings[j] = strings[idx-1];
     strings[idx-1] = '\0';
     idx--;
   }

    /* record for later, if -f is an option selected */
    if (firstInserted == 0) {
      firstInserted = strdup (ins);
    }

    if (verbose) {
      printf ("ins:%s\n", ins);
    }

    /* maintain copy for later use in constructing SL, regardless of
     * what underlying set is using it for.  */
    elementsInC[ct++] = strdup (ins);
  }

  /* These are the items that we are looking for. Only create if 'first'
   * was not selected, otherwise fill that entire list with firstInserted */
  if (first) {
    int i;
    searchList = (char **) calloc (numElements, sizeof(char *));
    for (i = 0; i < numElements; i++) {
      searchList[i] = firstInserted;
    }
  } else {
    constructSearchList();
  }
}
 Node* construct(vector<vector<int>>& grid) {
     if (grid.size() == 0) {
         return nullptr;
     }
     return construct(grid, 0, 0, grid.size() - 1, grid.size() - 1);
 }
Esempio n. 28
0
	GUIWidget::GUIWidget(const HCamera& camera)
		: mCamera(camera->_getCamera()), mPanel(nullptr), mDepth(0), mIsActive(true), mPosition(BsZero)
		, mRotation(BsIdentity), mScale(Vector3::ONE), mTransform(BsIdentity), mCachedRTId(0), mWidgetIsDirty(false)
	{
		construct(mCamera);
	}
Esempio n. 29
0
	GUIWidget::GUIWidget(const HCamera& camera)
		: mCamera(camera->_getCamera()), mPanel(nullptr), mDepth(0), mIsActive(true), mTransform(Matrix4::IDENTITY)
		, mCachedRTId(0), mWidgetIsDirty(false)
	{
		construct(mCamera);
	}
 NSFState::NSFState(const NSFString& name, NSFRegion* parentRegion, const NSFVoidAction<NSFStateMachineContext>& entryAction, NSFVoidAction<NSFStateMachineContext>* exitAction)
     : NSFTaggedObject(name), EntryActions(entryAction), ExitActions(exitAction), active(false), logEntry(true), parentRegion(parentRegion)
 {
     construct();
 }