Beispiel #1
0
bool RunPackage::actionParser(char* s) const
{
  // send plain text to the log
  if ( strcmp(s, "Text") == 0){

    char* tok = strtok(NULL, "}");
    LogMessage msg;
    msg << tok;
    msg.send();
   
    return true;
  }
   
  // create a file link 
  if (strcmp(s, "Link") == 0){
    
    char* text = strtok(NULL, ",");
    char* filename = strtok(NULL, "}");
    
    LogMessage msg1;
    msg1 << Link(Chars( text ),
		 "Package",Chars(filename), true );
    msg1.send();
    
    ofstream colorf(Chars(filename)+Chars(".color"),ios::app);
    colorf << "#0000000%000@" << flush;
    colorf.close();
  
    return true;
  }



  
  // Create an object in the workspace
  if (strncmp("Create", s, strlen("Create")) == 0 ){
    
    // get object description and parent
    char* description = strtok(NULL, "|");
    
    Chars errMsg;

    // create a group
    if (strcmp(s, "CreateGroup")==0){
      FPGroup G;
      //@njz
      //      strstream ss;
      std::strstream ss;
      //
      ss << description << endl;
      ss >> G;
      
      SMFPGroup* smo =
	new SMFPGroup( G,Text("The group created from a package") );
      
      
      ListOf<OID> dependencies;
      CheckinMessage( *smo, "", dependencies ).send();
      return true;
    } else { // if not a group than ...
void SGListExtractOfRankARCer::runComputation( )
{
#if SAFETY > 0
  if( ! theIterator )
    error( "void SGListExtractOfRankARCer::runComputation( ) : "
	   "fileIterator must be initialized first.");
#endif
  int counter = 1;
  theData.setWriteMode();

  for (theIterator->reset();!theIterator->EOL();theIterator->nextCell()){
    int rank;
    VectorOf<Word> v =  theIterator->getData().generators();

    if (theGroup->getCheckinType() == SMFPGroup::FREE )
      rank = indexInFreeGroup( v );
    else
      error("void SGListExtractOfRankARCer::runComputation( ) : "
	    "defined only for free groups.");

    if ( rank >= minRank && rank <= maxRank ){
      theData << EnumWriteVectorOfWords( v, theGroup->getFPGroup() ) 
	      << Chars("\nRank :") << Chars(rank)
	      << Chars("\n\n");
      counter ++;
    }
  }
  theData.closeCurrentMode(); 
  
}
void SGListExtractOfRank::takeControl( )
{
  if (freeARCs() > 0){
    int min = getParameters().getValue("minRank");
    int max = getParameters().getValue("maxRank");
    
    if (arcer.takeControl()){
      SMList<Subgroup>* smo = 
	new  SMList<Subgroup>(theList.getGroup(),
			      arcer.getData(),
			      Text("Subgroups of rank from ") +
			      Text(Chars(min)+Chars(" to ")+Chars(max)+
				   Chars(" in ")) + 
			      Name(theList)
			      ); 
      
      ListOf<OID> dependencies( smo->getGroup() );
      CheckinMessage( *smo, "", dependencies ).send();
      
      LogMessage msg( *smo );
      msg << Link( Chars("Click here to see the contents of ") + 
		   Text( Name( *smo) ),
		   "SGEnumerator",
		   smo->getData().getDataFileName() 
		   );
      msg << ".";
      msg.send();	
    
      adminTerminate();
      return;
    }
    else
      usedOneARC();
  }
}
void SMListExtractProperPowerInFree::takeControl( )
{
  if ( freeARCs() > 0 ) {
    if ( arcer.takeControl() ){
      SMList<Word>* smo = 
	new  SMList<Word>(theList.getGroup(),
			  arcer.getData(),
			  Text("Proper powers from") + Name(theList) 
			  ); 
      
      ListOf<OID> dependencies( smo->getGroup() );
      CheckinMessage( *smo, "", dependencies ).send();
      
      LogMessage msg( *smo );
      msg << Link( Chars("Click here to see the contents of ") + 
		   Text( Name( *smo) ),
		   "WEnumerator",
		   smo->getData().getDataFileName() 
		   );
      msg << ".";
      msg.send();
      adminTerminate();
      return;
    } else 
      usedOneARC();
  }
}
void MapListExtractInner::takeControl( )
{
  if (freeARCs() > 0){
    if (arcer.takeControl()){
      SMList<Map>* smo = 
	new  SMList<Map>(theList.getGroup(),
			      arcer.getData(),
			      Text("Inner automorphisms from ") + Name(theList)
			      ); 
      
      ListOf<OID> dependencies( smo->getGroup() );
      CheckinMessage( *smo, "", dependencies ).send();
      
      LogMessage msg( *smo );
      msg << Link( Chars("Click here to see the contents of ") + 
		   Text( Name( *smo) ),
		   "RandomAutomorphisms",
		   smo->getData().getDataFileName() 
		   );
      msg << ".";
      msg.send();	
      
      adminTerminate();
      return;
    }
    else
      usedOneARC();
  }
}
Beispiel #6
0
FStringData *FStringData::MakeCopy ()
{
	FStringData *copy = Alloc (Len);
	copy->Len = Len;
	FString::StrCopy (copy->Chars(), Chars(), Len);
	return copy;
}
void SGListExtractNormal::takeControl( )
{
  if (freeARCs() > 0){
    if (arcer.takeControl()){
      SMList<Subgroup>* smo = 
	new  SMList<Subgroup>(theList.getGroup(),
			      arcer.getData(),
			      Text("Normal subgroups in ") + Name(theList)
			      ); 
      
      ListOf<OID> dependencies( smo->getGroup() );
      CheckinMessage( *smo, "", dependencies ).send();
      
      LogMessage msg( *smo );
      msg << Link( Chars("Click here to see the contents of ") + 
		   Text( Name( *smo) ),
		   "SGEnumerator",
		   smo->getData().getDataFileName() 
		   );
      msg << ".";
      msg.send();	
      
      adminTerminate();
      return;
    }
    else
      usedOneARC();
  }
}
Beispiel #8
0
void EditPackage::takeControl( )
{
  Packages ps;
  ListOf<ParamRecord> params;
  PackageRecord r = ps.getPackage(theObject, theIndex,params);

  ListIterator<ListOf<ParamRecord> > I(params);
  for (I.reset();!I.done();I.next()) {
   LogMessage msg;
   msg <<    "Parameters :  " << I.value().getName() << ", type " << int(I.value().getType());
   msg.send();
  }

  if ( theAction == Chars("delete") ) {
    ps.deletePackage( theObject, theIndex );
    theObject->addPackagesToMenu();
    
    LogMessage msg1;
    msg1 <<  "Package \\\"" << r.getName() <<"\\\" was deleted.";
    msg1.send();
  } else {
    Chars obj_name = theObject->getObjectName();
    PackageInfoMessage  msg(r.getName(),r.getCommand(),
			    Packages::getCheckinTypeName(r.getCheckinSelection()), 
			    obj_name);
    msg.send();
  }
}
void SGListExtractOfRank::start( ) {              

  int min = getParameters().getValue("minRank");
  int max = getParameters().getValue("maxRank");

  arcer.setMinimalRank(min);
  arcer.setMaximalRank(max);
  LogMessage msg( *this, theList );
  
  msg << Link(Chars( "Click here to see subgroups of rank from ") +
	      Chars(min) +Chars(" to ") +
	      Chars(max) + Chars(" in ") +
	      Text( Name( theList ) ),
	      "SGEnumerator",
	      arcer.getData().getDataFileName(),true );
  
  msg.send();        
}
void SGListExtractMalnormal::start( ) {              
  LogMessage msg( *this, theList );
  
  msg << Link(Chars( "Click here to see malnormal subgroups in ") +
	      Text( Name( theList ) ),
	      "SGEnumerator",
	      arcer.getData().getDataFileName(),true );
  
  msg.send();   
}
void MapListExtractInner::start( ) {              
  LogMessage msg( *this, theList );
  
  msg << Link(Chars( "Click here to see inner automorphisms in ") +
	      Text( Name( theList ) ),
	      "RandomAutomorphisms",
	      arcer.getData().getDataFileName(),true );
  
  msg.send();   
}
Beispiel #12
0
SMListData::SMListData( ): number_of_elements(0), mode( -1 ) 
{ 
  // get name for the data file
  char* tmpFileName = tempnam(MagnusTmp::magnusTmp(),NULL);
  dataFileName = Chars( tmpFileName );
  
  // makes an empty color file for front end maybe needs to be changed
  //const char* destColor = Chars( dataFileName ) + Chars(".color");
  Chars destColor = Chars( tmpFileName ) + Chars(".color");
  ofstream outColor( destColor );
  outColor << "#0000000%000@" << flush;
  outColor.close();
  free(tmpFileName);

  // get name for the referencies file
  tmpFileName = tempnam(MagnusTmp::magnusTmp(),NULL);
  refFileName = Chars( tmpFileName );
  free(tmpFileName);
  

}
void SMListExtractProperPowerInFree::start( )
{
  LogMessage msg( *this, theList );
  msg << Link( Chars("Click here to see proper powers from ") + 
	       Text( Name( theList ) ),
	       "WEnumerator",
	       arcer.getData().getDataFileName() ,
	       true
	       );
  msg << ".";
  msg.send();	
}
void SMListProperPowerInFreeARCer::runComputation( )
{
  int counter = 1;
  theData.setWriteMode();
  for ( theIterator->reset();!theIterator->EOL();theIterator->nextCell() ){
    Word w = theIterator->getData().cyclicallyReduce();
    if ( w.isProperPower() ) {
      theData << EnumWriteWord( w,theGroup) << Chars("\n\n");
      counter++;
    }
  }
  theData.closeCurrentMode();  
}
bool PresentationParser::getRangeOf( const Chars& name ,Chars& c, int& n){
  char last = name[name.length()-1];
  // If last char is not a number 
  if ( !(last >= '0' && last <= '9') ) return false;
  bool endOfNum = false;
  Chars charPart;
  Chars numPart;
  for (int i = name.length()-1;i>=0;i--){
    char ch = name[i];
    if(!endOfNum && (ch >= '0' && ch <= '9'))
      numPart = Chars(ch)+numPart;
    else {
      endOfNum = true;
      charPart = Chars(ch)+charPart;
    }
  }
  // If name consists of numbers only
  if (!endOfNum) return false;
  c = charPart;
  n = atoi(numPart);
  return true;
}
Beispiel #16
0
  // returns i-th element as a character. 
  // Iterator must parse it to the corresponding data type
Chars SMListData::getElementOf( int i )
{
  int beg_pos = getBegPosOf( i );
  int size = getLengthOf( i );

  Chars ret;
  
  char* el = new char[size + 1];

  dataFile.seekg( beg_pos );
  dataFile.read( el, size );

  el[size] = '\0';
  ret = Chars( el );
  delete [] el;
  return ret;   
}
VectorOf<Chars> PresentationParser::parseGeneratorList( Chars& errMesg )
{
  VectorOf<Chars> result;

  if ( curToken == INIT ) getToken();

  while ( curToken == GENERATOR ) {

	 Chars name(tokenName);

    // Check for duplication and presence of inverses.
	 if ( result.indexOf(name) >= 0 ) {
		parseError("Duplicate generator");
		errMesg = parseErrorMessage;
		return result;
	 } else {
		invertName(tokenName);
		if ( result.indexOf(Chars(tokenName)) >= 0 ) {
		  parseError("Duplicate generator: formal inverse");
		  errMesg = parseErrorMessage;
		  return result;
		}
	 }

	 result.append(name); // Ok, it's inefficient, but time is $$

	 getToken();

	 if ( curToken == COMMA ) {
	   getToken();
	   if ( curToken == DOT ) {
	     if (!getGeneratorRange(name,result,errMesg))
	       return result;
	   } else {
	     if ( curToken != GENERATOR ) {
	       parseError("Expected a generator here");
	       errMesg = parseErrorMessage;
	       return result;
	     }
	   }
	 }
  }

  return result;
}
void MapListExtractIAautoARCer::runComputation( )
{
#if SAFETY > 0
  if( ! theIterator )
    error( "void MapListExtractIAautoARCer::runComputation( ) : "
	   "fileIterator must be initialized first");
#endif

  int counter = 1;
  theData.setWriteMode();
  
  for (theIterator->reset();!theIterator->EOL();theIterator->nextCell()){
    
    if (theGroup.isIAAutomorphism(theIterator->getData().generatingImages())){
      theData <<EnumWriteMap( theIterator->getData() ) << Chars("\n\n");
      counter ++;
    }
  }
  theData.closeCurrentMode();  
}
Beispiel #19
0
void RunPackage::start() {
  

  ListOf<Chars> paramList;

   
  ListIterator<ListOf<ParamRecord> > I(params);
  int pname = 0;
  for (I.reset();!I.done();I.next(), pname++) {
    Chars pstring;
    pstring  = paramToChars(I.value().getName(),  
			    getParameters().getValue(Chars(pname)), 
			    I.value().getType());
    paramList.append( pstring );
  }

   arcer = new RunPackageARCer( *this, packageObject, thePackageRecord.getCommand(), paramList);


}
void SGListExtractNormalARCer::runComputation( )
{
#if SAFETY > 0
  if( ! theIterator )
    error( "void SGListExtractNormalARCer::runComputation( ) : "
	   "fileIterator must be initialized first");
#endif

  int counter = 1;
  theData.setWriteMode();
  for (theIterator->reset();!theIterator->EOL();theIterator->nextCell()){
    SGofFreeGroup s( theGroup, theIterator->getData().generators() );
    if (  s.isNormal( ) ){
      VectorOf<Word> v = s.generators();
      theData  << EnumWriteVectorOfWords( v, theGroup ) << Chars("\n\n");
      counter ++;
    }
  }
  theData.closeCurrentMode();  
}
Beispiel #21
0
Chars RunPackage::paramToChars(Chars name, PValue value, ParamRecord::PARAM_TYPE t) const 
{
  Chars pstring;
  Chars tmpV;
  if (t == ParamRecord::INT){
    pstring = Chars("Integer");
    int i = (int)value;
    tmpV = Chars(i);
  } else if (t == ParamRecord::BOOL){
    pstring = Chars("Boolean");
    int i = (int)value;
    tmpV = Chars(i);
  } else if ( t == ParamRecord::STRING){
    pstring = Chars("String");
    tmpV = value;
  }else
    error("Type is not supported yet");
  return pstring + Chars(" ( ") + name + Chars(") (  ") + tmpV + ") ";
}
Beispiel #22
0
void RunPackage::sendOutput()
{

  ifstream in(arcer->getFileName());
  in.seekg(pos);

  char theline[1000]; 
  while (!in.eof()){
    readline(in,theline,999);
    pos = in.tellg();

    
    
    if (strlen(theline) > 0 ){
      char* tok = strtok(theline, "{");
      char trimtok[1000];
      strcpy(trimtok, tok);
      trimall(trimtok);
      
      if ( !actionParser(trimtok) )  {

	//  all output goes into a file link

	if (!started){
	  
	  LogMessage msg1;
	  msg1 << Link(Chars( "Click here to see the details from ") + packageName,
		       "Package",
		       file.getFileName(), true );
	  msg1.send();
	  started = true;
	  useGlobalLink = true;
	}
	file << theline << endl;
	
      }
    }
  }
  in.close();
}
Beispiel #23
0
// Finding the basis of the subgroup.
void SGOfFreeNilpotentGroupRep::initBasis( ) const {     // logical const !

  if(theBasisSet.isMalcevBasis()) return;

  SGOfFreeNilpotentGroupRep *This = (SGOfFreeNilpotentGroupRep *)this;

  if( theBasisSet.cardinality() == 0 )
    This->theBasisSet = MalcevSet(theGenerators, theParentGroup.collector() );

  This->theBasisSet.makeFull(); 

  This->theBasis = theBasisSet.getPolyWords();

  // name the generators
  // now standard names as h1, h2, h3 ......

  int hirsch = theBasis.length();

  This->theBasisNames = VectorOf<Chars> ( hirsch );

  for(int n = 0; n < hirsch; n++)
    This->theBasisNames[n] = (Chars)"h" + Chars(n+1);

}
Beispiel #24
0
void IsEltCentral::takeControl( )
{
  Trichotomy theAnswer = dontknow;
  Chars explanation;
  if ( ! displayInFE() || freeARCs() > 0 )
    if (nilpotentWP->state() == ComputationManager::TERMINATED){
      explanation = ": this follows from an inspection of a basis." ;
      theAnswer = nilpotentWP->isTrivial();
    }
  if (nilpotentWPInQuotients->state() == ComputationManager::TERMINATED)
    if (nilpotentWPInQuotients->isTrivial()==no){
      int retClass;
      theAnswer = nilpotentWPInQuotients->isTrivial(retClass);
      //@njz
      //      ostrstream msgTmp;
      std::ostrstream msgTmp;
      //
      msgTmp << ": because it's not central in lower central quotient of class " 
	     << retClass << ends;
      explanation = msgTmp.str();
    }
  if (theAnswer != dontknow){
      LogMessage msg( *this, theWord );
      msg << Name( theWord ) << " is ";
      if ( theAnswer == no ) msg << "not ";
      msg << "central in " << Name( Parent( theWord ) ) << explanation;
      msg.send();
      adminTerminate();     
      return;    
  }
  if ( ( theAnswer = theChecker.isTrivial() ) != dontknow ) {
    
    LogMessage msg( *this, theWord );
    msg << Name( theWord ) << " is ";
    if ( theAnswer == no ) msg << "not ";
    msg << "central in " << Name( Parent( theWord ) );
    
    Chars explanation = theChecker.getExplanation();
    if( explanation.length() > 0 )
      msg << " : " << explanation;
    
    msg << ".";
    msg.send();

    if( theChecker.haveDetails() ) {
      LogMessage msgLink( *this, theWord );
      msgLink << Link( Chars("Click here to see details of centrality problem "
			     "for ")
		       + Text(Name(theWord)) + 
		       Text("."),
		       "WordProblemDetails", 
		       theChecker.getDecompositionFileName()
		       );
      msgLink.send();
    }
    
    
    adminTerminate();
  } 
  else if ( ( theAnswer = genetic->areTrivial() ) != dontknow ) {
    
    Chars explanation = "according to the genetic algorithm";
    LogMessage msg( *this, theWord );
    msg << Name( theWord ) << " is central";
    msg << " : " << explanation << ".";
    msg.send();
    adminTerminate();
  }
 
  else if ( ( theAnswer = genetic->areTrivial() ) != dontknow ) {
    
    Chars explanation = "according to the genetic algorithm";
    LogMessage msg( *this, theWord );
    msg << Name( theWord ) << " is central";
    msg << " : " << explanation << ".";
    msg.send();
    adminTerminate();
  }
  else
    usedOneARC();
}
bool PresentationParser::getGeneratorRange( const Chars& name,
					    VectorOf<Chars>& result,
					    Chars& errMesg )
{
  if ( curToken != DOT ) 
    error("bool PresentationParser::getGeneratorRange() "
	  "can't read the range");
  // Make sure, that we have 3 dots in a row
  for (int i = 0;i<2;i++){
    getToken();
    if ( curToken != DOT ) {
      parseError("Expected '.' here");
      errMesg = parseErrorMessage;
      return false;
    }   
  }
  getToken();
  
   // Supose to be ','
  if ( curToken != COMMA ) {
    parseError("Expected ',' here");
    errMesg = parseErrorMessage;
    return false;
  }    

  getToken();
  
  // Supose to be a generator
  if ( curToken != GENERATOR ) {
    parseError("Expected a generator here");
    errMesg = parseErrorMessage;
    return false;
  }    
  Chars name1;
  int beginRange;
  
  // Generators must be in the form: <name><index>, where
  // index is the first and the last generator index in a range.
  // 
  Chars rangeErrMsg = "When defining a set of generators using a range of "
    "subscripts, both the smallest subscript and the largest subscript"
    " must be given and the smallest subscript mast be less then the "
    "largest one";

  if ( !getRangeOf(name,name1,beginRange)) {
    parseError(rangeErrMsg);
    errMesg = parseErrorMessage;
    return false;    
  }
  Chars name2;
  int endRange;  
  if ( !getRangeOf(tokenName,name2,endRange)) {
    parseError(rangeErrMsg);
    errMesg = parseErrorMessage;
    return false;    
  }

  // The last index must be greater than the first one
  if ( endRange <= beginRange) {
    parseError(rangeErrMsg);
    errMesg = parseErrorMessage;
    return false;    
  }
 
  // Names gave to be equal
  if ( name2 != name1) {
    parseError(rangeErrMsg);
    errMesg = parseErrorMessage;
    return false;    
  }

  // Generate generators of type: name1<index>, where
  // beginRange < index < endRange
  int numberOfGens = endRange - beginRange - 1;
  if (numberOfGens > 0){
    VectorOf<Chars> gens(numberOfGens);
    
    for(int i = 0;i<numberOfGens;i++){
      gens[i] = name1+Chars(beginRange + 1 + i);
      // Check for duplication and presence of inverses.
      if ( result.indexOf(gens[i]) >= 0 ) {
	parseError("Duplicate generator");
	errMesg = parseErrorMessage;
	return false;
      } else {
	char str[100];
	strcpy(str,gens[i]);
	invertName(str);
	if ( result.indexOf(Chars(str)) >= 0 ) {
	  parseError("Duplicate generator: formal inverse");
	  errMesg = parseErrorMessage;
	  return false;
	}
      }
    }
    result = concatenate(result, gens);
  }
  return true;
}
	void AddChars(const cv::Mat& m, const cv::Rect& r) { m_chars.push_back(Chars(m, r)); }
Beispiel #27
0
 const std::string ToString() const
 {
     return std::string(Chars(), Size());
 }
Beispiel #28
0
void SMListData::doHardCopy( const SMListData& sd )
{
  closeCurrentMode();

  number_of_elements = sd.number_of_elements;

  // copy the file with enumerations
  char* tmpFileName = tempnam(MagnusTmp::magnusTmp(),NULL);
  Chars fName = sd.dataFileName;
  const char* tmpStr = fName;
  int pid;
  
  if ( ( pid = fork() ) == 0 ) {
    setpgid(0,0);
    
    if ( execlp( "cp", "",tmpStr ,tmpFileName, NULL) == -1 )
      error("SMListData( const SMListData& sd, int m = ios::in ):"
	    " can't create a copy of the data file.");
    
    _exit(0);
  }
  
  while( kill(pid, 0) == 0 ) {
    sleep(100); 
  }
  
#ifdef BSD    
  int status;
  wait(&status);
#endif
  
  // make an empty color file
  //const char* destColor = Chars( tmpFileName ) + Chars(".color");
  Chars destColor = Chars( tmpFileName ) + Chars(".color");
  ofstream outColor( destColor );
  outColor << "#0000000%000@" << flush;
  outColor.close();
  
  // save the name of the data file
  dataFileName = Chars( tmpFileName );
  free( tmpFileName );
  // Copy references file
  tmpFileName = tempnam(MagnusTmp::magnusTmp(),NULL);
  fName = sd.refFileName;
  tmpStr = fName;
  
  if ( ( pid = fork() ) == 0 ) {
    setpgid(0,0);
    
    if ( execlp( "cp", "",tmpStr ,tmpFileName, NULL) == -1 )
      error("SMListData( const SMListData& sd, int m = ios::in ):"
	    " can't create a copy of the offset file.");
    
    _exit(0);
  }
  
  while( kill(pid, 0) == 0 ) { sleep(10); }
  
#ifdef BSD    
  status;
  wait(&status);
#endif
  // save the name of the offset file
  refFileName = Chars( tmpFileName );
  free( tmpFileName );
}
Beispiel #29
0
String::operator const Chars () const
{
	return Chars( m_start, m_length );
}