Ejemplo n.º 1
0
// This method is required for all derived classes of EffectBase, and returns a
// modified openshot::Frame object
tr1::shared_ptr<Frame> Deinterlace::GetFrame(tr1::shared_ptr<Frame> frame, int frame_number)
{
	// Get original size of frame's image
	int original_width = frame->GetImage()->width();
	int original_height = frame->GetImage()->height();

	// Get the frame's image
	tr1::shared_ptr<QImage> image = frame->GetImage();
	const unsigned char* pixels = image->bits();

	// Create a smaller, new image
	QImage deinterlaced_image(image->width(), image->height() / 2, QImage::Format_RGBA8888);
	const unsigned char* deinterlaced_pixels = deinterlaced_image.bits();

	// Loop through the scanlines of the image (even or odd)
	int start = 0;
	if (isOdd)
		start = 1;
	for (int row = start; row < image->height(); row += 2) {
		memcpy((unsigned char*)deinterlaced_pixels, pixels + (row * image->bytesPerLine()), image->bytesPerLine());
		deinterlaced_pixels += image->bytesPerLine();
	}

	// Resize deinterlaced image back to original size, and update frame's image
	image = tr1::shared_ptr<QImage>(new QImage(deinterlaced_image.scaled(original_width, original_height, Qt::IgnoreAspectRatio, Qt::FastTransformation)));

	// Update image on frame
	frame->AddImage(image);

	// return the modified frame
	return frame;
}
Ejemplo n.º 2
0
unsigned long long CCachedAffairMap::Static_PushNewAffair_Pre(map<unsigned long long, tr1::shared_ptr<CCachedAffair> >& cachedMap, CCachedAffairMapLock &Lock
	, tr1::shared_ptr<CCachedAffair> pCachedAffairItem, long nOutSeqId, int nOutCmdId, int nExpetedCmdId)//
{
	if(((!!(pCachedAffairItem->m_fpOnGotData)) ^ (!!(pCachedAffairItem->m_fpOnAffairOverTime))))
	{
		//同时有,同时没有才正确
		return -2;
	}

	pCachedAffairItem->SetSequencePair(nOutSeqId);
	pCachedAffairItem->SetCommandIdxPair(nOutCmdId,nExpetedCmdId);

	//unsigned long long AffairId=0;
	{
		//缩小加锁范围
		///AffairId = nOutSeqId;//JT_AMIOC_ADD(m_lastSeq,1);//使用外部的nOutSeqId,因为处理时可能涉及批量
		//if(AffairId==0)
		//	AffairId = JT_AMIOC_ADD(m_lastSeq,1);

		Lock.LockMap();
		cachedMap[nOutSeqId] = pCachedAffairItem;
		Lock.UnLockMap();
	}

	return nOutSeqId;
}
Ejemplo n.º 3
0
tr1::shared_ptr<AbstractNumber> E::divide(tr1::shared_ptr<AbstractNumber>number){
    char newSign = '-';
    if (getSign() == number->getSign())
    {
        newSign = '+';
    }
		if (number -> getName() == "E")
		{

			if (newSign == '+')
			{
				tr1::shared_ptr<AbstractNumber> output(new SmartInteger(1));
				return output;
			}

			else
			{
				tr1::shared_ptr<AbstractNumber> output(new SmartInteger(-1));
				return output;
			}

		}

		else if (number -> getName() == "Exponent")
		{
		    tr1::shared_ptr<Exponent> numExp = tr1::static_pointer_cast<Exponent>(number);
			if (numExp -> getValue("base") -> getName() == "E")
			{
				tr1::shared_ptr<AbstractNumber> num(new SmartInteger(1));
				tr1::shared_ptr<AbstractNumber> exp = number->getValue("power");
				tr1::shared_ptr<AbstractNumber> exp2(new SmartInteger(-1));
				tr1::shared_ptr<AbstractNumber> me(new E());
				tr1::shared_ptr<AbstractNumber> ans2(new Exponent(me, exp -> add(exp2), newSign));
				tr1::shared_ptr<AbstractNumber> output2(new MultExpression(num, ans2, '+'));
				return output2;
			}
		}
        else if(number->getName() == "MultExpression")
        {
            tr1::shared_ptr<MultExpression> MultE = tr1::static_pointer_cast<MultExpression>(number);
            vector<tr1::shared_ptr<AbstractNumber> > MultENum = MultE->getNumerator();
            vector<tr1::shared_ptr<AbstractNumber> > MultEDem = MultE->getDenominator();
            if (MultEDem.size() == 0)
            {
                tr1::shared_ptr<AbstractNumber> one(new SmartInteger(1));
                MultEDem.push_back(one);
            }
            tr1::shared_ptr<AbstractNumber> reversedMultE(new MultExpression(MultEDem, MultENum, number->getSign()));
            return reversedMultE->multiply(shared_from_this());
        }

        tr1::shared_ptr<AbstractNumber> output2(new MultExpression(shared_from_this(), number, newSign));
        return output2;
}
Ejemplo n.º 4
0
    inline saga::task
    dispatch_async (proxy * prxy, 
                    TR1::shared_ptr <adaptor_selector_state> state,
                    void       (Base::*sync_)  (RetVal &, BOOST_PP_ENUM_PARAMS (K, FuncArg)),
                    saga::task (Base::*async_) (          BOOST_PP_ENUM_PARAMS (K, FuncArg)),
                    BOOST_PP_ENUM_BINARY_PARAMS (K, Arg, const & arg),
                    bool       (Base::*prep_)  (RetVal &, BOOST_PP_ENUM_PARAMS(K, FuncArg), saga::uuid) = NULL)
    {
        typedef void       (Base::*sync_func )(RetVal&, BOOST_PP_ENUM_PARAMS(K, FuncArg));
        typedef saga::task (Base::*async_func)(         BOOST_PP_ENUM_PARAMS(K, FuncArg));
        typedef bool       (Base::*prep_func )(RetVal&, BOOST_PP_ENUM_PARAMS(K, FuncArg), saga::uuid);

        void       (Base::*sync )() = NULL;
        saga::task (Base::*async)() = NULL;
        bool       (Base::*prep )() = NULL;

        run_mode mode = Unknown;
        TR1::shared_ptr<Base> c (
            state->get_next_cpi (mode, &sync, &async, &prep));

//      BOOST_ASSERT(NULL == sync  || (sync_func)  sync  == sync_ );
//      BOOST_ASSERT(NULL == async || (async_func) async == async_);
//      BOOST_ASSERT(NULL == prep  || (prep_func)  prep  == prep_ );

        switch (mode) {
        case Async_Sync:
            BOOST_ASSERT(sync);
            return async_sync(prxy, c, state, (sync_func)sync, 
                BOOST_PP_ENUM_PARAMS(K, arg), (prep_func)prep);

        case Async_Async:
            BOOST_ASSERT(async);
            return async_async(c, state, (async_func)async, 
                BOOST_PP_ENUM_PARAMS(K, arg));

        case Sync_Sync:
        case Sync_Async:
            BOOST_ASSERT(false);
            break;

        default:
            break;
        }

        // no adaptor found  (Invalid mode)!
        SAGA_THROW_VERBATIM(c.get(),
                            std::string ("No adaptor implements method: ") + state->get_op_name(),
                            adaptors::NoAdaptor);

        // this makes some compilers happy, but will never be called in fact
        // (didn't you see the throw above?)
        return saga::task(saga::task_base::Done);
    }
Ejemplo n.º 5
0
 // Multiplies number by this and returns the product
 //
 // Parameters:
 // shared_ptr<AbstractNumber> number	number being multiplied
 //
 // Returns:
 // shared_ptr<AbstractNumber> 			resulting product of multiplication
tr1::shared_ptr<AbstractNumber>  Exponent::multiply(tr1::shared_ptr<AbstractNumber> number){
	// Checks for simplification if both exponents
	number = number->simplify();

	if(number->getName() == "Exponent"){
        tr1::shared_ptr<Exponent> givenNumber = tr1::static_pointer_cast<Exponent>(number);
		if(abs(givenNumber->getValue("base")->toDouble() - base->toDouble()) < 0.000001){
			tr1::shared_ptr<AbstractNumber> r(new Exponent(base, power->add(givenNumber->getValue("power")), this->calcSign(number)));
		    return r;
		}
	else if (number->getName() == "Radical") {
		 if (abs(number->getValue("value")->toDouble() - base->toDouble()) < 0.000001 )
		 {
			 std::vector< tr1::shared_ptr<AbstractNumber> > SumVector;
			 tr1::shared_ptr<AbstractNumber> one(new SmartInteger(1));
			 tr1::shared_ptr<AbstractNumber> invertedRoot(new MultExpression(one, number->getValue("root")->noSign(), number->getValue("root")->getSign()));
			 SumVector.push_back(power);
			 SumVector.push_back(invertedRoot);
			 tr1::shared_ptr<AbstractNumber> power(new SumExpression(SumVector));
			 tr1::shared_ptr<AbstractNumber> output(new Exponent(number->getValue("value")->noSign(), power, sign));
			 return output;
		 }
	}
        else{
            tr1::shared_ptr<AbstractNumber> me(new Exponent(base, power, sign));
            tr1::shared_ptr<AbstractNumber> r(new MultExpression(me, number, this->calcSign(number)));
            return r;
        }
	}

	// Checks for simplification if number = base
	// Adds 1 to exponent
	else if(abs(number->toDouble() - base->toDouble()) < 0.000001 ){
		tr1::shared_ptr<AbstractNumber> c(new SmartInteger(1));
		tr1::shared_ptr<AbstractNumber> r(new Exponent(base, power->add(c), this->calcSign(number)));
	    return r;
	}
	else if(number->getName() == "SumExpression" || number->getName() == "MultExpression")
    {
        return number->multiply(shared_from_this());
    }

    vector< tr1::shared_ptr<AbstractNumber> > MultVector;
    tr1::shared_ptr<AbstractNumber> me(new Exponent(base, power, sign));
    MultVector.push_back(me);
    MultVector.push_back(number);
    tr1::shared_ptr<AbstractNumber> r(new MultExpression(MultVector, '+'));

    return r;
}
Ejemplo n.º 6
0
    inline saga::task
    dispatch_sync (run_mode     mode, 
                   char const * name,
                   TR1::shared_ptr<v1_0::cpi> cpi_instance,
                   void       (Base::*sync ) (RetVal &, BOOST_PP_ENUM_PARAMS (K, FuncArg)),
                   saga::task (Base::*async) (          BOOST_PP_ENUM_PARAMS (K, FuncArg)),
                   BOOST_PP_ENUM_BINARY_PARAMS (K, Arg, const & arg))
    {
        TR1::shared_ptr<Base> c = TR1::static_pointer_cast<Base>(cpi_instance);

        switch (mode) {
        case Sync_Sync:
            return sync_sync(c, sync, BOOST_PP_ENUM_PARAMS(K, arg));

        case Sync_Async:
            return sync_async(c, async, BOOST_PP_ENUM_PARAMS(K, arg));

        case Async_Sync:
        case Async_Async:
            BOOST_ASSERT(false);
            break;

        default:
            break;
        }

        // no adaptor found  (Invalid mode)!
        SAGA_THROW_VERBATIM(cpi_instance.get(),
            std::string ("No adaptor implements method: ") + name,
            adaptors::NoAdaptor);

        return saga::task(saga::task_base::Done);
    }
Ejemplo n.º 7
0
// This method is required for all derived classes of EffectBase, and returns a
// modified openshot::Frame object
tr1::shared_ptr<Frame> ChromaKey::GetFrame(tr1::shared_ptr<Frame> frame, int frame_number)
{
	// Determine the current HSL (Hue, Saturation, Lightness) for the Chrome
	int threshold = fuzz.GetInt(frame_number);
	long mask_R = color.red.GetInt(frame_number);
	long mask_G = color.green.GetInt(frame_number);
	long mask_B = color.blue.GetInt(frame_number);

	// Get source image's pixels
	tr1::shared_ptr<QImage> image = frame->GetImage();
	unsigned char *pixels = (unsigned char *) image->bits();

	// Loop through pixels
	for (int pixel = 0, byte_index=0; pixel < image->width() * image->height(); pixel++, byte_index+=4)
	{
		// Get the RGB values from the pixel
		unsigned char R = pixels[byte_index];
		unsigned char G = pixels[byte_index + 1];
		unsigned char B = pixels[byte_index + 2];
		unsigned char A = pixels[byte_index + 3];

		// Get distance between mask color and pixel color
		long distance = Color::GetDistance((long)R, (long)G, (long)B, mask_R, mask_G, mask_B);

		// Alpha out the pixel (if color similar)
		if (distance <= threshold)
			// MATCHED - Make pixel transparent
			pixels[byte_index + 3] = 0;
	}

	// return the modified frame
	return frame;
}
Ejemplo n.º 8
0
bool
commit::isCommitPathEffective(Cstore& cs, const Cpath& pcomps,
                              tr1::shared_ptr<Ctemplate> def,
                              bool in_active, bool in_working)
{
  if (in_active && in_working) {
    // remain the same
    return true;
  }
  if (!in_active && !in_working) {
    // doesn't exist
    return false;
  }
  // at this point, in_active corresponds to "being deleted"

  if (def->isTagNode()) {
    // special handling for tag nodes, which are never marked
    vector<string> tvals;
    // get tag values from active or working config
    cs.cfgPathGetChildNodes(pcomps, tvals, in_active);
    Cpath vpath(pcomps);
    /* note that there should be at least 1 tag value since tag node
     * cannot exist without tag value.
     */
    for (size_t i = 0; i < tvals.size(); i++) {
      vpath.push(tvals[i]);
      if (in_active) {
        // being deleted => all tag values are being deleted
        if (!cs.cfgPathMarkedCommitted(vpath, true)) {
          /* a tag value is not marked committed
           * => a tag value has not been deleted
           * => tag node has not been deleted
           * => still effective
           */
          return true;
        }
      } else {
        // being added => all tag values are being added
        if (cs.cfgPathMarkedCommitted(vpath, false)) {
          /* a tag value is marked committed
           * => a tag value has been added
           * => tag node has been added
           * => already effective
           */
          return true;
        }
      }
      vpath.pop();
    }
    // not effective
    return false;
  }

  /* if not tag node, effectiveness corresponds to committed marking:
   *   if deleted (i.e., in_active), then !marked is effective
   *   otherwise (i.e., added), marked is effective
   */
  bool marked = cs.cfgPathMarkedCommitted(pcomps, in_active);
  return (in_active ? !marked : marked);
}
Ejemplo n.º 9
0
// Add (or replace) pixel data to the frame (for only the odd or even lines)
void Frame::AddImage(tr1::shared_ptr<QImage> new_image, bool only_odd_lines)
{
	// Ignore blank new_image
	if (!new_image)
		return;

	// Check for blank source image
	if (!image) {
		// Replace the blank source image
		AddImage(new_image);

	} else {

		// Ignore image of different sizes or formats
		if (image == new_image || image->size() != image->size() || image->format() != image->format())
			return;

		// Get the frame's image
		const unsigned char *pixels = image->bits();
		const unsigned char *new_pixels = new_image->bits();

		// Loop through the scanlines of the image (even or odd)
		int start = 0;
		if (only_odd_lines)
			start = 1;
		for (int row = start; row < image->height(); row += 2) {
			memcpy((unsigned char *) pixels, new_pixels + (row * image->bytesPerLine()), image->bytesPerLine());
			new_pixels += image->bytesPerLine();
		}

		// Update height and width
		width = image->width();
		height = image->height();
	}
}
Ejemplo n.º 10
0
void ConsoleHandler::SendConsoleText(HANDLE hStdIn, const tr1::shared_ptr<wchar_t>& textBuffer)
{
	wchar_t*	pszText	= textBuffer.get();
	size_t		textLen = wcslen(pszText);
	size_t		partLen	= 512;
	size_t		parts	= textLen/partLen;
	size_t		offset	= 0;

	for (size_t part = 0; part < parts+1; ++part)
	{
		size_t	keyEventCount = 0;
		
		if (part == parts)
		{
			// last part, modify part size
			partLen = textLen - parts*partLen;
		}

		scoped_array<INPUT_RECORD> pKeyEvents(new INPUT_RECORD[partLen]);
		::ZeroMemory(pKeyEvents.get(), sizeof(INPUT_RECORD)*partLen);

		for (size_t i = 0; (i < partLen) && (offset < textLen); ++i, ++offset, ++keyEventCount)
		{
			if ((pszText[offset] == L'\r') || (pszText[offset] == L'\n'))
			{
				if ((pszText[offset] == L'\r') && (pszText[offset+1] == L'\n')) ++offset;

				if (keyEventCount > 0)
				{
					DWORD dwTextWritten = 0;
					::WriteConsoleInput(hStdIn, pKeyEvents.get(), static_cast<DWORD>(keyEventCount), &dwTextWritten);
				}

				::PostMessage(m_consoleParams->hwndConsoleWindow, WM_KEYDOWN, VK_RETURN, 0x001C0001);
				::PostMessage(m_consoleParams->hwndConsoleWindow, WM_KEYUP, VK_RETURN, 0xC01C0001);

				keyEventCount = static_cast<size_t>(-1);
				partLen -= i;
				i = static_cast<size_t>(-1);
			}
			else
			{
				pKeyEvents[i].EventType							= KEY_EVENT;
				pKeyEvents[i].Event.KeyEvent.bKeyDown			= TRUE;
				pKeyEvents[i].Event.KeyEvent.wRepeatCount		= 1;
				pKeyEvents[i].Event.KeyEvent.wVirtualKeyCode	= LOBYTE(::VkKeyScan(pszText[offset]));
				pKeyEvents[i].Event.KeyEvent.wVirtualScanCode	= 0;
				pKeyEvents[i].Event.KeyEvent.uChar.UnicodeChar	= pszText[offset];
				pKeyEvents[i].Event.KeyEvent.dwControlKeyState	= 0;
			}
		}

		if (keyEventCount > 0)
		{
			DWORD dwTextWritten = 0;
			::WriteConsoleInput(hStdIn, pKeyEvents.get(), static_cast<DWORD>(keyEventCount), &dwTextWritten);
		}
	}
}
Ejemplo n.º 11
0
 inline saga::task
 sync_async (TR1::shared_ptr <Cpi> cpi,
             saga::task (Base::*async)(BOOST_PP_ENUM_PARAMS (K, FuncArg)),
             BOOST_PP_ENUM_BINARY_PARAMS (K, Arg, const & arg))
 {
     return saga::detail::run_wait(
         (cpi.get()->*async)(BOOST_PP_ENUM_PARAMS(K, arg)));
 }
Ejemplo n.º 12
0
// Returns char identifying sign resulting from multiplication or division of two numbers
//
// Returns:
// char 			'+' or '-'
char Exponent::calcSign(tr1::shared_ptr<AbstractNumber> number){
	if(sign == number->getSign()){
		return '+';
	}
	else{
		return '-';
	}
}
Ejemplo n.º 13
0
int boot(int argc, char *args[]) {
    screen.reset(new P47Screen());
    pad.reset(new Pad());
    try {
        pad->openJoystick();
    } catch (const exception& e) {}
    gameManager.reset(new P47GameManager());
    prefManager.reset(new P47PrefManager());
    mainLoop.reset(new MainLoop(screen, pad, gameManager, prefManager));
    try {
        parseArgs(argc, args);
    } catch (const exception& e) {
        return EXIT_FAILURE;
    }
    mainLoop->loop();
    return EXIT_SUCCESS;
}
Ejemplo n.º 14
0
// Get pointer to QImage of frame
void Frame::AddMagickImage(tr1::shared_ptr<Magick::Image> new_image)
{
	const int BPP = 4;
	const std::size_t bufferSize = new_image->columns() * new_image->rows() * BPP;

	/// Use realloc for fast memory allocation.
	/// TODO: consider locking the buffer for mt safety
	//qbuffer = reinterpret_cast<unsigned char*>(realloc(qbuffer, bufferSize));
	qbuffer = new unsigned char[bufferSize]();
	unsigned char *buffer = (unsigned char*)qbuffer;

    // Iterate through the pixel packets, and load our own buffer
	// Each color needs to be scaled to 8 bit (using the ImageMagick built-in ScaleQuantumToChar function)
	int numcopied = 0;
    Magick::PixelPacket *pixels = new_image->getPixels(0,0, new_image->columns(), new_image->rows());
    for (int n = 0, i = 0; n < new_image->columns() * new_image->rows(); n += 1, i += 4) {
    	buffer[i+0] = MagickCore::ScaleQuantumToChar((Magick::Quantum) pixels[n].red);
    	buffer[i+1] = MagickCore::ScaleQuantumToChar((Magick::Quantum) pixels[n].green);
    	buffer[i+2] = MagickCore::ScaleQuantumToChar((Magick::Quantum) pixels[n].blue);
    	buffer[i+3] = 255 - MagickCore::ScaleQuantumToChar((Magick::Quantum) pixels[n].opacity);
    	numcopied+=4;
    }

    // Create QImage of frame data
    image = tr1::shared_ptr<QImage>(new QImage(qbuffer, width, height, width * BPP, QImage::Format_RGBA8888, (QImageCleanupFunction) &cleanUpBuffer, (void*) qbuffer));

	// Update height and width
	width = image->width();
	height = image->height();
}
Ejemplo n.º 15
0
int AdaBoost2::create_one_weak_classifier(tr1::shared_ptr<WeakClassifier> wc)
{
//  tr1::shared_ptr<WeakClassifier> wc(new WeakClassifier(feature_type));

  uint64 feature_type;
  wc->feature_type(feature_type);
  m_all_weak_classifiers.insert(pair<uint64, tr1::shared_ptr<WeakClassifier> >(feature_type, wc));
  return 0;
}
Ejemplo n.º 16
0
tr1::shared_ptr<AbstractNumber> E::add(tr1::shared_ptr<AbstractNumber>number){

	if (number -> getName() == "E")
	{
		if (number -> getSign() == '+' && getSign() == '+')
		{
			vector<tr1::shared_ptr<AbstractNumber> > M;
			tr1::shared_ptr<AbstractNumber> two(new SmartInteger(2));
			M.push_back(two);
			M.push_back(shared_from_this());
			tr1::shared_ptr<AbstractNumber> output(new MultExpression(M, '+'));
			return output;
		}

		else if (number -> getSign() == '-' && getSign() == '-')
		{
			vector<tr1::shared_ptr<AbstractNumber> > N;
			tr1::shared_ptr<AbstractNumber> twoN(new SmartInteger(-2));
			N.push_back(twoN);
			tr1::shared_ptr<AbstractNumber> me(new E());
			N.push_back(me);
			tr1::shared_ptr<AbstractNumber> output1(new MultExpression(N, '+'));
			return output1;
		}

		else
		{
			tr1::shared_ptr<AbstractNumber> zero(new SmartInteger(0));
			return zero;
		}

	}
	else if(number->getName() == "MultExpression" || number->getName() == "SumExpression")
    {
        return number->add(shared_from_this());
    }

    vector<tr1::shared_ptr<AbstractNumber> > N;
    N.push_back(number);
    N.push_back(shared_from_this());
    tr1::shared_ptr<AbstractNumber> output1(new SumExpression(N));
    return output1;

}
Ejemplo n.º 17
0
// Divides this by number and returns the product
//
// Parameters:
// shared_ptr<AbstractNumber> number	divisor
//
// Returns:
// shared_ptr<AbstractNumber> 			resulting quotient of division
tr1::shared_ptr<AbstractNumber>  Exponent::divide(tr1::shared_ptr<AbstractNumber>number){
	// Reverses sign if exponent and multiplies
	if(number->getName()=="Exponent"){
        tr1::shared_ptr<Exponent> givenNumber = tr1::static_pointer_cast<Exponent>(number);
		if(givenNumber->getSign()=='-'){
			tr1::shared_ptr<AbstractNumber> r(new Exponent(givenNumber->getValue("base"), givenNumber->getValue("power")));
			return multiply(r);
		}
		else{
            tr1::shared_ptr<AbstractNumber> nOne(new SmartInteger(-1));
            tr1::shared_ptr<AbstractNumber> newPower = givenNumber->getValue("power")->multiply(nOne);
			tr1::shared_ptr<AbstractNumber> r(new Exponent(givenNumber->getValue("base"), newPower, givenNumber->getSign()));
			return multiply(r);
		}
	}

	// Subtracts 1 from power if base = number
	else if(number->toDouble() == base->toDouble()){
		tr1::shared_ptr<AbstractNumber> c(new SmartInteger(-1));
		tr1::shared_ptr<AbstractNumber> r(new Exponent(base, power->add(c), this->calcSign(number)));
		return r;
	}
	else if(number->getName() == "MultExpression")
    {
        tr1::shared_ptr<MultExpression> MultE = tr1::static_pointer_cast<MultExpression>(number);
        vector<tr1::shared_ptr<AbstractNumber> > MultENum = MultE->getNumerator();
        vector<tr1::shared_ptr<AbstractNumber> > MultEDem = MultE->getDenominator();
        if (MultEDem.size() == 0)
        {
            tr1::shared_ptr<AbstractNumber> one(new SmartInteger(1));
            MultEDem.push_back(one);
        }
        tr1::shared_ptr<AbstractNumber> reversedMultE(new MultExpression(MultEDem, MultENum, '+'));
        return reversedMultE->multiply(shared_from_this());
    }

    vector< tr1::shared_ptr<AbstractNumber> > NumVector;
    tr1::shared_ptr<AbstractNumber> me(new Exponent(base, power, sign));
    NumVector.push_back(me);
    vector< tr1::shared_ptr<AbstractNumber> > DenVector;
    DenVector.push_back(number);
    tr1::shared_ptr<AbstractNumber> r(new MultExpression(NumVector, DenVector, this->calcSign(number)));
    return r;
}
Ejemplo n.º 18
0
 inline saga::task
 async_async (TR1::shared_ptr <Cpi> cpi,
              TR1::shared_ptr <adaptor_selector_state> state,
              saga::task (Base::*async) (BOOST_PP_ENUM_PARAMS (K, FuncArg)),
              BOOST_PP_ENUM_BINARY_PARAMS (K, Arg, const & arg))
 {
     saga::task t ((cpi.get()->*async)(BOOST_PP_ENUM_PARAMS(K, arg)));
     detail::set_selector_state(t, state);
     return t;
 }
Ejemplo n.º 19
0
 inline saga::task
 sync_sync (TR1::shared_ptr <Cpi> cpi,
            void (Base::*sync) (RetVal &, BOOST_PP_ENUM_PARAMS (K, FuncArg)),
            BOOST_PP_ENUM_BINARY_PARAMS (K, Arg, const & arg))
 {
     saga::task t(saga::task::Done);
     (cpi.get()->*sync)(
         t.get_result<RetVal>(), BOOST_PP_ENUM_PARAMS (K, arg));
     return t;
 }
Ejemplo n.º 20
0
 inline task::task (
         char const *func_name, TR1::shared_ptr<Cpi> cpi, 
         void (Base::*sync)(RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid),
         BOOST_PP_ENUM_BINARY_PARAMS (P, Arg, const& arg),
         bool (Base::*prep)(
             RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid))
   : base_type(create_task(func_name, cpi, cpi->get_proxy(), sync, 
         BOOST_PP_ENUM_PARAMS(P, arg), prep)) 
 {
 }
        void release(TR1::shared_ptr<database_connection> db)
        {
            mutex_type::scoped_lock lock(mtx_);

            // find old entries
            cache_type::iterator end = cache_.end();
            for (cache_type::iterator it = cache_.begin(); it != end; /**/)
            {
                if ((*it).second.is_old()) {
                    cache_type::iterator old = it++;
                    cache_.erase(old);
                }
                else {
                    ++it;
                }
            }

            // insert the new entry
            cache_.insert(cache_type::value_type(
                cache_key(db->get_dbtype(), db->get_connectstring()), db));
        }
Ejemplo n.º 22
0
    inline saga::task
    sync_sync (TR1::shared_ptr <Cpi> cpi,
               void (Base::*sync) (saga::impl::void_t &, BOOST_PP_ENUM_PARAMS (K, FuncArg)),
               BOOST_PP_ENUM_BINARY_PARAMS (K, Arg, const& arg))
    {
        saga::task t (saga::task::Done);
        saga::impl::void_t void_result;

        (cpi.get()->*sync)(void_result, BOOST_PP_ENUM_PARAMS (K, arg));

        return t;
    }
Ejemplo n.º 23
0
    inline saga::task
    async_sync (proxy * prxy, 
                TR1::shared_ptr <Cpi> cpi, 
                TR1::shared_ptr <adaptor_selector_state> state,
                void (Base::*sync) (RetVal&, BOOST_PP_ENUM_PARAMS (K, FuncArg)),
                BOOST_PP_ENUM_BINARY_PARAMS (K, Arg, const& arg),
                bool (Base::*prep) (RetVal&, BOOST_PP_ENUM_PARAMS (K, FuncArg), saga::uuid))
    {
        saga::adaptors::task t(state->get_op_name(), cpi, prxy, sync, 
                               BOOST_PP_ENUM_PARAMS(K, arg), prep);

        detail::set_selector_state(t, state);
        
        return t;
    }
Ejemplo n.º 24
0
 DbBatchAction::DbBatchAction(
     tr1::shared_ptr<IDbTasks> dbtasks, 
     tr1::shared_ptr<DbEngine> engine, 
     bool& is_action_finished, 
     int values_per_batch, 
     int times_to_commit)
     : DbInsertAction(dbtasks, engine, is_action_finished, times_to_commit)
 {
     values_per_batch_ = values_per_batch;
     
     vector<DbLocation>& dbs = dbtasks->GetDbLocations();
     for (int i = 0; i < dbs.size(); i++)
     {
         values_now_[dbs[i]] = 0;
     }
 }
Ejemplo n.º 25
0
// Adds number to this and returns the sum
//
// Parameters:
// shared_ptr<AbstractNumber> number	number being added
//
// Returns:
// shared_ptr<AbstractNumber> 			resulting sum of addition
 tr1::shared_ptr<AbstractNumber> Exponent::add(tr1::shared_ptr<AbstractNumber> number){
 	// Checks for cancellation
 	number = number->simplify();
 	if(abs(toDouble() - number->toDouble()) < 0.000001 &&
 	   this->getSign() != number->getSign()){
 		tr1::shared_ptr<AbstractNumber> r(new SmartInteger(0));

 	    return r;
 	}
 	// Checks for duplication/simplification
 	else if(abs(toDouble() - number->toDouble()) < 0.000001 &&
 			this->getSign() == number->getSign()){
 		vector< tr1::shared_ptr<AbstractNumber> > MultVector;
		tr1::shared_ptr<AbstractNumber> i(new SmartInteger(2));
		MultVector.push_back(i);
		tr1::shared_ptr<AbstractNumber> me(new Exponent(base, power, sign));
		MultVector.push_back(me);
		tr1::shared_ptr<AbstractNumber> r(new MultExpression(MultVector, '+'));

	    return r;
  	}

    //Can't tell if they add or not
 	else if(number->getName() == "SumExpression" ||
            number->getName() == "MultExpression"){
 	    return number->add(shared_from_this());
 	}
    // Duplication necessary for simplification
 	// Assuming number is in simplest form

 	// No simplification possible
	else{
		vector< tr1::shared_ptr<AbstractNumber> > SumVector;
		tr1::shared_ptr<AbstractNumber> me(new Exponent(base, power, sign));
		SumVector.push_back(me);
		SumVector.push_back(number);
		tr1::shared_ptr<AbstractNumber> r(new SumExpression(SumVector));

	    return r;
	}

}
Ejemplo n.º 26
0
// Resample audio and map channels (if needed)
void FrameMapper::ResampleMappedAudio(tr1::shared_ptr<Frame> frame, long int original_frame_number)
{
	// Init audio buffers / variables
	int total_frame_samples = 0;
	int channels_in_frame = frame->GetAudioChannelsCount();
	int sample_rate_in_frame = frame->SampleRate();
	int samples_in_frame = frame->GetAudioSamplesCount();
	ChannelLayout channel_layout_in_frame = frame->ChannelsLayout();

	AppendDebugMethod("FrameMapper::ResampleMappedAudio", "frame->number", frame->number, "original_frame_number", original_frame_number, "channels_in_frame", channels_in_frame, "samples_in_frame", samples_in_frame, "sample_rate_in_frame", sample_rate_in_frame, "", -1);

	// Get audio sample array
	float* frame_samples_float = NULL;
	// Get samples interleaved together (c1 c2 c1 c2 c1 c2)
	frame_samples_float = frame->GetInterleavedAudioSamples(sample_rate_in_frame, NULL, &samples_in_frame);

	// Calculate total samples
	total_frame_samples = samples_in_frame * channels_in_frame;

	// Create a new array (to hold all S16 audio samples for the current queued frames)
	int16_t* frame_samples = new int16_t[total_frame_samples];

	// Translate audio sample values back to 16 bit integers
	for (int s = 0; s < total_frame_samples; s++)
		// Translate sample value and copy into buffer
		frame_samples[s] = int(frame_samples_float[s] * (1 << 15));


	// Deallocate float array
	delete[] frame_samples_float;
	frame_samples_float = NULL;

	AppendDebugMethod("FrameMapper::ResampleMappedAudio (got sample data from frame)", "frame->number", frame->number, "total_frame_samples", total_frame_samples, "target channels", info.channels, "channels_in_frame", channels_in_frame, "target sample_rate", info.sample_rate, "samples_in_frame", samples_in_frame);


	// Create input frame (and allocate arrays)
	AVFrame *audio_frame = AV_ALLOCATE_FRAME();
	AV_RESET_FRAME(audio_frame);
	audio_frame->nb_samples = total_frame_samples / channels_in_frame;

	int error_code = avcodec_fill_audio_frame(audio_frame, channels_in_frame, AV_SAMPLE_FMT_S16, (uint8_t *) frame_samples,
			audio_frame->nb_samples * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) * channels_in_frame, 1);

	if (error_code < 0)
	{
		AppendDebugMethod("FrameMapper::ResampleMappedAudio ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1);
		throw ErrorEncodingVideo("Error while resampling audio in frame mapper", frame->number);
	}

	// Update total samples & input frame size (due to bigger or smaller data types)
	total_frame_samples = Frame::GetSamplesPerFrame(frame->number, target, info.sample_rate, info.channels);

	AppendDebugMethod("FrameMapper::ResampleMappedAudio (adjust # of samples)", "total_frame_samples", total_frame_samples, "info.sample_rate", info.sample_rate, "sample_rate_in_frame", sample_rate_in_frame, "info.channels", info.channels, "channels_in_frame", channels_in_frame, "original_frame_number", original_frame_number);

	// Create output frame (and allocate arrays)
	AVFrame *audio_converted = AV_ALLOCATE_FRAME();
	AV_RESET_FRAME(audio_converted);
	audio_converted->nb_samples = total_frame_samples;
	av_samples_alloc(audio_converted->data, audio_converted->linesize, info.channels, total_frame_samples, AV_SAMPLE_FMT_S16, 0);

	AppendDebugMethod("FrameMapper::ResampleMappedAudio (preparing for resample)", "in_sample_fmt", AV_SAMPLE_FMT_S16, "out_sample_fmt", AV_SAMPLE_FMT_S16, "in_sample_rate", sample_rate_in_frame, "out_sample_rate", info.sample_rate, "in_channels", channels_in_frame, "out_channels", info.channels);

	int nb_samples = 0;
	// Force the audio resampling to happen in order (1st thread to last thread), so the waveform
	// is smooth and continuous.
	#pragma omp ordered
	{
		// setup resample context
		if (!avr) {
			avr = avresample_alloc_context();
			av_opt_set_int(avr,  "in_channel_layout", channel_layout_in_frame, 0);
			av_opt_set_int(avr, "out_channel_layout", info.channel_layout, 0);
			av_opt_set_int(avr,  "in_sample_fmt",     AV_SAMPLE_FMT_S16,     0);
			av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_S16,     0);
			av_opt_set_int(avr,  "in_sample_rate",    sample_rate_in_frame,    0);
			av_opt_set_int(avr, "out_sample_rate",    info.sample_rate,    0);
			av_opt_set_int(avr,  "in_channels",       channels_in_frame,    0);
			av_opt_set_int(avr, "out_channels",       info.channels,    0);
			avresample_open(avr);
		}

		// Convert audio samples
		nb_samples = avresample_convert(avr, 	// audio resample context
				audio_converted->data, 			// output data pointers
				audio_converted->linesize[0], 	// output plane size, in bytes. (0 if unknown)
				audio_converted->nb_samples,	// maximum number of samples that the output buffer can hold
				audio_frame->data,				// input data pointers
				audio_frame->linesize[0],		// input plane size, in bytes (0 if unknown)
				audio_frame->nb_samples);		// number of input samples to convert
	}

	// Create a new array (to hold all resampled S16 audio samples)
	int16_t* resampled_samples = new int16_t[(nb_samples * info.channels)];

	// Copy audio samples over original samples
	memcpy(resampled_samples, audio_converted->data[0], (nb_samples * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) * info.channels));

	// Free frames
	free(audio_frame->data[0]); // TODO: Determine why av_free crashes on Windows
	AV_FREE_FRAME(&audio_frame);
	av_free(audio_converted->data[0]);
	AV_FREE_FRAME(&audio_converted);
	frame_samples = NULL;

	// Resize the frame to hold the right # of channels and samples
	int channel_buffer_size = nb_samples;
	frame->ResizeAudio(info.channels, channel_buffer_size, info.sample_rate, info.channel_layout);

	AppendDebugMethod("FrameMapper::ResampleMappedAudio (Audio successfully resampled)", "nb_samples", nb_samples, "total_frame_samples", total_frame_samples, "info.sample_rate", info.sample_rate, "channels_in_frame", channels_in_frame, "info.channels", info.channels, "info.channel_layout", info.channel_layout);

	// Array of floats (to hold samples for each channel)
	float *channel_buffer = new float[channel_buffer_size];

	// Divide audio into channels. Loop through each channel
	for (int channel_filter = 0; channel_filter < info.channels; channel_filter++)
	{
		// Init array
		for (int z = 0; z < channel_buffer_size; z++)
			channel_buffer[z] = 0.0f;

		// Loop through all samples and add them to our Frame based on channel.
		// Toggle through each channel number, since channel data is stored like (left right left right)
		int channel = 0;
		int position = 0;
		for (int sample = 0; sample < (nb_samples * info.channels); sample++)
		{
			// Only add samples for current channel
			if (channel_filter == channel)
			{
				// Add sample (convert from (-32768 to 32768)  to (-1.0 to 1.0))
				channel_buffer[position] = resampled_samples[sample] * (1.0f / (1 << 15));

				// Increment audio position
				position++;
			}

			// increment channel (if needed)
			if ((channel + 1) < info.channels)
				// move to next channel
				channel ++;
			else
				// reset channel
				channel = 0;
		}

		// Add samples to frame for this channel
		frame->AddAudio(true, channel_filter, 0, channel_buffer, position, 1.0f);

		AppendDebugMethod("FrameMapper::ResampleMappedAudio (Add audio to channel)", "number of samples", position, "channel_filter", channel_filter, "", -1, "", -1, "", -1, "", -1);
	}

	// Update frame's audio meta data
	frame->SampleRate(info.sample_rate);
	frame->ChannelsLayout(info.channel_layout);

	// clear channel buffer
	delete[] channel_buffer;
	channel_buffer = NULL;

	// Delete arrays
	delete[] resampled_samples;
	resampled_samples = NULL;
}
Ejemplo n.º 27
0
 bool DbBatchAction::MakeupStatement(const tr1::shared_ptr<StmtGenerator>& elem, BatchFilter* filter)
 {
     return elem->MakeupStatement(filter->GetColumns(), filter->GetTableName(), filter->GetValues(), filter->CheckCompatible());
 }
Ejemplo n.º 28
0
tr1::shared_ptr<AbstractNumber> E::multiply(tr1::shared_ptr<AbstractNumber>number){
    char newSign = '-';
    if (getSign() == number->getSign())
    {
        newSign = '+';
    }

    if(number -> getName() == "E")
	{
	    if (newSign == '+')
        {
            tr1::shared_ptr<AbstractNumber> exp(new SmartInteger(2));
            tr1::shared_ptr<AbstractNumber> me(new E());
            tr1::shared_ptr<AbstractNumber> ans(new Exponent(me, exp));
            return ans;
        }
        else
        {
            tr1::shared_ptr<AbstractNumber> exp(new SmartInteger(-2));
            tr1::shared_ptr<AbstractNumber> me(new E());
            tr1::shared_ptr<AbstractNumber> ans(new Exponent(me, exp));
            return ans;
        }
	}

	else if (number -> getName() == "Exponent")
	{
	    tr1::shared_ptr<Exponent> numExp = tr1::static_pointer_cast<Exponent>(number);
		if (numExp -> getValue("base") -> getName() == "E")
		{
			tr1::shared_ptr<AbstractNumber> exp = numExp->getValue("power");
			tr1::shared_ptr<AbstractNumber> exp2(new SmartInteger(1));
			tr1::shared_ptr<AbstractNumber> me(new E());

			tr1::shared_ptr<AbstractNumber> ans2(new Exponent(me, exp -> add(exp2), newSign));
			return ans2;
		}
	}
	else if (number->getName() == "Radical") {
		 if (abs(number->getValue("value")->toDouble() - toDouble()) < 0.000001 )
		 {
			 tr1::shared_ptr<AbstractNumber> one(new SmartInteger(1));
			 tr1::shared_ptr<AbstractNumber> invertedRoot(new MultExpression(one, number->getValue("root"), '+'));
			 tr1::shared_ptr<AbstractNumber> me(new E());
			 tr1::shared_ptr<AbstractNumber> output(new Exponent(me, invertedRoot->add(one), newSign));
			 return output;
		 }
		 else
         {
            vector<tr1::shared_ptr<AbstractNumber> > M;
            M.push_back(number);
            M.push_back(shared_from_this());
            tr1::shared_ptr<AbstractNumber> ans3(new MultExpression(M, '+'));
            return ans3;
         }
	 }

    else if(number->getName() == "MultExpression")
    {
        return number->multiply(shared_from_this());
    }
    vector<tr1::shared_ptr<AbstractNumber> > M;
    M.push_back(number);
    M.push_back(shared_from_this());
    tr1::shared_ptr<AbstractNumber> ans3(new MultExpression(M, '+'));
    return ans3;

}
Ejemplo n.º 29
0
int main() {

  vector< tr1::shared_ptr<AbstractNumber> > ansHistory;
  vector<string>  expHistory;
  bool menuLoop = true;
    int input = 0;
    int setAns;
    cout << "||||   WELCOME   ||||" << endl;
    cout << "||||   TO OUR    ||||" << endl;
    cout << "|||| CALCULATOR  ||||" << endl;
    cout << " _____________________ " << endl;
    cout << "|  _________________  |" << endl;
    cout << "| |               0 | |" << endl;
    cout << "| |_________________| |" << endl;
    cout << "|  ___ ___ ___   ___  |" << endl;
    cout << "| | 7 | 8 | 9 | | + | |" << endl;
    cout << "| |___|___|___| |___| |" << endl;
    cout << "| | 4 | 5 | 6 | | - | |" << endl;
    cout << "| |___|___|___| |___| |" << endl;
    cout << "| | 1 | 2 | 3 | | x | |" << endl;
    cout << "| |___|___|___| |___| |" << endl;
    cout << "|_____________________|" << endl;

    while (menuLoop)
    {
    	cout << "\nPlease enter one of the options below: " << endl;
    	cout << "=================================================" << endl;
        cout << "1. Compute New Expression                       |" << endl;
        cout << "=================================================" << endl;
        cout << "2. Help                                         |" << endl;
        cout << "=================================================" << endl;
        cout << "3. Review Previous Expressions and Answers      |" << endl;
        cout << "=================================================" << endl;
        cout << "4. Quit                                         |" << endl;
        cout << "=================================================\n" << endl;

        cin>>input;

        if ( !( (1 <= input) && (input <= 4) ) )
        {
            cin.clear();
            while (cin.get() != '\n');
            cout << "\nNot a valid menu option. Please enter 1, 2, 3, or 4." << endl;
            continue;
        }

        switch (input)
        {
            case 1:
            {
                cin.ignore();
                bool keepCompute = true;
                while (keepCompute)
                {

                    string input2;
                    cout << "Enter the expression to compute. (Type 'back' to go back to the main menu)" << endl;
                    getline(cin, input2);
                    if(input2 != "")
                    {


                    	if (input2.find("back") != string::npos)
                    	{
                    		keepCompute = false;
                    	}
                    	else
                    	{

                    				try{
                    					if(input2.rfind("ans") != std::string::npos)
                    					{
                        				unsigned found = input2.rfind("ans");
                                        if (history == "")
                                            history = "0";
                    					input2.replace(found, std::string("ans").length(), "(" + history + ")");

                    					tr1::shared_ptr<AbstractNumber> num(new SumExpression(input2,true));
                    					historyAns = num->simplify();
                    					cout << "Result: \n" << historyAns->toString() << endl;
                    					ansHistory.push_back(historyAns);
                    					history = input2;
                    					expHistory.push_back(history);
                    					}
                    					else
                    					{
                    						tr1::shared_ptr<AbstractNumber> num(new SumExpression(input2,true));
                    						historyAns = num->simplify();
                    						cout << "Result: \n" << historyAns->toString() << endl;
                    						ansHistory.push_back(historyAns);
                    						history = input2;
                    						expHistory.push_back(history);
                    					}


                    				}
                    				catch(exception &msg)
                    				{

                    					cout << "***ERROR: "<< msg.what() << "***"  << endl;
                    				}



                    		}
                    	}
                    else
                    {
                    	cout << "Result: Invalid Expression\n" << endl;
                    }
                }


                break;
            }
            case 2:
                printHelp();

                break;
            case 3:
            	if(ansHistory.size() == 0)
            	{
            		cout << "Please enter some expressions before viewing this option." << endl;
            	}
            	else
            	{
            	cout << "The previous answer was: " << historyAns->toString() << endl;
            	cout << "The previous answer as a decimal: " << historyAns->toDouble() << endl;
            	cout << "This answer may be used in further calculations by using the keyword 'ans'" << endl;
            	cout << "\nThe previous expressions and answers calculated are as follows: " << endl;

            	for(int i=0; i<ansHistory.size(); i++)

            	{

            		cout << "(#" << (ansHistory.size()-i) << ")" << "Expression: " << expHistory[i] << endl;
            		cout << "Answer: " << ansHistory[i]->toString() << "\n" << endl;

            	}




            		cout << "To set 'ans' to a previous expressions's answer, please enter the corresponding digit: " << endl;
            		cin>>setAns;

            		if(!( (1 <= setAns) && (setAns <= ansHistory.size()) ))
            		{

            			cin.clear();
            			while (cin.get() != '\n');
            			cout << "\nNot a valid menu option. Please enter 1-10." << endl;
            			continue;
            		}

            			else if(((1 <= setAns) && (setAns <= ansHistory.size()))== 1)
            			{
            			history = ansHistory[ansHistory.size() - setAns]->toString();


            		}
            		else
            		{
            			cout << "\nNot a valid menu option. Please enter 1-10." << endl;
            		}

            	}
                break;
            case 4:
            	cout << "The calculator will now exit. Thank you!" << endl;
                menuLoop = false;
                break;
        }
    }
}
  sshfs_t filesystem_adaptor::mount_sshfs (const saga::session & s, const saga::url & u )
  {
    saga::url   tgt = u;

    // if url is any:// based, convert to ssh:// as expected by sshfs
    if ( tgt.get_scheme () == "any" )
    {
      tgt.set_scheme ("ssh");
    }

    std::string id  = get_sshfs_id (tgt);

    
    // std::cout << " mounted_        mount  :  " << this             << std::endl;
    // std::cout << " mounted_.size() mount 1:  " << mounted_.size () << std::endl;
    // std::cout << " tested__.size() mount 1:  " << tested__.size () << std::endl;

    // check if we have that mounted already
    if ( mounted_.find (id) != mounted_.end () )
    {
      // make sure the fs is mounted
      mounted_[id]->mount ();

      return mounted_[id];
    }

    // is not mounted, yet - try to mount it, store a new shared pointer, and
    // return it.
    SAGA_LOG_ALWAYS ("to mount new sshfs");
    SAGA_LOG_ALWAYS (id.c_str ());
    SAGA_LOG_ALWAYS (tgt.get_string ().c_str ());

    TR1::shared_ptr <sshfs> ptr;
    try 
    {
      ptr.reset (new sshfs (ini_, s, tgt));
    }
    catch ( const saga::exception & e )
    {
      SAGA_LOG_ERROR (e.what ());
      std::stringstream ss;
      ss << "Could not mount sshfs for " << tgt << " : \n  " << e.what () <<
        std::endl;
      SAGA_ADAPTOR_THROW_NO_CONTEXT (ss.str ().c_str (), saga::BadParameter);
    }

    if ( ! ptr )
    {
      // cannot mount the fs for some reason - throw a BadParameter
      SAGA_ADAPTOR_THROW_NO_CONTEXT ("sshfs mount failed for unknown reason",
                                     saga::NoSuccess);
    }

    // std::cout << " mounted_.size() mount 2:  " << mounted_.size () << std::endl;
    // std::cout << " tested__.size() mount 2:  " << tested__.size () << std::endl;

    // got the fs mounted - register it, and return the ptr
    mounted_[id] = ptr;
    tested__[id] = 1;
    SAGA_LOG_ALWAYS ("register mounted sshfs");
    SAGA_LOG_ALWAYS (id.c_str ());

    // std::cout << " === register mounted sshfs: " << id << std::endl;
    // std::cout << " mounted_.size() mount 3:  " << mounted_.size () << std::endl;
    // std::cout << " tested__.size() mount 3:  " << tested__.size () << std::endl;

    return ptr;
  }